Skip to content

Instantly share code, notes, and snippets.

Avatar
drinking coffee

Rafal Piekarski RaVbaker

drinking coffee
View GitHub Profile
@RaVbaker
RaVbaker / types.rb
Created Dec 11, 2017
Runtime type checking in Ruby - proof-of-concept
View types.rb
module Types
InvalidTypeError = Class.new(ArgumentError)
def specify(spec, a_method)
args_spec = []
return_spec = nil
case spec.first
when Hash
args_spec = spec.first.keys.first
@RaVbaker
RaVbaker / app_proxy.rb
Last active Jul 20, 2020
Simple HTTP app Proxy using sinatra
View app_proxy.rb
# ENDPOINT="host.com" ruby app_proxy.rb
# curl -i localhost:4567/capture # => "<TIMEOUT>" or regular response every 2 calls
require 'sinatra'
require 'net/http'
$request_settings = { host: ENV["ENDPOINT"] }
$headers = { "Content-Type" => "application/json" }
$counter = 0
View keybase.md

Keybase proof

I hereby claim:

  • I am ravbaker on github.
  • I am ravbaker (https://keybase.io/ravbaker) on keybase.
  • I have a public key whose fingerprint is EE34 D7F4 AD3C 0C1C AAA1 23BA 98D3 D195 22C2 259E

To claim this, I am signing this object:

@RaVbaker
RaVbaker / initial_state_bug.rb
Last active Aug 29, 2015 — forked from Tuhaj/initial_state_bug.rb
Corrected version of initial repo by @Tuhaj
View initial_state_bug.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'activerecord', '4.2.1'
gem 'state_machines'
gem 'state_machines-activerecord'
gem 'sqlite3'
gem 'minitest'
GEMFILE
@RaVbaker
RaVbaker / geocoder-service.js
Last active Aug 29, 2015 — forked from avaliani/geocoder-service.js
My solution is basically original with fixed bugs and removed dependency on underscore. :)
View geocoder-service.js
/*
* An AngularJS Service for intelligently geocoding addresses using Google's API. Makes use of
* localStorage (via the ngStorage package) to avoid unnecessary trips to the server. Queries
* Google's API synchronously to avoid `google.maps.GeocoderStatus.OVER_QUERY_LIMIT`.
*
* @author: benmj
* @author: amir.valiani
*
* Original source: https://gist.github.com/benmj/6380466
*/
@RaVbaker
RaVbaker / ar_instantiate_test.rb
Created May 14, 2014
AR.instantiate with hash when keys are symbols bug
View ar_instantiate_test.rb
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.1'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
@RaVbaker
RaVbaker / your_legacy_code.sh
Created Mar 16, 2014
Most changed files in your project - like @mfeathers suggested at #wrocloverb 2014 conference
View your_legacy_code.sh
find . -name "*.rb" |xargs -n1 -I file sh -c 'echo `git log --oneline file | wc -l`: file'|sort -nr |head
@RaVbaker
RaVbaker / nametab.sh
Created Nov 27, 2013
[iTerm] Naming tabs in iTerm
View nametab.sh
#!/bin/bash
# A simple script which will name a tab in iTerm
# usage:
# $ nametab NewTabName
echo "trying to rename the current tab to $@"
echo -ne "\033]0;"$@"\007"
echo "finished"
@RaVbaker
RaVbaker / readme.md
Last active Apr 6, 2020
Reverse engineering Things SQLite tasks database
View readme.md

To open SQLite Things.app database run this command in Terminal.app:

$ sqlite3 ~/Library/Containers/com.culturedcode.things/Data/Library/Application\ Support/Cultured\ Code/Things/ThingsLibrary.db

In SQLite command-line type this query to get your tasks stats:

sqlite> .mode column
sqlite> .header on
sqlite> select zscheduler, zstatus, ztrashed, count(*) from ZTHING where z_ent = 13 group by  zstatus,ztrashed order by Z_pk desc;
ZSCHEDULER  ZSTATUS     ZTRASHED    count(*)
You can’t perform that action at this time.