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
# ruby 1.8.7 | |
# Hash implicitly creates an array for empty nodes | |
a = Hash.new([]) | |
a[:key] << 2 # => [2] | |
p a # => {} nil | |
p a[:key] # => [2] | |
# Explicitly add an array for all nodes before creating | |
b = Hash.new |
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/bash | |
# requires bash 3 | |
URL=http://piratepad.net/ep/admin/auth | |
EXPECTED_CODE=200 | |
TEST_FILE=/tmp/pad-watcher | |
TIMEOUT=300 # 5 minutes | |
RESTART_COMMAND='/opt/piratepad/bin/restart.sh &' | |
LAST_UPDATED_JS='/opt/piratepad/etherpad/data/50x-error-handler/last-updated.js' |
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
CREATE TABLE IF NOT EXISTS `node_convert` ( | |
`nid` int(11) NOT NULL, | |
`created_at` int(11) NOT NULL, | |
`updated_at` int(11) NOT NULL, | |
`lang` varchar(5) character set utf8 NOT NULL, | |
`title` varchar(255) character set utf8 NOT NULL, | |
`url` varchar(255) character set utf8 NOT NULL, | |
`body` longtext character set utf8 NOT NULL, | |
`teaser` text character set utf8 NOT NULL, | |
`new_nid` int(11) NOT NULL, |
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
module ImageHelper | |
def image(name, alt, link = '') | |
tmp = File.join(Dir.getwd, 'content') | |
possible_paths = [ | |
File.join(tmp, @page.directory, 'images', name), | |
File.join(tmp, 'images', name) | |
] | |
file = possible_paths.find {|path| File.exists? path } | |
file |
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/bash | |
# Author: Björn Andersson <[email protected]> | |
# | |
# Piratpartiet has two servers running Varnish and keeping them both in sync | |
# started to get cumbersome. A quick search on Google gave nothing so I wrote | |
# this script to ease the maintenance of activating new configuration files on | |
# a Varnish farm. | |
# | |
# How the script works: | |
# - The directory holding the varnish configuration will be synced to all |
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
--- orig/worksheet.rb 2011-04-18 10:26:50.000000000 +0200 | |
+++ patched/worksheet.rb 2011-04-18 10:27:23.000000000 +0200 | |
@@ -89,7 +89,7 @@ | |
def need_number? cell | |
if cell.is_a?(Numeric) && cell.abs > 0x1fffffff | |
true | |
- elsif cell.is_a?(Float) | |
+ elsif cell.is_a?(Float) and not cell.nan? | |
higher = cell * 100 | |
if higher == higher.to_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
If you have "too much" free space the installation stops because the resulting | |
SPACE_AVAILABLE is not just numbers, and thus can't be used by expr. | |
This patch removes all characters that is not numeric, so in my case the | |
free space changes from 210974368K to 210974368 and I can install the receiver. | |
Running on Ubuntu 11.04 with the tools installed for that version. |
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
*.rb diff=ruby |
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
class Migration(DataMigration): | |
def forwards(self, orm): | |
if settings.DEBUG: | |
app, _ = FacebookApplication.objects.get_or_create( | |
id=123456, | |
secret='sssh', | |
default_scope='user_likes,email' | |
) | |
# Yet another test page | |
page, _ = FacebookPage.objects.get_or_create(id=123456) |
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/bash | |
TOKEN=phonegap-build-access-token | |
APP_ID=phonegap-build-app-id | |
PROGRESS_FILE=/tmp/$TOKEN-progress | |
echo "" > $PROGRESS_FILE | |
tail -f $PROGRESS_FILE & | |
curl -X PUT -F file=@$1 https://build.phonegap.com/api/v1/apps/$APP_ID?auth_token=$TOKEN -o /tmp/$TOKEN-progress --progress-bar | |
kill $! |
OlderNewer