Skip to content

Instantly share code, notes, and snippets.

View jeremija's full-sized avatar

Jerko Steiner jeremija

View GitHub Profile
@jeremija
jeremija / 90-tp-compact-keyboard.rules
Last active April 6, 2023 09:26
Attempt to persistent bluetooth pairing (Thinkpad Bluetooth Keyboard with Trackpoint)
# udev rules to be placed in /etc/udev/rules.d
# this is from https://github.com/lentinj/tp-compact-keyboard
SUBSYSTEM=="input", \
ATTRS{name}=="ThinkPad Compact Bluetooth Keyboard with TrackPoint", \
RUN+="/etc/udev/scripts/tp-compact-keyboard --fn-lock-enable"
# this is my script
SUBSYSTEM=="input", \
ATTRS{name}=="ThinkPad Compact Bluetooth Keyboard with TrackPoint", \

Sends HTTP File to AppleTV for Playback

go get github.com/jeremija/appletv
appletv [apple-tv-host:port] [http-url-to-play]

Running from source:

@jeremija
jeremija / go.md
Created March 6, 2020 07:17
go example
// db/db.go
type MyDB struct {
  DB *sql.DB
}

func Exec(query string, params... interface{}) error {...}
func Select(target interface{}, query string, params... interface) error {...}
@jeremija
jeremija / create-cert.sh
Last active June 25, 2019 08:01
Create root CA and certificates
#!/bin/bash
DOMAIN=$1
MERGED="$DOMAIN-merged.crt"
echo "Generating private key for certificate signing request" > /dev/stderr
openssl genrsa -out $DOMAIN.key 2048
echo "Creating a certificate signing request" > /dev/stderr
openssl req -new -key $DOMAIN.key -out $DOMAIN.csr \
@jeremija
jeremija / .tern-project
Created October 20, 2017 19:42
Tern plugin to work with babel-plugin-module-resolver
{
"libs": [],
"loadEagerly": [],
"plugins": {
"node": {},
"es_modules": {},
"module-resolver": {
"cwd": "packagejson",
"alias": {
"my-alias1": "./path/to/my/module1",
@jeremija
jeremija / index.js
Last active September 26, 2017 01:59
knex raw query with where (example)
'use strict'
const knex = require('knex')
const { expect } = require('chai')
const db = knex({
client: 'sqlite3',
connection: ':memory:',
useNullAsDefault: true
})
describe('raw', () => {
@jeremija
jeremija / init.lua
Created May 24, 2017 12:35 — forked from juanmiret/init.lua
Simple Vi mode with Karabiner-elements and Hammerspoon
local module = {}
module.debugging = false -- whether to print status updates
local eventtap = require "hs.eventtap"
local event = eventtap.event
local inspect = require "hs.inspect"
local keyHandler = function(e)
local watchFor = {
@jeremija
jeremija / update-node-deps.js
Created April 27, 2017 19:19
update node deps
'use strict';
const pkg = require('./package.json');
const _ = require('underscore');
const fs = require('fs');
const deps = {};
fs.readFileSync('./deps').toString().split('\n').forEach(row => {
row = row.split('@');
deps[row[0]] = row[1];
});
@jeremija
jeremija / socat.sh
Created February 18, 2016 14:54
forward port 8080 to port 80
sudo socat tcp-listen:80,reuseaddr,fork tcp:localhost:8080
@jeremija
jeremija / gist:7729929
Created December 1, 2013 08:38
Recursive object traversal
function traverse(data) {
for (var objName in data) {
if (!data.hasOwnProperty(objName)) {
continue;
}
var obj = data[objName];
if (typeof obj === 'object') {
console.log('obj: ' + objName + ' = {}...');
this.traverse(obj);