Skip to content

Instantly share code, notes, and snippets.

View davidpp's full-sized avatar

David Paquet Pitts davidpp

View GitHub Profile
class Question < ActiveRecord::Base
belongs_to :category
belongs_to :pack
# TODO Doit etre possible de le limiter
# a une categorie passe en parametre et au question appartenant a un set
# en particulier
named_scope :random, :limit => 1,:order => 'RAND()'
end
packages:
yum:
newrelic-php5: []
rpm:
newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm
commands:
configure_new_relic:
command: newrelic-install install
env:
NR_INSTALL_SILENT: true
@davidpp
davidpp / fbme.js
Created April 2, 2013 16:57
Get current user name + ID with Facebook JS SDK
FB.api('/me', function(response) {
alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id);
var img_link = "http://graph.facebook.com/"+response.id+"/picture"
});
@davidpp
davidpp / fb_picture.js
Created April 4, 2013 01:32
Get FB picture
FB.login(function(response) {
if (response.authResponse) {
var access_token = FB.getAuthResponse()['accessToken'];
FB.api("/me", {fields: "id,name,picture.type(large)"}, function(response) {
console.log(response.id, response.name, response.picture);
});
}
}, {
scope: 'publish_stream,email'
});
def symbolize_keys(hash)
hash.inject({}){|new_hash, key_value|
key, value = key_value
value = symbolize_keys(value) if value.is_a?(Hash)
new_hash[key.to_sym] = value
new_hash
}
end
rails g model Asset source type attachable:belongs_to{polymorphic}

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@davidpp
davidpp / rootscopeListener.js
Created July 25, 2013 20:23
Log to console each transition change (useful to intercept a state before it change)
angular.module('SkylineApp').run(function($rootScope) {
return $rootScope.$on("$stateChangeStart", function(evt, toState, toParams, fromState, fromParams) {
return console.log("Transitioning from: " + fromState.name + " to: " + toState.name);
});
});
@davidpp
davidpp / view_content_loaded.js
Created July 30, 2013 13:41
Log when the content of a view has been loaded
$scope.$on "$viewContentLoaded", ->
console.log "View Content Loaded"
@davidpp
davidpp / restangular_post.js
Created July 31, 2013 11:58
Example of a restangular POST not returning a response object
Restangular.all('devices').post(device_to_activate).then(function(response) {
$log.info("Device activated", response);
alert("Error " + response.status + ", " + response.data);
}, function(response) {
alert("Error " + response.status + ", " + response.data.message);
});