Skip to content

Instantly share code, notes, and snippets.

da or danish
nl or dutch
en or english
fi or finnish
fr or french
de or german
hu or hungarian
it or italian
nb or norwegian
pt or portuguese
@michaeldelorenzo
michaeldelorenzo / pre-commit
Created September 24, 2014 21:25
Put this in .git/hooks/pre-commit then run chmod a+x .git/hooks/pre-commit
#!/bin/bash
# Pre commit hook that prevents FORBIDDEN code from being commited.
# Add unwanted code to the FORBIDDEN array as necessary
FILES_PATTERN='\.(rb|js|coffee)(\..+)?$'
FORBIDDEN=( debugger ruby-debug )
for i in "${FORBIDDEN[@]}"
do
{
"_id": 12345,
"_type": "tweet",
"text": "welcome to #MongoDBWorld!",
"twitter_user": "mongodb"
}
@michaeldelorenzo
michaeldelorenzo / recursive_key_removal.rb
Created May 15, 2014 16:42
Recursively removes key-value pairs from a Hash using lambda.
remove_id_attr = lambda do |obj|
if obj.is_a?(Hash)
obj.keys.each do |_k|
if _k.to_s.eql?('_id')
obj.delete(_k)
elsif obj[_k].is_a?(Hash)
remove_id_attr.call(obj[_k])
elsif obj[_k].is_a?(Array)
obj[_k].each{|o| remove_id_attr.call(o)}
end
CRM.module("DashboardApp.Show", function(Show, CRM, Backbone, Marionette, $, _){
Show.Dashboard = Marionette.Layout.extend({
className: "container-fluid",
template: "backbone/crm/templates/dashboard/show",
regions: {
contacts: "#contacts",
filter: "#filter"
},
origHeight: null,
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
sudo dpkg -i elasticsearch-0.90.7.deb
@michaeldelorenzo
michaeldelorenzo / assets.js.erb
Last active December 15, 2015 19:19 — forked from patrickberkeley/assets.js.erb
JavaScript asset helper. Forked from https://gist.github.com/patrickberkeley/3879730, cleaned up the assignment to "images" in the App.assets object to not have an extra comma and to be a single line.
App.assets = {
// Returns an object containing all of asset pipeline's image paths.
//
// Sample:
//
// {
// avatars/missing_avatar.png: "/assets/avatars/missing_avatar.png"
// chosen-sprite.png: "/assets/chosen-sprite.png"
// circle_green.png: "/assets/circle_green.png"
// circle_orange.png: "/assets/circle_orange.png"
:javascript
window._popup_closed = function(){
location.href = "#{@my_instance_var_uri_string}"; // replace the opening window document with this one
window._popup_closed = null; // remove on close callback
};
var connect_path = "/auth/#{@platform name}"; // the oauth destination - there is a route for these
var new window_specs = ""; // your window opening parameters
// open the new window
@michaeldelorenzo
michaeldelorenzo / install-rbenv.sh
Created March 29, 2013 04:27
Used this script to install rbenv on a fresh Ubuntu 12.10 server.
sudo apt-get install zlib1g-dev openssl libopenssl-ruby1.9.1 libssl-dev libruby1.9.1 libreadline-dev git-core make
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
mkdir -p ~/.rbenv/plugins
cd ~/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git
rbenv install 1.9.3-p194
rbenv rehash
@michaeldelorenzo
michaeldelorenzo / facebook-picture-url.js
Last active December 14, 2015 07:19
Regex to update picture URL to 'normal' sized.
var large_photo_url = options.picture_url.replace(/_[a-z]\.[a-z]{3}$/i,
"_n"+options.picture_url.match(/\.[a-z]{3}$/i)[0]);