Skip to content

Instantly share code, notes, and snippets.

View ain's full-sized avatar

Ain Tohvri ain

View GitHub Profile
@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 / uniqid.js
Created May 23, 2013 19:57
JavaScript alternative of PHP uniqid()
function uniqid (prefix, more_entropy) {
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + revised by: Kankrelune (http://www.webfaktory.info/)
// % note 1: Uses an internal counter (in php_js global) to avoid collision
// * example 1: uniqid();
// * returns 1: 'a30285b160c14'
// * example 2: uniqid('foo');
// * returns 2: 'fooa30285b1cd361'
// * example 3: uniqid('bar', true);
// * returns 3: 'bara20285b23dfd1.31879087'
@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 / free-memory.rb
Last active December 19, 2020 22:20 — forked from vigo/free-memory.rb
#!/usr/bin/env ruby
# encoding: utf-8
# By Uğur Özyılmazel, @vigobronx | @ugurozyilmazel
# http://vigodome.com | http://ugur.ozyilmazel.com | http://github.com/vigo
def get_paged_memory_usage(match_string, paging=4096)
mvar = 3
if match_string.split(/[^\w]/).length > 1
mvar = 4
@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)