Skip to content

Instantly share code, notes, and snippets.

View ricardobeat's full-sized avatar

Ricardo Tomasi ricardobeat

View GitHub Profile
@ricardobeat
ricardobeat / mongoose-indexing.js
Created September 13, 2011 05:30
MongoDB - test compound indexes on embedded documents
var mongoose = require('mongoose')
, Schema = mongoose.Schema
mongoose.connect('mongodb://localhost/identities');
var IdentitySchema = new Schema({
type : { type: String, enum: ['twitter', 'facebook', 'google'] }
, uid : { type: String }
})
@ricardobeat
ricardobeat / favicon.txt
Created June 4, 2012 20:36
Create multiple-size, alpha transparent favicon.ico
# How to create a favicon with multiple image sizes and keep alpha transparency
- export your images in the desired sizes (16x16, 32x32 ... max 256x256) as PNGs + alpha
- install ImageMagick
Run this command (replacing the .png files for your own images):
convert favicon-16.png favicon-32.png favicon-64.png -colors 256 -alpha background favicon.ico

Simple comparison between Atomic CSS vs 'standard' CSS. Might not be representative of larger files.

results

file raw gzip
with-atomic.css 576b 325b
with-atomic.html 1183b 254b
without-atomic.css 1676b 324b
without-atomic.html 714b 199b
@ricardobeat
ricardobeat / .profile
Last active December 25, 2015 05:39
simple PS1 for development VM
# Reset
Color_Off="\[\033[0m\]" # Text Reset
# Regular Colors
Black="\[\033[0;30m\]" # Black
Red="\[\033[0;31m\]" # Red
Green="\[\033[0;32m\]" # Green
Yellow="\[\033[0;33m\]" # Yellow
Blue="\[\033[0;34m\]" # Blue
Purple="\[\033[0;35m\]" # Purple
@ricardobeat
ricardobeat / serialize-multipart.js
Created September 20, 2013 04:28
JSON serialize to multipart form data
function serializeMultipart (obj, previous) {
var pairs = []
_.each(obj, function (value, key) {
if (previous !== undefined) {
key = previous + '[' + key + ']'
}
if (_.isArray(value)) {
_.each(value, function (value) {
pairs.push([key + '[]', value])
@ricardobeat
ricardobeat / npm-permissions.sh
Last active December 22, 2015 16:08
/usr/local permissions for NPM on Ubuntu. User should be part of the *admin* group.
sudo chgrp -R admin /usr/local/lib/node_modules
sudo chmod -R g+w /usr/local/lib/node_modules
@ricardobeat
ricardobeat / .gitconfig
Created September 9, 2013 14:02
Git config
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
function soma (a, b) {
return a + b
}
module.exports = soma
@ricardobeat
ricardobeat / up.coffee
Last active December 20, 2015 20:29
coffeescript + generators
upload = (stream, idOrPath, tag, done) ->*
blob = blobManager.create(account)
tx = db.begin()
blobId = *blob.put(stream)
file = *self.byUuidOrPath(idOrPath).get()
prevId = file?.version
version = {
userAccountId : userAccount.id
<script>
document.body.addEventListener('click', function(e){
if (e.target.tagName.toLowerCase() !== 'a' || !e.target.href) return
_gaq.push(['_trackEvent', 'Outbound Links' , e.target.href])
}, false)
</script>