Skip to content

Instantly share code, notes, and snippets.

View dux's full-sized avatar

Dino Reić dux

  • Trifolium
  • London, Zagreb, Berlin
View GitHub Profile
@dux
dux / git-stat.rb
Last active August 29, 2015 13:56
Simple git statistics, prints git user and number of files and lines changed in last 14 days
#!/usr/bin/ruby
require 'colorize'
require 'optparse'
options = {}
op = OptionParser.new do |opts|
opts.banner = "Usage: git-stat.rb [options]"
opts.on("-d", "--days N", Integer, "In last x days") do |v|
options[:days] = v
@dux
dux / generate.rb
Last active August 29, 2015 13:57
Simple native rails generate, without Rails and Rails generators
#!/usr/bin/ruby
require 'colorize'
@locations = []
def generate_file( file_name, data )
if File.exist?(file_name)
info = 'exists'.red
else
@dux
dux / expand_yt_to_fs.js
Last active August 29, 2015 13:57
Expand YouTube video to full screen - bookmarklet
// GOOD bookmarklet, copy and paste
javascript:elms=['masthead-positioner-height-offset', 'content', 'footer-container', 'masthead-positioner'];for (i in elms) { var e=document.getElementById(elms[i]); if (e) e.parentNode.removeChild(e); };document.getElementById('player-api').setAttribute('class','player-api');window.exTFS=function(){ s = document.body.clientHeight-1; document.getElementById('player-api').setAttribute('style','position:absolute;top:0px; left:0px; width:100%; min-height:'+s+'px;z-index:100000000000');document.getElementById('movie_player').setAttribute('style','min-height:'+s+'px;');void(document.getElementsByTagName('video')[0].setAttribute('style','width:100%;min-height:'+s+'px;'))};window.onresize=exTFS;exTFS();
// annotated source
elms=['masthead-positioner-height-offset', 'content', 'footer-container', 'masthead-positioner'];
for (i in elms) { var e=document.getElementById(elms[i]); if (e) e.parentNode.removeChild(e); }
document.getElementById('player-api').setAttribute('class','player-
@dux
dux / gist:9881717
Created March 30, 2014 23:30
get remote postgree database
#!/bin/bash
REMOTE_HOST=deployer@1.2.3.4
REMOTE_DB_NAME=db_production
REMOTE_DB_USER=db_user
REMOTE_DB_PASS=db_pass
LOCAL_DB=db_local
echo $REMOTE_DB_PASS | pbcopy
@dux
dux / finds.rb
Last active August 29, 2015 14:00
grep -r CLI response prettifier and open file inteface # http://i.imgur.com/qpNl0KQ.png
#!/usr/bin/ruby
find = ARGV.join(' ')
unless find =~ /\w/
print "WHAT: Finds text via grep -r, trims long reponses, pretty print and open file interface\n"
print "USAGE: ./finds [text to find in realtive path without quotes]\n"
print "EXAMPLE: ./finds def avatar\n"
print "@dux 2014\n"
exit
@dux
dux / cgrep
Created April 30, 2014 00:40
colorized grep # memcached -vv 2>&1 | cgrep GET SET # for resoult of http://i.imgur.com/ifnrEj9.png
#!/usr/bin/ruby
require 'colorize'
colors = [:green, :red, :yelow, :blue]
$stdin.each_line do |l|
for el, i in ARGV.each_with_index
next unless l =~ /#{el}/
print l.send(colors[i])
@dux
dux / string_base.rb
Last active August 29, 2015 14:03
Encode any integer to string base of choice. Just replace keys with one you want to encode into. StringBase.encode(11111111) == "frgh"
module StringBase
KEYS = 'bcdfghjklmnpqrstvwxyz'
def self.encode( value )
ring = Hash[KEYS.chars.map.with_index.to_a.map(&:reverse)]
base = KEYS.length
result = []
until value == 0
result << ring[ value % base ]
value /= base
@dux
dux / post-commit
Last active August 29, 2015 14:04
StashBuckets.com post commit hook wor Work Logs app
#!/usr/bin/ruby
# create .git/hooks/post-commit
# chmod +x .git/hooks/post-commit
# http://githooks.com/
# to test if it works just run ".git/hooks/post-commit" and it should post last git commit
require 'net/http'
require 'uri'
require 'colorize' # gem install colorize
@dux
dux / remote.rb
Last active August 29, 2015 14:05
simple replacement for Rails capistrano
#!/usr/bin/ruby
require 'open3'
require 'colorize'
# CODE
@actions = {}
def action(id, name, &block)
@actions[id] = { name:name, func:block }
@dux
dux / PubSub
Last active August 29, 2015 14:06
NodeJS PubSub server - simple firebase API clone
sudo npm install nodemon -g
nodemon server.coffee
open stand-alone.html
stand-alone.html?room1
stand-alone.html?room2
stand-alone.html?room3