Skip to content

Instantly share code, notes, and snippets.

@thsig
thsig / emacs-icelandic-keyboard.el
Last active August 29, 2015 14:02
Emacs key bindings for Icelandic keyboard
;; Icelandic keyboard setup
(define-key key-translation-map (kbd "M-ö") (kbd "\\"))
(define-key key-translation-map (kbd "M-8") (kbd "["))
(define-key key-translation-map (kbd "M-9") (kbd "]"))
(define-key key-translation-map (kbd "M-7") (kbd "{"))
(define-key key-translation-map (kbd "M-0") (kbd "}"))
(define-key key-translation-map (kbd "M-q") (kbd "@"))
(define-key key-translation-map (kbd "M--") (kbd "~"))
org.jruby.RubyMatchData.updateCharOffset(RubyMatchData.java:137)
org.jruby.RubyMatchData.begin19(RubyMatchData.java:479)
org.jruby.RubyMatchData$i$1$0$begin19.call(RubyMatchData$i$1$0$begin19.gen:65535)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:167)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.DAsgnNode.interpret(DAsgnNode.java:110)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
@thsig
thsig / cube.rb
Last active April 11, 2016 19:02
brute-force count of the number of Hamiltonian paths on the surface of a cube from a given starting vertex
require 'set'
class Hash
def dig(key, *rest)
if value = (self[key] rescue nil)
if rest.empty?
value
elsif value.respond_to?(:dig)
value.dig(*rest)
end
@thsig
thsig / git-open
Created March 27, 2018 15:06
Simple script for viewing a file at a given commit/branch Github.com
#!/usr/bin/env ruby
usage_description = """Usage:
github-open <commit> [<path> [<line-number>]]
Uses the <origin> remote's URL, and assumes that it's a Github repo.
"""
args = ARGV
@thsig
thsig / garden-dev.txt
Last active April 5, 2019 14:35
Rails example - garden dev log output
$ garden dev --hot=frontend
Good morning! Let's get your environment wired up...
✔ local-kubernetes → Configured
✔ tiller → Installing to garden-system... → Done (took 5.9 sec)
ℹ tiller → Service deployed
ℹ tiller → Service deployed
✔ kubernetes-dashboard → Building version v-4f7ba3eeaf... → Done (took 1.5 sec)
✔ ingress-controller → Building version v-df47c0150b... → Done (took 1.5 sec)
@thsig
thsig / frontend-hot-reload.yml
Created April 5, 2019 14:38
Rails example - hot reload config for frontend service
hotReload:
sync:
- source: app/
target: /usr/src/app/app
@thsig
thsig / frontend-service-config.yml
Created April 5, 2019 14:40
Rails example - service config for frontend
services:
- name: frontend
ports:
- name: http # Maps 80 to 3000.
containerPort: 3000
ingresses:
- path: /
port: http
hostname: vote-rails.local.app.garden
dependencies:
@thsig
thsig / frontend-tasks.yml
Created April 5, 2019 14:42
Rails example - task config for frontend
tasks:
- name: db-migrate
args: [rake db:migrate]
dependencies:
- postgres
@thsig
thsig / postgres-config.yml
Created April 5, 2019 14:43
Rails example - garden.yml for postgres service
kind: Module
description: Postgres container for storing voting results
type: container
name: postgres
image: postgres:9.4
Services:
- name: postgres
volumes: # A persistent volume for the data.
- name: data
containerPath: /db-data
@thsig
thsig / rails-console.txt
Created April 5, 2019 14:45
Rails example - running rails console inside the container
$ garden run module frontend "rails console"
Running command rails console in module frontend 🏃
✔ frontend → Getting build status... → Done (took 0.4 sec)
Loading development environment (Rails 5.2.2.1)
irb(main):001:0> Vote.where(animal: "cat").count
(0.7ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."animal" = $1 [["animal", "cat"]]
=> 6