Skip to content

Instantly share code, notes, and snippets.

@k3rni
k3rni / nested-tags-exploration.rb
Created March 18, 2020 15:10
Various styles of nested method definitions
class NestedMethods
def bad
def inner
puts "bad/inner"
end
inner
end
def good_lambda
inner = -> { puts "good_lambda/inner" }
@k3rni
k3rni / Gemfile
Created March 17, 2020 12:53
Ruby script to load and validate private SSH-RSA keys
source 'https://rubygems.org'
gem 'bindata'
gem 'bcrypt_pbkdf', github: 'mfazekas/bcrypt_pbkdf-ruby'
@k3rni
k3rni / ansible.cfg
Created July 23, 2019 09:17
Gruvbox colors for ansible
[colors]
highlight = color223
verbose = color66
warn = color167
error = color124
debug = color245
deprecate = color132
skip = color72
unreachable = color124
ok = color142
@k3rni
k3rni / hollerith_card.py
Created February 10, 2018 00:53
Decipher contents of a Hollerith-style punched card
# As read on the card, top-down. For convenience, leading zeros can be skipped
rows = [
"11000001100001001110010101010101001011000110",
"11000000110000000101010001000100100100001",
"100011000110001000000100000000000001000",
"100001000000000000000100001001000000",
"0",
"100001000100101110110100000000100001000",
"10010000000000000000000000000000000",
"10001000000001000001000010000100000100011",
@k3rni
k3rni / gems.rb
Last active July 5, 2017 13:07
Private `Module.delegate` behavior is wrong?
source 'https://rubygems.org'
gem 'activesupport', '~> 5.0'
gem 'minitest'
@k3rni
k3rni / shell
Created July 7, 2016 13:56
NPM taki fajny
$ npm install -g eslint eslint-config-standard-react-native
[ciachciach]
npm ERR! Linux 4.4.0-28-generic
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package eslint@3.0.1 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer eslint-config-standard@5.3.1 wants eslint@^2.0.0-rc.0
npm ERR! peerinvalid Peer eslint-config-standard-react-native@1.0.0 wants eslint@^3.0.0
@k3rni
k3rni / login.css
Last active August 29, 2015 14:26
Enable full-size ponymote emoji in ScudCloud
/* Append this to /opt/scudcloud/resources/login.css */
[data-emoji^=twi], [data-emoji^=rarity], [data-emoji^=pp], [data-emoji^=flutter], [data-emoji^=aj], [data-emoji^=rd], [data-emoji^=sb], [data-emoji^=granny] {
height: 100% !important;
}
[data-emoji^=twi], [data-emoji^=rarity], [data-emoji^=pp], [data-emoji^=flutter], [data-emoji^=aj], [data-emoji^=rd], [data-emoji^=sb], [data-emoji^=granny] > .emoji-sizer {
width: 2em !important;
height: 2em !important;
}
@k3rni
k3rni / bzip2.rb
Created March 11, 2014 12:28
simplest possible ruby bzip2 library
require 'open3'
require 'delegate'
require 'stringio'
class BzipFile < SimpleDelegator
attr_accessor :path
end
# Features and nonfeatures:
# * doesn't support writing
@k3rni
k3rni / mctechtree.lua
Created April 16, 2013 22:43
Access MCTechTree from inside Computercraft. Needs HTTP API enabled.
args={...}
url="http://mctechtree.herokuapp.com/solve.lua"
name=table.concat(args, ' ')
-- TODO: split on commas, pass multiple items
local request = http.post(url, "items[]="..name)
if request == nil then
error("Error making request")
end
data=request.readAll();
loadstring(data)()
@k3rni
k3rni / inliner_spec.rb
Created October 22, 2012 10:13
Roadie failing CDATA + HTML Comments spec
it 'ignores HTML comments and CDATA sections' do
use_css %(<![CDATA[
<!--
p { color: green }
-->
]]>)
expect { rendering '<p></p>' }.not_to raise_error
end