Skip to content

Instantly share code, notes, and snippets.

View ain's full-sized avatar

Ain Tohvri ain

View GitHub Profile
@ain
ain / SafeDoctrineMigrationBase
Created November 7, 2012 22:34
Symfony 1.4 Doctrine migration base class for checking against existance of the table/field
<?php
abstract class SafeDoctrineMigrationBase extends Doctrine_Migration_Base
{
public function hasField($table, $field)
{
$conn = Doctrine_Manager::connection();
$result = $conn->execute("SHOW COLUMNS FROM $table LIKE '$field'");
$fields = $result->fetchAll();
return !empty($fields);
@ain
ain / config.inc.php
Created July 14, 2012 16:50
phpMyAdmin configuration for local development sandbox on Mac OS X
<?php
/**
* phpMyAdmin configuration
*
* For local development sandbox on Mac OS X
* with Mac-bundled PHP and Apache instances
*
* phpMyAdmin 3.5.2
*/
@ain
ain / PPPlane.as
Created February 23, 2012 20:13
AS3 visible bounds of DisplayObject
package {
import flash.display.Sprite;
import flash.display.Graphics;
import flash.geom.Rectangle;
import flash.geom.PerspectiveProjection;
import flash.display.BitmapData;
public class PPPlane extends Sprite {
@ain
ain / str_replace.as
Created February 23, 2012 19:55
String.replace() method for ActionScript2
String.prototype.replace = function(searchStr, replaceStr):String {
return this.split(searchStr).join(replaceStr);
};
@ain
ain / log.php
Created February 23, 2012 19:47
tail functionality in PHP
<?php
// full path to text file
define("TEXT_FILE", "/home/www/default-error.log");
// number of lines to read from the end of file
define("LINES_COUNT", 10);
function read_file($file, $lines) {
//global $fsize;
@ain
ain / NORMSINV.mxml
Created March 21, 2011 13:48
Returns the inverse of the standard normal cumulative distribution.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function inverseCumulativeNormalDistribution(v:Number):Number{
//refer http://home.online.no/~pjacklam/notes/invnorm/ for how this works