Skip to content

Instantly share code, notes, and snippets.

@sn00011
sn00011 / xhprof for mac
Created August 19, 2011 08:12 — forked from nebiros/xhprof for mac
xhprof for mac
# brew install re2c graphviz
# cd /tmp
# wget http://pecl.php.net/get/xhprof-0.9.2.tgz
# tar -xvzf xhprof-0.9.2.tgz
# cd xhprof-0.9.2/extension
# phpize
# MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
# export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
# ./configure --with-php-config=/usr/local/zend/bin/php-config
# make
@sn00011
sn00011 / markdown_absolute_url.patch
Created October 19, 2011 08:45
for issue #37504
diff --git markdown.php markdown.php
index ed79197..0cde939 100644
--- markdown.php
+++ markdown.php
@@ -761,6 +761,17 @@ class Markdown_Parser {
$url = $this->encodeAttribute($url);
+ // For some links like [xxx](/node/xxx), turn them into absolute ones
+ // so when they're contained in feeds, the W3C feed validator won't
@sn00011
sn00011 / example.jst
Created April 4, 2012 16:03 — forked from taxilian/example.jst
example of a select statement in an underscore template
<select name="formitem_school">
<% if(schools && schools.length > 0) {
<option value="select_schools">Select School</option>
<% schools.each(function(t) { %>
<option value="<%= t.id %>" <% if(curSchool == t.id){ print('selected'); } %>><%= t.get("name") %></option>
<% });
} else { %>
<option value"schools_none">No Schools</option>
<% }
</select>
@sn00011
sn00011 / backbone-persistable-collection.js
Created April 16, 2012 06:31 — forked from efeminella/backbone-persistable-collection.js
A Persistable Backbone Collection Implementation
/*!
* Copyright (c) 2012 Eric Feminella, http://code.ericfeminella.com/license/LICENSE.txt
*/
( function( _, Backbone )
{
// convenience reference to the Backbone.Collection constructor
var _initialize = Backbone.Collection.prototype.initialize;
/*
* The Backbone.PersistableCollection provides a simply abstraction which
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},
@sn00011
sn00011 / gist:3186899
Created July 27, 2012 08:52
Manually install drush 5.4 on OSX Lion
# Install Drush 5.4
> cd /opt
> sudo git clone --recursive --branch master http://git.drupal.org/project/drush.git
> cd drush
> sudo git checkout tags/7.x-5.4
> sudo ln -s /opt/drush/drush /usr/bin/drush
> sudo drush
> drush
> drush --version
drush version 5.4
@sn00011
sn00011 / gist:3203930
Created July 30, 2012 03:16
Reset Drupal 6/7 admin password
# For Drupal 6:
## This sql will reset admin password to 'admin'
> UPDATE users SET pass = MD5('admin') WHERE uid=1;
# For Drupal 7:
## This drush command will reset admin password to 'admin'
> drush upwd admin --password=admin
@sn00011
sn00011 / gist:3205339
Created July 30, 2012 06:31
Drush notes
## Download a module and enable it, take 'migrate' module as an example:
> drush dl migrate --destination=sites/all/modules/contrib
> drush en migrate -y
@sn00011
sn00011 / gist:3292016
Created August 8, 2012 04:26
[Javascript] Round a number to a specified decimal place
/**
* Round a number to a specified decimal place.
* @var num The number to be rounded
* @var digits The digit behind the decimal point to be rounded to
*/
function roundNumber(num, digits) {
num = parserFloat(num);
var multiple = Math.pow(10, digits);
return Math.round(num * multiple) / multiple;
@sn00011
sn00011 / gist:3347350
Created August 14, 2012 08:03
Solution for iOS simulator on Mac OS X 10.7 (Lion) can't be found issue
#Suppose the Xcode (v4.3x) is installed at the default location, then:
## 1. Use this command to directly open it:
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
## 2. Create an alias for later quick access:
echo "alias ios-simulater='open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'" >> ~/.bash_profile; source ~/.bash_profile