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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sortable test Dino</title> | |
</head> | |
<body> | |
<style> | |
ul { margin:0; padding:0; width:200px; float:left; margin-right:50px; } | |
ul li { border:1px solid #ccc; background-color:#eee; margin-bottom:10px; padding:10px; } |
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
// simple templateing | |
String.prototype.template = function() { | |
var formatted = this, arg; | |
var args = typeof(arguments[0]) === 'object' ? arguments[0] : arguments; | |
for(arg in args) { | |
formatted = formatted.replace("{" + arg + "}", args[arg]); | |
} | |
return formatted; | |
}; |
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 | |
require 'open3' | |
require 'colorize' | |
unless Dir.exists?('.git') | |
puts 'No .git directory'.red | |
exit | |
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
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 |
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 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
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
--- 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
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
#!/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}" |