This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set-up a connection between the client and the server | |
var socket = io.connect(); | |
// let's assume that the client page, once rendered, knows what room it wants to join | |
var room = "abc123"; | |
socket.on('connect', function() { | |
// Connected, let's sign-up for to receive messages for this room | |
socket.emit('room', room); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Conditionally loads scripts. | |
var loadScripts = function(params) { | |
// Iterate over each source. | |
var eachSource = function(callback) { | |
if (typeof params.scripts == 'string') { | |
callback(params.scripts); | |
} | |
else { | |
for (var i=0; i < params.scripts.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- using the truncate filter --> | |
{% for post in site.posts limit:10 %} | |
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2> | |
<span class="post-date">{{ post.date | date: "%B %d, %Y" }}</span> | |
{% if post.content.size > 2000 %} | |
{{ post.content | truncatewords: 300 }} <!-- bad! content gives you rendered html and you will truncate in the middle of a node --> | |
<a href="{{ post.url }}">read more</a> | |
{% else %} | |
{{ post.content }} | |
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = 2 | |
core = 7.x | |
projects[drupal][type] = core | |
projects[drupal][version] = "7.12" | |
; Make system directories configurable to allow tests in profiles/[name]/modules to be run. | |
; http://drupal.org/node/911354 | |
projects[drupal][patch][911354] = http://drupal.org/files/issues/911354.43.patch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Place as .git/hooks/pre-commit | |
#Reject any commit that would have PHP syntaz errors on .php , .module, .install, .inc files | |
#### | |
# Reject any commit that would add a line with tabs. | |
# | |
# You can enable this as a repo policy with | |
# | |
# git config hooks.allowtabs true | |
#### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$('*').each(function() { | |
var e = $.data(this, 'events'); | |
if(!e) return; | |
for(var p in e) { | |
$(this).bind(p, {event:p, name: this.tagName + '.' + this.className}, function(event) { | |
console.log(event.data.name + " triggered " + event.data.event); | |
}); | |
}; | |
}); |
Note: the original location of this article is on my blog, however, it is posted here too for better readability.
In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$somefunction = function($foo, $bar){ | |
//do something | |
} | |
$myfunction = ($somefunction($foo, $bar), $variable){ | |
//do stuff | |
//call somefunction | |
//do some more stuff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Quick Setup | |
sudo apt-get install byobu | |
sudo apt-get install htop | |
sudo apt-get install openvpn | |
# sudo apt-get install bitlbee | |
sudo apt-get install irssi | |
# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys | |