Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
Build that!

David Gil dgilperez

🌊
Build that!
View GitHub Profile
@dgilperez
dgilperez / codewall.badges.js
Last active Aug 26, 2015 — forked from marcinbunsch/codewall.badges.js
Coderwall - display missing badges
View codewall.badges.js
// How to use this:
// 1. Go to the desired profile page on coderwall, like http://coderwall.com/marcinbunsch
// 2. Paste this gist in the JS console
//
// You can also probably use this in greasemonkey and dot.js
//
// Also, it was tested in Chrome, Firefox and Safari, it probably will
// not work in IE, but I just don't care about it ;)
//
// UPDATE: Coderwall made changes to the site and I cannot retrieve the achievements, so they are hardcoded, taken from a cached version of the achievements page
View gist:8847922
require 'delegate'
class Base
def foo
"foo"
end
def bar
"bar"
end
end
View Bitmask.js
// Slick little method to create a bitmask from an array of boolean values. (for Javascript)
function bitMask(a, b) {
var m = 0, i;
if (b !== undefined) { a = Array.prototype.slice.apply(arguments); }
for (i = 0; i < a.length; i += 1) {
if (a[i] !== false) { m += Math.pow(2, i) };
}
return m;
View Capybara-Rspec-Rails-assets-pipeline.md
View abilities.rb
module Abilities
def self.ability_for(user)
if user.admin?
AdminAbility.new(user)
else user
MemberAbility.new(user)
else
GuestAbility.new
end
end
View gist:cfa4a58e990930aaa921
# Parses YouTube URLs directly or from iframe code. Handles:
# * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI)
# * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI)
# * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">)
# * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...)
/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
$5 #=> the video ID
# test it on Rubular: http://rubular.com/r/eaJeSMkJvo
View gist:b0f9b3dfe8af0b37b37b
namespace :spec do
# largely lifted from http://www.pervasivecode.com/blog/2007/06/28/hacking-rakestats-to-get-gross-loc/
task :stats_setup do
require 'code_statistics'
class CodeStatistics
alias calculate_statistics_orig calculate_statistics
def calculate_statistics
@pairs.inject({}) do |stats, pair|
if 3 == pair.size
View emoji_image_replace.js
/**
*
* Here's a thing that will look through all the text nodes of a document, and
* upon encountering an emoji codepoint, will replace it with an image.
* For now, those images are pulled from GitHub, which isn't very nice, so I
* need to find a more suitable host.
*
* Much of this code was gleaned from staring at the minified GitHub JS.
*
* Copyright (c) 2013 Mark Wunsch. Licensed under the MIT License.
@dgilperez
dgilperez / gist:cd04989dd9d54f13a89e
Last active Aug 29, 2015
Sacando un trabajo a medias a una rama
View gist:cd04989dd9d54f13a89e

Sacando código a otra rama

"Ocultas" los cambios en la pila de cambios local

git stash

Creas una rama local (no en github)

View _flash_messages.html.erb
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>