Skip to content

Instantly share code, notes, and snippets.

View ain's full-sized avatar

Ain Tohvri ain

View GitHub Profile
@ain
ain / poster.php
Created August 23, 2013 15:34
PHP dummy parsing the REQUEST.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<pre><?php print_r($_REQUEST); ?></pre>
</body>
</html>
@ain
ain / netbeans_ignore.regex
Last active December 18, 2015 11:18
Regex for Netbeans' Ignored Files Pattern to make Travis CI dotfile visible
^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|~$|^\.(?!htaccess|jshintrc|DS_Store|gitattributes|gitignore$|.*\.yml$).*$
@ain
ain / mysql_csv_dump
Created May 16, 2013 14:10
MySQL select query dump to CSV
#!/bin/bash
usage="Usage: mysql_csv_dump database_name username"
err[1]="Invalid command"
# Check for database name argument
if [ -z "$1" ]
then
echo ${err[1]}
@ain
ain / mysql_collation_to_utf8
Last active December 17, 2015 02:59
Convert MySQL collation of all fields in database to UTF-8 at once
#!/bin/bash
usage="Usage: mysql_collation_to_utf8 database_name username"
err[1]="Invalid command"
# Check for database name argument
if [ -z "$1" ]
then
echo ${err[1]}
@ain
ain / mysqldumpgz
Last active December 16, 2015 02:28
mysqldump a database to gzip
#!/bin/bash
usage="Usage: mysqldumpgz database_name username"
err[1]="Invalid command"
# Check for database name argument
if [ -z "$1" ]
then
echo ${err[1]}
@ain
ain / git-info
Created February 6, 2013 16:00
Shell script that displays repository information for Git.
#!/bin/bash
# author: Duane Johnson
# email: duane.johnson@gmail.com
# date: 2008 Jun 12
# license: MIT
#
# Based on discussion at http://kerneltrap.org/mailarchive/git/2007/11/12/406496
pushd . >/dev/null
<?php
/**
* Displays the current migration version of the database
*
* @version 1.0
* @author Ain Tohvri <at@interactive-pioneers.de>
* @see sfBaseTask
*/
class currentMigrationVersionTask extends sfBaseTask
@ain
ain / MyBaseForm.class.php
Created December 9, 2012 15:15
Symfony 1.4 base form class with a method to output all errors of a Form in one array
<?php
class MyBaseForm extends sfFormSymfony
{
public function getErrors()
{
$errors = array();
foreach ($this as $form_field)
{
@ain
ain / sfWidgetFormSelectRadioSingleable.class.php
Created November 28, 2012 22:13
sfWidgetFormSelectRadioSingleable Symfony widget lets you render just one option at a time. Extends sfWidgetFormSelectRadio.
<?php
class sfWidgetFormSelectRadioSingleable extends sfWidgetFormSelectRadio
{
public function formatChoices($name, $value, $choices, $attributes)
{
$onlyChoice = !empty($attributes['only_choice']) ? $attributes['only_choice'] : false;
unset($attributes['only_choice']);
if ($onlyChoice)
@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);