Skip to content

Instantly share code, notes, and snippets.

@padde
padde / ilike.sql
Created January 8, 2015 15:02
ILIKE
SELECT * FROM posts WHERE body ILIKE '%zweitag%'
@padde
padde / test.json
Created January 8, 2015 10:24
some json
{
"hello": "world"
}
@padde
padde / brainfuck.ex
Created November 12, 2014 07:47
Brainfuck interpreter in Elixir
# Inspired by these blog posts:
# http://dev.mikamai.com/post/100075543414/elixir-as-a-parsing-tool-writing-a-brainfuck
# http://dev.mikamai.com/post/102283561929/elixir-as-a-parsing-tool-writing-a-brainfuck
defmodule Brainfuck do
@op_decv "-"
@op_incv "+"
@op_decp "<"
@op_incp ">"
@op_putc "."
@padde
padde / filter_matching.exs
Last active May 8, 2017 23:31
Filter a list by pattern matching in Elixir
defmodule MyEnum do
defmacro filter_matching(collection, pattern) do
quote do
Enum.filter unquote(collection), fn
unquote(pattern) -> true
_ -> false
end
end
end
end
@padde
padde / open3.rb
Last active August 29, 2015 14:05
require 'open3'
command = 'sh'
Open3.popen2e(command) do |stdin, stdout_and_stderr, wait_thread|
Thread.new do
stdout_and_stderr.each {|l| puts l }
end
stdin.puts 'ls'
@padde
padde / array_to_proc.rb
Last active August 29, 2015 14:04
Pass arguments to Ruby shortcut procs
class Array
def to_proc
->(obj) { obj.public_send *self }
end
end
input = <<EOS
foo,bar,baz
hello,world
1,2,3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def inspect(s):
if s is None:
return '"None"'
return '"' + str(s) + '"'
@padde
padde / portcheck.sh
Created July 2, 2014 22:42
Is port in use?
netstat -anp tcp | awk '$6 ~ "LISTEN" && $4 ~ "22$"'
@padde
padde / SSH-Remote-Port-Forwarding.markdown
Last active September 8, 2022 06:03
SSH Remote Port Forwarding

!!! WIP !!!

SSH Remote Port Forwarding

TODO: intro

Provision Server

  • DigitalOcean
  • 512 MB RAM
@padde
padde / gist:a2a789e504cdbfc739c1
Created June 20, 2014 12:54
Gitio Shell Alias
function gitio { curl -fsi git.io -F "url=$1" | grep 'Location' | sed 's/.*: //' | tee >(pbcopy) }