Skip to content

Instantly share code, notes, and snippets.

Avatar

Gilles Doge gido

View GitHub Profile
@gido
gido / diskusage.js
Created Jan 15, 2015
Quick&Dirty script to get total disk usages of each account by crawling the Alwaysdata web administration
View diskusage.js
/**
* run:
* $ casperjs diskusage.js --user=myaccount --password=mypassword
*
* This script can lookup for env variables:
* ALWAYSDATA_USER
* ALWAYSDATA_PASSWORD
*/
var casper = require('casper').create({
//verbose: true,
@gido
gido / bookmarlet-harvest.js
Created May 13, 2015
Bookmarlet to display/preview the total hours in Harvest Estimate
View bookmarlet-harvest.js
var totalH = 0;
var hours = document.getElementsByClassName('item-qty desktop');
Array.prototype.forEach.call(hours, function(el) { totalH += parseFloat(el.innerHTML); });
var totalRow = document.querySelector('tr.total');
var totalLabelCol = document.querySelector('tr.total td.label');
var totalAmoundCol = document.querySelector('tr.total td.total');
var totalHoursCol = document.createElement('td');
totalHoursCol.innerHTML = totalH;
totalRow.insertBefore(totalHoursCol, totalAmoundCol);
@gido
gido / stream-example.js
Created Jun 1, 2015
Playing with Stream and Nodejs
View stream-example.js
var request = require("request");
var zlib = require("zlib");
var csv = require("csv-streamify");
var Handlebars = require("handlebars");
var es = require("event-stream");
var tmpl = Handlebars.compile("<li><a href="{{URL}}">{{Name}}</a> ({{City}})</li>");
// HTTP GET Request
request("http://nodestreams.com/input/people.csv.gz")
View gist:103148
# routing.yml
language:
class: sfPropelRouteCollection
options:
model: Language
module: language
prefix_path: language
column: id
with_wildcard_routes: true
requirememts:
View gist:103158
# routing.yml
language:
class: sfPropelRouteCollection
options:
model: Language
module: language
prefix_path: language
column: id
with_wildcard_routes: true
requirememts: '\w+'
View gist:103118
language GET /language.:sf_format
language_new GET /language/new.:sf_format
language_create POST /language.:sf_format
language_edit GET /language/:id/edit.:sf_format
language_update PUT /language/:id.:sf_format
language_delete DELETE /language/:id.:sf_format
language_show GET /language/:id.:sf_format
language_object GET /language/:id/:action.:sf_format
language_collection POST /language/:action/action.:sf_format
View gist:103123
>> app Route "language_edit" for application "backend"
Name language_edit
Pattern /language/:id/edit.:sf_format
Class sfPropelRoute
Defaults action: 'edit'
module: 'language'
sf_format: 'html'
Requirements id: '\\d+'
sf_format: '[^/\\.]+'
sf_method: 'get'
View gist:115416
class MyClass
{
static $choicesMaxChildren = array(
1 => '1',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
6 => 'Whaaa! more than 5 ?',
);
View gist:246306
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enableAllPluginsExcept('sfDoctrinePlugin');
// if(ENV == "dev"):
$this->setWebDir('/a/path');
// else:
$this->setWebDir('a/different/path');
@gido
gido / blackify hex color
Created Dec 13, 2010
Example of a simple script to manipulate hexadecimal color
View blackify hex color
<?php
$input = "#A2D73A";
if(!preg_match('/#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/', $input, $matches)){
die(sprintf("Error: '%s' is not a valid hexadecimal color!", $input));
}
$bgColor1 = $input;
$bgColor2 = blackify($input, 60);