Skip to content

Instantly share code, notes, and snippets.

View wdalmut's full-sized avatar
💭
Fantasy Land

Walter Dal Mut wdalmut

💭
Fantasy Land
View GitHub Profile
@wdalmut
wdalmut / couchdb-bulk-geoname-db.php
Created January 6, 2012 16:53
couchdb bulk operation using geonames database
<?php
$filename = dirname(__FILE__) . '/allCountries.txt';
$file = new SplFileObject($filename ,'r');
$map = array(
0 => 'id',
1 => 'name',
2 => 'asciiName',
3 => 'alternateNames',
4 => 'latitude',
@wdalmut
wdalmut / git-remove-forever.sh
Created January 14, 2012 09:46
Remove files or folders from git history forever!
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@wdalmut
wdalmut / Date.php
Created January 19, 2012 16:13
Zend Date next day by name - not great but it works...
<?php
class Application_Date
extends Zend_Date
{
public static function nextDay($dayWanted)
{
$weekdays = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
if (!in_array($dayWanted, $weekdays)) {
throw new Zend_Exception("'{$dayWanted}' not found in array of possible weekdays");
}
@wdalmut
wdalmut / tree.sh
Created April 14, 2012 10:51
Linux Tree Display (ls tree) - Alias
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
@wdalmut
wdalmut / ec2metadata.py
Created April 18, 2012 10:24
Alon Swartz EC2 Metadata display
#!/usr/bin/python
#
# Query and display EC2 metadata related to the AMI instance
# Copyright (c) 2009 Canonical Ltd. (Canonical Contributor Agreement 2.5)
#
# Author: Alon Swartz <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@wdalmut
wdalmut / ec2-run-user-data.sh
Created April 19, 2012 09:29
Run EC2 user metadata (Alestic)
#!/bin/bash
#
# ec2-run-user-data - Run instance user-data if it looks like a script.
#
# Only retrieves and runs the user-data script once per instance. If
# you want the user-data script to run again (e.g., on the next boot)
# then add this command in the user-data script:
# rm -f /var/ec2/ec2-run-user-data.*
#
# History:
@wdalmut
wdalmut / default.conf
Created April 20, 2012 10:31
Nginx configuration with proxy pass...
server {
listen 80;
server_name localhost;
error_page 404 = @fallback;
error_page 400 = @fallback;
proxy_intercept_errors on;
location / {
@wdalmut
wdalmut / autocomplete-snippet.php
Created April 20, 2012 10:59
Example for upcloo-autocomplete test run
<?php
$jsonp = false;
if ($_GET["callback"]) {
$jsonp = $_GET["callback"];
}
$memcached = new Memcached();
$memcached->addServer("127.0.0.1", 11211);
@wdalmut
wdalmut / .gitignore
Created June 20, 2012 14:05
Simple View... Based on idea that I found on the web...
.project
.buildpath
.settings
@wdalmut
wdalmut / .htaccess
Created June 21, 2012 18:28
.htaccess useful rules
# Rewrite non www urls to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]