Skip to content

Instantly share code, notes, and snippets.

View akhy's full-sized avatar

Akhyar Amarullah akhy

View GitHub Profile
@solarkraft
solarkraft / syncthing-automerge.py
Created December 30, 2022 18:00
Monitors a Syncthing-synced directory and tries to merge conflicting files (based on https://www.rafa.ee/articles/resolve-syncthing-conflicts-using-three-way-merge/). Probably adaptable for other directory types, but only tested with Logseq (works for me™️).
import os
import time
import re
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
def get_relative_path(path):
return os.path.relpath(path)
@Makeshift
Makeshift / tutorial.md
Last active November 15, 2024 21:57
Tutorial for automatically syncing an Obsidian vault with Git on an Android device

How to sync Obsidian with Git on Android

Limitations

  • If Termux is closed in the background by Android, the cron service will stop updating your repository and you must open Termux again. Refer to instructions for your device model to disable the killing of certain background applications.
  • This may negatively affect your devices battery life. I'm not entirely sure yet.

Setup

@dkorn
dkorn / compile_nginx_from_sources.yml
Created October 11, 2017 08:57
Ansible Playbook compiling NGINX from sources, to include particular modules
---
- name: Compile NGINX from sources
hosts: webserver
vars:
nginx_version: nginx-1.13.4
nginx_tarball_url: "http://nginx.org/download/{{ nginx_version }}.tar.gz"
nginx_install_dir: "/tmp/{{ nginx_version }}"
nginx_sbin_path: "/usr/sbin/nginx"
nginx_conf_path: "/etc/nginx/nginx.conf"
@heyimalex
heyimalex / sqlmap.go
Last active April 6, 2024 14:25
Functions for querying directly into map[string]interface{}
// Package sqlmap provides functions for querying directly into
// map[string]interface{}.
//
// In developing really simple api endpoints, I found the boilerplate needed
// to take the results of a database query and output them as JSON to be
// really fucking annoying; make a custom struct, scan into that struct, if
// there are multiple rows do the whole rows.Next() song and dance, and if
// anything changes update the three spots each column of the result is now
// dependent on. Even when using libraries like sqlx, there's still a lot of
// extraneous code that needs to be written.
@peterhellberg
peterhellberg / graceful.go
Last active November 13, 2024 20:20
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@dhanifudin
dhanifudin / zshrc.zsh
Created July 23, 2016 11:05
Integrate prezto with zplug
export ZPLUG_HOME=$HOME/.zplug
source $ZPLUG_HOME/init.zsh
zmodload zsh/zprof
zplug "zplug/zplug"
# Prezto framework
zplug "sorin-ionescu/prezto", \
use:"init.zsh", \
@mandrachek
mandrachek / MultiDexJunitRunner
Last active August 22, 2016 09:25
AndroidJunitRunner that supports MultiDex
import android.os.Bundle;
import android.support.multidex.MultiDex;
import android.support.test.runner.AndroidJUnitRunner;
public class MultiDexJunitRunner extends AndroidJUnitRunner {
@Override
public void onCreate(Bundle arguments) {
MultiDex.install(getTargetContext());
super.onCreate(arguments);
}
@haasn
haasn / about:config.md
Last active August 9, 2024 10:23
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.

@filewalkwithme
filewalkwithme / main.go
Created February 7, 2015 21:50
Listening multiple ports on golang http servers
package main
import (
"net/http"
)
func main() {
finish := make(chan bool)
server8001 := http.NewServeMux()
package trikke.gists;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;