Skip to content

Instantly share code, notes, and snippets.

@yvmarques
yvmarques / fabfile.py
Created December 23, 2011 10:58 — forked from onyxfish/fabfile.py
Chicago Tribune News Applications fabric deployment script
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
module ActiveRecord::ConnectionAdapters
class Mysql2Adapter
alias_method :execute_without_retry, :execute
def execute(*args)
execute_without_retry(*args)
rescue Mysql2::Error => e
if e.message =~ /server has gone away/i
warn "Server timed out, retrying"
reconnect!
@yvmarques
yvmarques / gist:2894294
Created June 8, 2012 07:50
Tweet stats from your server
#!/usr/bin/env python
import tweepy
import commands
import time
# Fill these informations from you Twitter App Admin
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
Use requirements.txt to install all requirements.
pip install -r requirements.txt
Then start simple the small server with the fellowing command
python detect_language.py
To try the web service you can use curl
<?php
_refresh_and_assign_country_to_node($nid, $country, $region) {
if (empty($nid) || empty($country) || empty($region)) {
return FALSE;
}
// Some pseudo-constants for config
$VOCABULARY_COUNTRIES = 0;
$items[variable_get('file_public_path', conf_path() . '/files') . '/pdf/%'] = array(
'page callback' => '...',
'page arguments' => array(1),
'access callback' => TRUE,
);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sticky footer &middot; Twitter Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
<?php
# Bench functional programming
$start = microtime(true);
$fact = function($x, $y = 1) use (&$fact) {
if ($x == 0) {
return $y;
}
return $fact($x - 1, $y * $x);
};
$fact(30000) . "\n";
{
"close_windows_when_empty": false,
"default_line_ending": "unix",
"draw_white_spaces": "all",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"fold_buttons": false,
"font_size": 14.0,
"highlight_line": true,
"highlight_modified_tabs": true,