Skip to content

Instantly share code, notes, and snippets.

View lucaong's full-sized avatar

Luca Ongaro lucaong

View GitHub Profile
@lucaong
lucaong / leggibilizza.html
Created February 9, 2012 15:23
Bookmarklet per rendere i blog minimamente leggibili
<h1>Un Appello ai Blogger Italiani</h1>
<p>Per favore:
<ul>
<li>Utilizzate una font di almeno 14 pixels, meglio 16</li>
<li>Utilizzate un interlinea intorno al 150%</li>
<li>Mantenete strette le colonne di testo</li>
</ul>
Grazie per non volerci procurare cecit&agrave;.
</p>
@lucaong
lucaong / jquery-placeholders.js
Created March 1, 2012 09:38
jQuery plugin providing feature detection and cross-browser fallback for html5 input placeholder
/* Placeholders plugin for jQuery
* Use this to provide a graceful fallback for browsers not supporting the html5 placeholder attribute
*
* Usage:
* jQuery('form').placeholders(); // if the user's browser do not support placeholder, it implements a fallback
*
* You can also specify some options:
* jQuery('form').placeholders({
* placeholderAttr: "title", // specify the attribute to get placeholder value from (default: 'placeholder')
* placeholderedClass: "custom-class" // the class added to the input element when its value is a placeholder (default 'placeholdered')
@lucaong
lucaong / README.md
Created March 15, 2012 16:22
Experimenting with a client-side Rails-like JavaScript Model

Experimenting with a Rails-like client-side JavaScript Model

Backbone.js is awesome, but sometimes you just don't need the full MVC stack.

This is just a random experiment to come up with something simple and familiar to Rails developers, to allow something like:

// create a Post model
var Post = jjj.Model({
@lucaong
lucaong / README.md
Created November 22, 2012 15:39
Experiment with a nano-library for DOM selection

Usage:

the $query (aliased with $q) object exposes two methods: first() and all(). Both take a selector string as the first argument and, optionally, a context element as the second.

$q.first(".foo"); // => first element of class `foo`
$q.all(".foo");   // => array (yes, not NodeList) of all elements of class `foo`

var elem = $q.first("p");
@lucaong
lucaong / git-standup
Last active January 15, 2021 16:30 — forked from AndrewRadev/git-standup
#! /usr/bin/env ruby
require 'date'
require 'fileutils'
require 'optparse'
def parse_cli_options
options = {}
OptionParser.new do |opts|
#! /usr/bin/env ruby
require 'date'
require 'fileutils'
require 'optparse'
def parse_cli_options
options = {}
OptionParser.new do |opts|
@lucaong
lucaong / SassMeister-input.scss
Created February 18, 2014 16:18
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.4)
// Compass (v1.0.0.alpha.18)
// ----
// Start with a class .foo
.foo {
line-height: 150%;
font-size: 2em;
}
@lucaong
lucaong / SassMeister-input.scss
Created February 18, 2014 16:19
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.4)
// Compass (v1.0.0.alpha.18)
// ----
// Start with a class .foo
%foo {
line-height: 150%;
font-size: 2em;
}
@lucaong
lucaong / README.md
Last active August 29, 2015 13:56
ClosedStruct

ClosedStruct

A stupidly simple implementation of a kind of "sorta immutable" struct that can be instantiated as conveniently as an OpenStruct but after instantiation it doesn't let me (easily) add fields or mutate them:

guy = ClosedStruct.new( name: "John", age: 23 )

# readers:
guy.name             #=> "John"
guy.age #=&gt; 23
@lucaong
lucaong / lru_cache.js
Created September 29, 2014 23:59
JavaScript LRU cache implementation
var LRUCache = (function() {
function LRUCache(options) {
this._options = options || {}
this._map = {}
this._queue = {}
this._capacity = this._options.capacity || 10
this._size = 0
}
var _detachFromQueue = function(node, queue) {