Skip to content

Instantly share code, notes, and snippets.

View tinco's full-sized avatar

Tinco Andringa tinco

View GitHub Profile
@tinco
tinco / redis_stack.rb
Created April 27, 2023 09:10
Some methods for accessing Redis Stack
require 'redis'
require 'rejson'
RClient = Redis.new(host: "localhost", port: 36379, db: 0)
class RedisStack
class << self
REDIS_GRAPH_VALUE_UNKNOWN = 0,
REDIS_GRAPH_VALUE_NULL = 1,
REDIS_GRAPH_VALUE_STRING = 2,
@tinco
tinco / merge_tool.rb
Last active May 27, 2019 17:38
Merging IMC and PPK data
#!/usr/bin/env ruby
def merge_imc_ppk
if ARGV.length != 2
STDERR.puts "Usage: geotags_tool merge_imc_ppk <mission_control_csv> <ppk_csv>"
exit 1
end
imc_csv_path = ARGV[0]
ppk_csv_path = ARGV[1]
@tinco
tinco / keybase.md
Created July 26, 2018 10:00
Keybase proof

Keybase proof

I hereby claim:

  • I am tinco on github.
  • I am tinco (https://keybase.io/tinco) on keybase.
  • I have a public key whose fingerprint is 74B2 B6B2 0B8E C941 5245 1F1F 2D8B 95B4 23A1 D443

To claim this, I am signing this object:

@tinco
tinco / keybase-proof.md
Created January 6, 2015 13:51
Keybase proof

Keybase proof

I hereby claim:

  • I am d-snp on github.
  • I am tinco (https://keybase.io/tinco) on keybase.
  • I have a public key whose fingerprint is 944D C40A 8B2B 0CD6 67EB D303 0195 4C3B D3B4 367B

To claim this, I am signing this object:

@tinco
tinco / monty_hall.rb
Created July 25, 2014 20:18
Monty Hall playing code
def play_monty_hall(strategy)
doors = [:car,:goat,:sheep]
guess = doors.sample
if strategy == :switch
# the revealed door is one that's not the winning and not the one we guessed
revealed_door = doors.reject{|door| door == :car || door == guess}.sample
# we change our guess to the door that was not revealed (and not our guess)
@tinco
tinco / concurrent_sieve.hs
Created November 18, 2012 15:39 — forked from tmhedberg/concurrent_sieve.hs
Concurrent prime sieve translated from Go (http://play.golang.org/p/9U22NfrXeq)
-- Compile with `ghc -threaded -with-rtsopts=-N concurrent_sieve.hs`
import Control.Concurrent
import Control.Monad
import System.Environment
-- Map over [2..] (2 until infinity), putting the value in mOut. The putting operation will block until
-- mOut is empty. mOut will become empty when some other thread executes takeMVar (getting its value).
generate :: MVar Int -> IO ()
@tinco
tinco / gist:3773216
Created September 23, 2012 22:08
RVM openssl error
[tinco@MacBook ~] rvm pkg install openssl
Fetching openssl-1.0.1c.tar.gz to /Users/tinco/.rvm/archives
There is no checksum for 'http://www.openssl.org/source/openssl-1.0.1c.tar.gz' or 'openssl-1.0.1c.tar.gz', it's not possible to validate it.
If you wish to continue with unverified download add '--verify-downloads 1' after the command.
Extracting openssl-1.0.1c.tar.gz to /Users/tinco/.rvm/src
Error running 'tar', please read /Users/tinco/.rvm/log/openssl/extract.log
/Users/tinco/.rvm/scripts/functions/pkg: line 52: cd: /Users/tinco/.rvm/src/openssl-1.0.1c: No such file or directory
Configuring openssl in /Users/tinco/.rvm/src/openssl-1.0.1c.
Error running './Configure', please read /Users/tinco/.rvm/log/openssl/configure.log
@tinco
tinco / BuzzFizz.hs
Created May 4, 2012 21:39
Inverse of FizzBuzz implementation in Haskell
isFizz i = mod i 3 == 0
isBuzz i = mod i 5 == 0
isFizzBuzz i = isFizz i && isBuzz i
isFizzOrBuzz i = isFizz i || isBuzz i
isNeither i = (not.isBuzz) i && (not.isFizz) i
toFizzBuzz i
| isFizzBuzz i = "FizzBuzz"
| isFizz i = "Fizz"
| isBuzz i = "Buzz"
command -nargs=1 IndentStyle call IndentStyle("<args>")
let g:IndentStyle = "none"
fun IndentStyle(style)
if a:style == "ruby"
"ruby style:
set tabstop=2
set shiftwidth=2
set expandtab
--trace ree
rvm 0.1.38 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
+ [[ -z '' ]]
+ [[ ! -z ree ]]
+ rvm_action=use
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ 1 -gt 0 ]]