Skip Navigation
code_monkeys

Code Monkeys

  • YSK How to get a weather report in your terminal

    Lately I've been obsessed with moving everything that people typically use as widgets into my bashrc. Today I discovered wttr.in, which is an open source project on Github at https://github.com/chubin/wttr.in

    Usage is almost trivial. To get weather in your terminal, simply curl the URL with your city after the forward slash. If you live in New York City, use curl 'https://wttr.in/New%20York'

    Now, if that's too much bloat to have covering your precious terminal real estate, instead use curl 'https://wttr.in/New%20York'?0?A?u which will truncate the curl to only today's weather.

    0
  • Embrace terminal

    2
  • There is a language that punishes the programmer if they are not polite enough

    INTERCAL is an esoteric programming language which was purposely designed to be confusing and not visually aesthetic. It has two maintained implementations in C-INTERCAL and CLC-INTERCAL. C-INTERCAL's compiler is invoked by the ick command, and CLC-INTERCAL's compiler is invoked by the sick command.

    Some highlights of INTERCAL include

    • Programmers must use PLEASE before statements to avoid compile errors due to insufficiently polite, but not too many PLEASE statements or the compiler will report errors due to being overly polite.
    • Every call to a random number generator will introduce a random chance of the code failing to compile and report E774 RANDOM COMPILER BUG, and this chance to fail increases with the number of random number generator calls.
    • If compiling in INTERCAL-72 mode, the compiler will report E111 COMMUNIST PLOT DETECTED if the programmer uses features that are newer than INTERCAL-72.

    The full list of compiler errors and warnings for C-INTERCAL, as well as related documentation, can be found in the intercal/doc/ick.txi file under the "Errors and Warnings" chapter. If you want to quickly scroll through them, each of the entries are preceded by an @ieanchor tag.

    0
  • PSA for Lemmy instance admins: in backend v0.18.3 there is a bug that causes your instance to stop federating properly and to stop sending out outgoing messages

    cross-posted from: https://yiffit.net/post/868741

    > This new version introduced a system so that your instance stops sending out content to other instances that are supposedly dead / offline. > > Unfortunately for some reason there's false positives. When I checked comparing the results from a curl request vs the information in our Lemmy database I found over 350+ false positives. > > In the DB there is a table called "instance" which has a column called "updated". If the date on that column is older than 3 days, your server will stop sending any content to those instances. > > For some reason I had entries that were dated as last being alive in July, while actually they were always up. If an entry is incorrect, you can fix it by manually using an update statement and adding today's date. If your instance is not too large you can safely update all entries to today's date and check if everything works as expected from then on any new content created on your instances. > > The dead instances won't have an impact unless your instance is larger and generates more content, thus it might be easier to simply update all entries and have Lemmy believe they're all alive if you start noticing wonky behavior and don't want to check one by one. > > If you don't know how to access the database run this command where domaincom is your instance domain without the dot. > > 1. docker exec -it domaincom_postgres_1 busybox /bin/sh > > 2. psql -U > > (The default user is 'lemmy') > You could technically do this is one single step, but it's good to know the command to get shell access to the container itself if you didn't know how to. > > This should give you access to a postgres CLI interface. > Use \c to connect, \dt to list tables and \d+ tablename to list table definition. You can also run SQL queries from there. > > Try with this query: SELECT * from instance to list all instances and their updated date. > > You can use other SQL queries to get better results or correct false positives. Just be careful with what you execute since there's no undo.

    1
  • Links for creating your own LLM

    Some helpful links regarding training your own LLM since I've been playing with:

    https://github.com/geekylink/PicoGPT

    Hacker News post: https://news.ycombinator.com/item?id=36832572

    LLAMA: https://github.com/ggerganov/llama.cpp

    Dead simple LLAMA: https://cocktailpeanut.github.io/dalai/#/

    1
  • YSK how to get your IP address from the command line

    While it's easy to get an IP address from popular websites such as whatismyip.com, it's not often friendly to a context where you might need to get your IP address for command line tools.

    In order to grab your IP address via the command line, there's a page on a site called ipinfo.io/ip which only contains body content corresponding to your IP address. The easiest way to fetch that data is with the curl command (should be available on both Windows and Linux). curl ipinfo.io/ip It may also be beneficial to add this to your .bashrc or .aliasrc on Linux systems with something like alias myip="curl ipinfo.io/ip" Now you have an easy way to grab your IP address from the command line!

    3
  • Using rclone to backup your data encrypted in the cloud

    Rclone is a cool little CLI tool for Linux/WSL that allows you to backup, sync, and even mount various cloud server provider options on your desktop/server and protect your data.

    For additional security, you can encrypt the files before they are uploaded to the cloud so even the folder & file names, and file types are encrypted. By doing this client-side encryption you can pretty safely assume your files are free for snooping.

    Your password can be two passwords so you can access it from machine as well and recover your archive in case of your device failing.

    Once you have a crypt volume setup you can then copy your files manually, sync a directory to the cloud, or even mount your cloud drive as a local directory for easy exploration.

    sudo apt install rclone

    Then run:

    rclone config

    Optional: You don't have to use your own API keys but you'll be sharing it with everyone else who uses rclone with the default API keys and they throttle the connections with usage. So it's best to setup your own oauth consent screen and credentials here:

    https://console.cloud.google.com/apis/

    If you want a detailed guide on configuring rclone for Google Drive check this guide:

    https://www.maketecheasier.com/rclone-sync-multiple-cloud-storage-providers-linux/

    After you have a cloud account connected and named, you can create a crypt volume on top of it:

    https://www.maketecheasier.com/use-rclone-crypt-encrypt-files/

    rclone github:

    https://github.com/rclone/rclone

    0
  • How to install a Linux terminal on your phone

    Here's how to download and install a Linux terminal via the Termux app on your phone.

    Why should you install a Linux terminal on your phone? It allows you to easily ssh, code, and even host webapps from the palm of your hand. Those are my own use examples, but the possibilities are limitless.

    Note: The Termux app on the Google play store is out of date and doesn't have the correct permissions to work properly.

    1. Install an alternative app store. You may need to briefly modify permissions to install an app after downloading it via Firefox/Chrome/Brave. I used F-Droid
    2. Install Termux through the app store. You'll know it's the right one if the app page links back to termux.com and the termux/termux-app Github. You may again need to grant permissions to your alternative appstore to install it.
    3. Once you have Termux installed, you'll first want to run pkg upgrade in the terminal to update all the packages. Termux uses the pkg package manager, which wraps apt, to avoid doing dangerous things.
    4. At this point, you've done all the hard setup. If you want to access your phone's local storage, you can mount it by executing termux-setup-storage (see the wiki).
    5. Do you want to run python? Ruby? Npm (not sure why this link is broken)? For all those details and more, check out the Termux wiki.
    0
  • cross-posted from: https://programming.dev/post/266503

    > Yes, who haven't had a glass of red wine, relaxing music and some inline assembly....

    0
  • THANK YOU CANONICAL

    I LOVE /dev/loop I LOVE /dev/loop I LOVE /dev/loop I LOVE /dev/loop I LOVE /dev/loop I LOVE /dev/loop I LOVE /dev/loop I LOVE /dev/loop

    0
  • Lemmy Deployed

    Install docs for docker:

    https://join-lemmy.org/docs/administration/install_docker.html

    Gits:

    https://github.com/LemmyNet/lemmy

    https://github.com/LemmyNet/lemmy-ui

    Docs: https://join-lemmy.org/docs/introduction.html

    0
1 Active user