Skip to content

Instantly share code, notes, and snippets.

@michaeldelorenzo
michaeldelorenzo / hsp.js
Created October 25, 2012 14:02
Hootsuite SDK JS fix for HTTPS
// downloaded from https://d2l6uygi1pgnys.cloudfront.net/jsapi/0-5/hsp.js?
// to fix a bug in Hootsuite SDK
var hsp = {};
(function () {
hsp = new function () {
var g = "https:" == document.location.protocol ? "https://" : "http://",
q = g + "d2l6uygi1pgnys.cloudfront.net/jsapi/0-5/assets",
r = g + "d2l6uygi1pgnys.cloudfront.net/jsapi/json2.js",
j = "https:" == document.location.protocol ? "https://" : "http://",
l = !0,
@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]);
@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
: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 / 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"
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
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,
@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
{
"_id": 12345,
"_type": "tweet",
"text": "welcome to #MongoDBWorld!",
"twitter_user": "mongodb"
}