Skip to content

Instantly share code, notes, and snippets.

@proprietary
proprietary / external-links-in-new-window.js
Created October 7, 2017 16:16
open all external links in new window
@proprietary
proprietary / queryMap.go
Created November 17, 2017 02:20
query database in golang into a map/hash table instead of struct
import (
"database/sql"
_ "github.com/lib/pq"
"log"
)
// queryMap is used for quickly running a SQL query that returns only one
// row. Important: This shouldn't ever return errors and shouldn't ever
// be applied on user input. Ideally, you're querying non-nullable
// columns using keys you got from some trusted (non-human)
@proprietary
proprietary / GoogleFeelingLucky
Last active December 8, 2017 03:29
string to add Google I'm Feeling Lucky as a search engine in Chrome (works Nov 2017)
https://www.google.com/search?source=hp&q=%s&oq=%s&btnI=1
function roundTiesToEven(n) {
var TOLERANCE = 1e-6
if (Math.abs(n%1 - 0.5) <= TOLERANCE) {
var f = Math.floor(n)
return f%2 === 0 ? f : f+1
} else {
return Math.round(n)
}
}
@proprietary
proprietary / rmcl
Created March 8, 2018 22:55
deletes currently playing song in Clementine (works on GNU/Linux)
#!/usr/bin/env bash
# Deletes currently playing song in Clementine (works on GNU/Linux). Helps thin out a music library.
# 1. chmod a+x rmcl
# 2. add to PATH
# 3. use in GNOME by Alt+F2 + 'rmcl', easy
function is_playing() {
qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus
}
@proprietary
proprietary / mnt-mymountpoint.mount
Created April 12, 2018 13:25
systemd automount sshfs: how to automatically mount a remote sshfs filesystem with systemd
# Change the relevant {{ PARTS OF THIS FILE }} for your remote address etc.
# Make sure this unit file is named similarly to your mountpoint; e.g., for /mnt/mymountpoint name this file mnt-mymountpoint.mount
# On Ubuntu:
# $ sudo cp mnt-mymountpoint.mount /lib/systemd/system/
# $ sudo systemctl enable mnt-mymountpoint.mount
# $ sudo systemctl start mnt-mymountpoint.mount
# On Fedora:
# $ sudo cp mnt-mymountpoint.mount /etc/systemd/system
# $ sudo systemctl enable mnt-mymountpoint.mount
# $ sudo systemctl start mnt-mymountpoint.mount
@proprietary
proprietary / send_mail.rb
Created July 19, 2018 07:21
send gmail with ruby net/smtp
require 'net/smtp'
def send_email (to:, msg:, subject:, from_name:, from:, password:)
message = "From: #{from_name} <#{from}>\n" \
"To: <#{to}>\n"\
"Subject: #{subject}\n"\
"#{msg}\n"
smtp = Net::SMTP.new 'smtp.gmail.com', 587
smtp.enable_starttls
smtp.start('gmail.com',
First, run the following command to create a blank disk image:
$ hdiutil create -o /tmp/HighSierra.cdr -size 7316m -layout SPUD -fs HFS+J
Next, mount your blank image:
$ hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
Now you’re going to restore BaseSystem.dmg from the installer over to the newly mounted image:
@proprietary
proprietary / set_key_repeat_delay.cc
Created November 7, 2018 06:08
How to set key repeat rate and delay (in milliseconds) on Windows 10
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
BOOL parseDword(const char* in, DWORD* out)
{
char* end;
long result = strtol(in, &end, 10);
BOOL success = (errno == 0 && end != in);
if (success)

Keybase proof

I hereby claim:

  • I am proprietary on github.
  • I am zelly (https://keybase.io/zelly) on keybase.
  • I have a public key ASD9bCbFInpbh5w-KGEFJ2s9a4S1_qlYRtiGZOpv5H2KWAo

To claim this, I am signing this object: