Skip to content

Instantly share code, notes, and snippets.

View pingiun's full-sized avatar

Jelle Besseling pingiun

View GitHub Profile
@pingiun
pingiun / longtweets.js
Created December 11, 2022 17:45
Long Tweet Remover userscript
// ==UserScript==
// @name Long Tweet Remover
// @version 0.1
// @description remove tweets with more than 280 characters
// @author Jelle Besseling
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// ==/UserScript==
@pingiun
pingiun / README.md
Last active June 8, 2021 22:50
Zig sha256 and sha512 implementations without unnecessary code duplication

To learn Zig I implemented some crypto functions in Zig. It uses unique Zig comptime features to reduce code duplication

{ config, pkgs, lib, ... }:
let
helios-src = builtins.fetchTarball "https://github.com/pingiun/helios-server/archive/147da23bd9097c16c94a24cf4cc98bd709a35393.tar.gz";
helios = import helios-src;
user = "helios";
db-name = user;
@pingiun
pingiun / bf.c
Last active October 7, 2020 23:22
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// initialize the tape with 30,000 zeroes
unsigned char tape[30000] = {0};
// set the pointer to point at the left-most cell of the tape
unsigned char* ptr = tape;
@pingiun
pingiun / Habits.sol
Created August 21, 2020 17:00
Habits testing
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.7.0;
import "Owner.sol";
/**
* Track habits with a financial stake if you fail.
*/
contract Habits is Owner {
struct Habit {
@pingiun
pingiun / bisq.2m.sh
Last active July 30, 2020 13:39
Get the latest BTC price from Bisq and compare with Coinbase. This script is a Bitbar plugin: https://getbitbar.com
#!/usr/local/bin/bash
# Donations are always apreciated: 337tQLpE6u7itDzju1d3zdnWBr1qR9mNNW
# Can be changed to any currency both Bisq and Coinbase support (usd, eur are tested)
currency="eur"
alt_currency="usd"
tickers=$(curl -sS "https://markets.bisq.network/api/ticker/")
coinbase=$(curl -sS "https://api.coinbase.com/v2/prices/BTC-${currency}/buy")
@pingiun
pingiun / newsletterintro.sh
Last active July 20, 2020 14:54
Generate newsletter introduction piece, license: GPL-3.0
#!/usr/bin/env bash
set -euo pipefail
get_events() {
lang_website=$1
export LC_ALL=$2
for pk in $(curl -H "Accept-Language: $lang_website" "https://thalia.nu/api/v1/events/" 2>/dev/null | jq '.|=sort_by(.start)|.[].pk'); do
event=$(curl -H "Accept-Language: $lang_website" "https://thalia.nu/api/v1/events/$pk/" 2>/dev/null)
@pingiun
pingiun / configuration.nix
Last active April 13, 2019 11:47
The nixos configuration file I use to use mac.jelle.space for my macbook
let
wireguardPort = 51820;
tunnels = [ {
ipv4Addr = { addr = "195.201.249.203"; suffix = 32; };
ipv6Addr = { addr = "2a01:4f8:c2c:2b57::2"; suffix = 128; };
wgPublicKey = "3WWr1zr3ry6KeAwr3Cw3mQsnBeLLUYs1DGa7iEwyAWA=";
} ];
mkAddrWithSuffix = (x: "${x.addr}/${toString x.suffix}" );
extern crate tokio;
extern crate dhcp_proto;
use std::io;
use tokio::codec::{Decoder, Encoder};
use bytes::{BytesMut};
use dhcp_proto::{DHCPMessage, nom, parse_dhcp};
use dhcp_proto::builder::DHCPMessageBuilder;
from sqlalchemy import Column, PickleType
def upsert(obj):
"""Inserts the `obj` or updates if it already exists
Postgresql is the only database that supports upserts like this, but sqlite is used locally so a "hack" is used to support
an alternative check and update/insert method. This cannot be used when multithreading."""
# SQLalchemy model objects have the table object in __table__
table = obj.__table__
# Filter out private values from the object