Skip to content

Instantly share code, notes, and snippets.

@tony-landis
tony-landis / pdo-adodb-singleton-refactor.class.php
Created December 3, 2008 07:44
PHP PDO Singleton w/AdoDB backwards compatable
<?php
/**
* PDO SINGLETON CLASS, ADODB ENABLED
*
* @author Tony Landis
* @link http://www.tonylandis.com
* @license Use how you like it, just please don't remove or alter this PHPDoc
*/
class sdb
{
@ramn
ramn / XmlSchemaValidator.scala
Created December 2, 2010 11:02
XML Schema validator in Scala
import javax.xml.transform.stream.StreamSource
import javax.xml.validation.Schema
import javax.xml.validation.SchemaFactory
import javax.xml.validation.{Validator=>JValidator}
import org.xml.sax.SAXException
object Validator {
def main(args: Array[String]) {
require(args.size >= 2, "Params: xmlFile, xsdFile")
val result =
@dcolish
dcolish / migration.sh
Created June 8, 2011 23:10
Migrations done in bash
#!/bin/bash
RUN_SQL?="$(which psql) i3"
function _info(){
echo "At migration version: $(cat .migration-version)"
}
function _init() {
echo 0 > .migration-version
@loonies
loonies / 1_phpunit-api.md
Last active January 19, 2024 07:34
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
@zbskii
zbskii / yc.py
Created April 10, 2012 03:38
Y-Combinator
# -*- coding: utf-8 -*-
# a functional is a function that takes a function for its input
def fact(factorial):
def fn(n):
if n == 0: return 1
else:
return n * factorial(n - 1)
return fn
@michaelkirk
michaelkirk / show-remote-branch-info.sh
Created May 4, 2012 16:51
sort remote branches by age
#!/bin/sh
#
# Too many crusty old git branches? Run this to find likely candidates for deletion
# It lists all the remote branches and sorts them by age.
#
# Folks at pivotal shared this with me
#
#$ . show-remote-branch-info.sh
# 2012-05-04 09:42:29 -0700 4 minutes ago Ted & Bill \torigin/hey_Bill
@legumbre
legumbre / foo.md
Created June 29, 2012 00:14
resolving merge conflicts with magit-ediff

Use magit-ediff to resolve merge conflicts

Use magit-ediff or 'e' on an unmerged item to resolve merge conflicts with ediff. Magit will set up an ediff with three buffers A, B and C. A and B are the original (conflicting) files, and C is the conflicted merge.

Use 'n'/'p' to move to the next/previous conflict, use 'a'/'b' to choose which changes (those in a A or B) should be the ones to keep in the merged file.

You can always just switch to buffer C and edit what the merged version should look like.

@hpbuniat
hpbuniat / namespaceRefactor.php
Last active April 3, 2021 22:33
Super-simple script to convert a existing project to use namespaces
<?php
/**
* Super-simple script to convert a existing project to use namespaces
*
* @author Hans-Peter Buniat <hpbuniat@googlemail.com>
* @copyright 2012 Hans-Peter Buniat <hpbuniat@googlemail.com>
* @license http://opensource.org/licenses/BSD-3-Clause
*/
class namespaceRefactor {
@dbackeus
dbackeus / utf8_json_spec.rb
Created December 13, 2012 17:11
Spec to confirm monkey patch still necessary for: https://github.com/rails/rails/issues/3727
# Encoding: UTF-8
require 'spec_helper'
# Specs for initializers/patches.rb
describe ActiveSupport::JSON::Encoding do
it "should not break high bitrate utf-8 characters" do
hash = { string: "𐒑" }
json = ActiveSupport::JSON.encode(hash)