Skip to content

Instantly share code, notes, and snippets.


Julio Cesar Ody juliocesar

View GitHub Profile
juliocesar / best-localStorage-polyfill-evar.js
Created Apr 18, 2011
This is the best localStorage polyfill in the world
View best-localStorage-polyfill-evar.js
// I mean, seriously, localStorage is supported even by your mum. How about instead of
// casing the feature out, you give users in-memory (stale) storage instead?
// If they close your application, they deserve to lose data anyway.
// if (!('localStorage' in window)) {
if (!Modernizr.localstorage) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
View prefix-mixins.sass
// Prefix mixins
// =============
// A set of SASS mixins for abstracting vendor prefixes.
@mixin background-size($parameters)
-webkit-background-size : $parameters
-moz-background-size : $parameters
-o-background-size : $parameters
background-size : $parameters
View for-loops.js
// ES6 for loops
// =============
// Things in ES6 can be "iterable". Arrays are iterable by default.
var fruits = ['Apple', 'Banana', 'Grape'];
for (var fruit of fruits)
console.log('Fruit: ' + fruit);
juliocesar /
Created Nov 21, 2019


Sort of, but not quite.

NSDAP (the Nazi Party) won a plurality of seats in the Reichstag (Parliament), but was unable to form a majority government because the Communists won the second-greatest number of seats, and while neither party won a majority, they collectively won enough seats for neither one to be able to muster enough support from the other parties to form a working majority.

I don't remember the exact details (I'm sure someone else can elaborate), but basically the Nazis did their best to paralyze the government. Eventually, there was an alleged terrorist attack (actually staged by the Nazis themselves) that convinced (independent) President Hindenburg to name Hitler as "Chancellor" in exchange for the Nazis agreeing to form a coalition government with other parties. At the time, Chancellor was a largely symbolic and ceremonial role.

The Nazis then did what would, in computer security terms, be classified as a complex m

juliocesar /
Created Oct 21, 2010
Testing front-end for a Sinatra app with RSpec and Capybara

Testing front-end for a Sinatra app with RSpec and Capybara

I've used Cucumber quite a bit on my last job. It's an excellent tool, and I believe readable tests are the way to the future. But I could never get around to write effective scenarios, or maintain the boatload of text that the suite becomes once you get to a point where you have decent coverage. On top of that, it didn't seem to take much for the suite to become really slow as tests were added.

A while ago I've seen a gist by Lachie Cox where he shows how to use RSpec and Capybara to do front-end tests. That sounded perfect for me. I love RSpec, I can write my own matchers when I need them with little code, and it reads damn nicely.

So for my Rails Rumble 2010 project, as usual, I rolled a Sinatra app and figured I should give the idea a shot. Below are my findings.


juliocesar / vsjsonp.js
Last active Aug 8, 2016
Very simple JSONP
View vsjsonp.js
// VSJONP ― Very Simple JSONP
// ==========================
// Usage:
// fetchJsonP({
// url: 'http://shit-no-cors.json',
// complete: function(response) {
// console.log(response);
// }
// });
juliocesar / color.scss
Last active Aug 3, 2016
Color palette implementation in Sass
View color.scss
// Color scale function
// ====================
// Similarly to dirg, this assists with creating rhythmic colour
// variations from a palette. The definition of the $color-palette var
// is made at build time.
// Granularity of variations.
$step-size: 7.5% !default;
juliocesar / gist:ebb658162370d2482d5520ea7a8581c7
Created Jun 8, 2016
Shell function for converting videos into GIFs.
View gist:ebb658162370d2482d5520ea7a8581c7
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 21 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 50% out-static*.png GIF:- | gifsicle --colors 256 --delay=5 --loop --optimize=3 --mul
tifile - > $1.gif
rm out-static*.png
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
View Capfile
# Capistrano deployment file
# ==========================
# Deployment requires that you can log in as "web", which means you'll
# need it's password.
require 'bundler/capistrano'
set :rvm_ruby_string, :local # Use the same ruby as used locally for deployment
set :rvm_autolibs_flag, "read-only" # More info: rvm help autolibs
View gist:6409580
# Kool console
# ============
# A snippet for running CoffeeScript snippets in browser, with a cool
# centered text input.
# Press <meta> + K to open the console.
# Styles for the text field.
CSS = """