Skip to content

Instantly share code, notes, and snippets.

View 13k's full-sized avatar

K 13k

View GitHub Profile
@13k
13k / openpgp.md
Last active August 20, 2023 22:46
Keyoxide
@13k
13k / foundation.go
Last active September 20, 2022 16:23
Accessing Foundation Framework from Go with cgo
// How to build: "CC=clang go build"
package main
import (
"fmt"
"net/url"
"strconv"
"unsafe"
)
@13k
13k / gist:3086739
Created July 10, 2012 22:49
Capybara in Rails Console
# rails console test
# # or
# RAILS_ENV=test rails console
require 'capybara/dsl'
Capybara.app = app.instance_variable_get("@app")
cap = Object.new.instance_eval { extend Capybara::DSL; self }
# cap.visit '/'
# cap.page.find 'h1'
@13k
13k / strip.sh
Created July 5, 2011 18:10
bash utils: stripping
# strip whitespace
strip() { local s="${1/%*([[:space:]])}"; echo "${s/#*([[:space:]])}"; }
# strip non-printing escape sequences (\[ ... \]) from string
strip_np() {
local c=`echo -e "\x06"`
local tmp="${1//@(\\\[|\\\])/$c}"
echo "${tmp//${c}*([^${c}])${c}}"
}
@13k
13k / migrate-create-tests.cmd
Created December 4, 2019 08:46
Migrate create Windows tests (df00bdc095175d7f0026b11813bd21ec1fb61914)
rem "migrate create" Windows tests
mkdir migs
rem ==============================
rem bad digits
rem ==============================
migrate.exe create -dir migs -ext .sql -seq -digits 0 bad_digits
@13k
13k / home_page.go
Last active January 18, 2019 13:57
Flutter in Go (https://divan.github.io/posts/flutter_go) - Functional options approach
func (m *MyHomePage) Build(ctx BuildContext) Widget {
return NewScaffold(
ScaffoldWithAppBar(
NewAppBar(
AppBarWithTitle(
NewTitle(
TitleWithText(NewText(TextWithText("My home page"))),
),
),
),
# Documentation: https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.md
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class ExampleApp < Formula
desc ""
homepage ""
url "http://example.com/example_app-1.0.tar.gz"
version "1.0"
sha256 ""
@13k
13k / sidekiq_scheduling.rb
Last active March 31, 2016 18:02
low-level sidekiq scheduling helpers
# reschedule a known job
# i: job index
# soon: reschedule time
def reschedule(i=0, soon=1.minute.from_now)
# black magic
Sidekiq.redis do |r|
m = r.zrange('schedule', i, i).first
j = JSON.parse(m)
j['at'] = soon.to_f
r.zrem('schedule', m)
FATAL -- : error adding listener addr=
/Users/k/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/socket_helper.rb:200:in `server_cast': undefined method `getsockname' for nil:NilClass (NoMethodError)
command Ruby19Hashes %s/\v:(\w+)(\s*)\=\>/\1:/g