Skip to content

Instantly share code, notes, and snippets.

View roccogalluzzo's full-sized avatar
⛑️

Rocco Galluzzo roccogalluzzo

⛑️
View GitHub Profile
'''
prefix_code.py
Copyright 2012-2013 Josiah Carlson
Released under the GNU LGPL v 2.1 license
This module offers the ability to encode/decode a sequence of integers into
strings that can then be used to compare sequences of integers (or paths on
trees) quickly. This module was originally intended to be used in a case-
preserving index in a relational database (where 'Z' comes before 'a', as is
/**
* Exercise 3
*/
def countChange(money: Int, coins: List[Int]): Int = {
if (money == 0) 1
else if (money < 0 || coins.isEmpty) 0
else countChange(money, coins.tail) + countChange(money - coins.head, coins)
}
@roccogalluzzo
roccogalluzzo / gist:1977777
Created March 5, 2012 10:27 — forked from dhh/gist:1975644
Protect against Mass assigniments bugs
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
DELIMITER $$
CREATE PROCEDURE `geodist`(IN mylat float, IN mylon float, IN dist int)
BEGIN
declare lon1 float; declare lon2 float;
declare lat1 float; declare lat2 float;
set lon1 = mylon-dist/abs(cos(radians(mylat))*111.1);
set lon2 = mylon+dist/abs(cos(radians(mylat))*111.1);
set lat1 = mylat-(dist/111.1);
def render(template_name, tmpl_vars={}, cache_key=None,
cache_type=None, cache_expire=None):
globs = pylons_globals()
tmpl_vars.update(globs)
@contextfunction
from routes import Mapper
class CustomMapper(Mapper):
def match(self, url= None, environ= None):
if not url and not environ:
raise RoutesException('URL or environ must be provided')
if not url:
from routes import Mapper
class CustomMapper(Mapper):
def match(self, url= None, environ= None):
if not url and not environ:
raise RoutesException('URL or environ must be provided')
if not url:
144 Query SET NAMES utf8
144 Init DB wordpress
144 Query SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
144 Query SELECT option_value FROM wp_options WHERE option_name = 'sidebars_widgets' LIMIT 1
144 Query SELECT option_value FROM wp_options WHERE option_name = 'rewrite_rules' LIMIT 1
144 Query SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 10
144 Query SELECT FOUND_ROWS()
144 Query SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag') AND tr.object_id IN (4, 1) ORDER BY t.name ASC
144 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (4,1)
144 Query SELECT option_value FROM wp_options WHERE option_name = 'kubrick_header_image' LIMIT 1
db = ['pri','secondo','terzo','quarto','quinto','sesto']
for string in db:
string_ascii= ''
s_len = len(string)
if (s_len > 5): string = string[:5]
for char in string: string_ascii+= str(ord(char))
var Element = {
visible: function() {return (!this.hasClassName('toggle'));},
toggle: function() {if (this.visible()) { this.hide();} else {this.show();}},
hide: function() {this.addClassName('toggle'); return this;},
show: function() { this.removeClassName('toggle'); return this;},
remove: function() { this.getParentNode().removeChild(this);return null;},
empty: function() {while (this.getLastChild()) { this.removeChild(this.getLastChild());}}
}
function $(element) {