This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'open3' | |
require 'colorize' | |
# CODE | |
@actions = {} | |
def action(id, name, &block) | |
@actions[id] = { name:name, func:block } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo npm install nodemon -g | |
nodemon server.coffee | |
open stand-alone.html | |
stand-alone.html?room1 | |
stand-alone.html?room2 | |
stand-alone.html?room3 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'sinatra' | |
require 'digest' | |
ROOT = Dir.getwd | |
error = nil | |
for dir in ['cache','cache/originals', 'cache/resized', 'cache/pages', 'cache/croped'] | |
dir = "#{ROOT}/#{dir}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.Persona = | |
loaded: false | |
button: null | |
init: (element) -> | |
$ -> | |
Persona.button = $(element) | |
return unless Persona.button[0] | |
unless Persona.button[0].persona_binded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- https://wiki.postgresql.org/wiki/Fixing_Sequences | |
SELECT 'SELECT SETVAL(' || | |
quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) || | |
', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' || | |
quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';' | |
FROM pg_class AS S, | |
pg_depend AS D, | |
pg_class AS T, | |
pg_attribute AS C, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_request_locale | |
I18n.default_locale ||= I18n.available_locales[0] | |
if params[:locale] | |
if I18n.available_locales.index(params[:locale].to_sym) | |
session[:locale] = params[:locale] | |
else | |
avail = I18n.available_locales.map{|el| %[<a href="#{request.path.sub(/\w+/,el.to_s)}">#{el}</a>] } | |
page_error 404, "Locale "#{params[:locale]}" is not supported, try with #{avail.to_sentence.sub(/\sand\s/,' or ')}" | |
end | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def as_array_values | |
name = @opts[:name] | |
ret = [] | |
values = @opts[:value].kind_of?(String) ? @opts[:value].split(',') : @opts[:value] | |
for el in @opts[:collection] | |
ret.push %[<label style="position:relative; top:4px;"> | |
<input name="#{name}[#{el[1]}]" value="1" type="checkbox" #{values[el[1]].present? ? 'checked=""' : ''} style="position:relative;top:2px; left:2px;" /> | |
<span style="margin-right:10px;">#{el[0]}</span> | |
</label>] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# gem install sass | |
# npm install -g clean-css | |
# npm install -g uglify-js | |
# less, scss, coffee | |
require 'colorize' | |
require 'pathname' | |
require 'json' | |
require 'listen' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def paginate(list) | |
ret = ['<div class="paginate"><div>'] | |
if list.paginate_page > 0 | |
url = Url.current | |
list.paginate_page == 1 ? url.delete(list.paginate_var) : url.qs(list.paginate_var, list.paginate_page) | |
ret.push %[<a href="#{url.relative}">←</a>] | |
else | |
ret.push %[<span>←</span>] | |
end |