Skip to content

Instantly share code, notes, and snippets.

View fordnox's full-sized avatar
🍕
Eating pizza

Andrius Putna fordnox

🍕
Eating pizza
View GitHub Profile
@fordnox
fordnox / Facebook.php
Created July 29, 2011 08:25
Very simple Facebook graph executor
<?php
namespace Ai;
class Facebook
{
private $token;
public function __construct($token)
{
$this->token = $token;
@fordnox
fordnox / autoloader.php
Created August 9, 2011 19:52
Simplest possible autoloader for PHP classes. Can be used and for namespaces
<?php
spl_autoload_register('autoloader');
function autoloader($className)
{
if(strpos($className, '\\') !== false) {
$className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
}
if(strpos($className, '_') !== false) {
@fordnox
fordnox / resetall.sh
Created August 17, 2011 12:26
Reset all doctrine 2 entries, regenerate db, dumps sql file, insert fixtures
#!/bin/bash
php doctrine.php orm:generate-entities ~/www/project/data/tmp/
php doctrine.php orm:schema-tool:create --dump-sql > ~/www/project/data/sql/structure.sql
php doctrine.php orm:schema-tool:drop --force
php doctrine.php orm:schema-tool:create
echo 'Inserting database entries'
php fixtures.php
@fordnox
fordnox / Country.php
Created August 22, 2011 09:13
Zend_Form_Element_Country
<?php
class Zend_Form_Element_Country extends Zend_Form_Element_Select
{
public function init()
{
$_countries = array(
"GB" => "United Kingdom",
"US" => "United States",
"AF" => "Afghanistan",
"AL" => "Albania",
@fordnox
fordnox / 960.12.gs.min
Created August 23, 2011 20:02
12 columns reset, text and 960 gs in one style tag
<style type="text/css">
a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,meter,nav,object,ol,output,p,pre,progress,q,rp,rt,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video,xmp{border:0;margin:0;padding:0;font-size:100%}html,body{height:100%}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}b,strong{font-weight:bold}img{color:transparent;font-size:0;vertical-align:middle;-ms-interpolation-mode:bicubic}li{display:list-item}table{border-collapse:collapse;border-spacing:0}th,td,caption{font-weight:normal;vertical-align:top;text-align:left}q{quotes:none}q:before,q:after{content:'';content:none}sub,sup,small{font-size:75%}sub,sup{line-height:0;position
@fordnox
fordnox / Twig syntax simplified replace
Created September 8, 2011 09:23
Replace variables {{ group.key }} in $content to values from $rep[group][key] array. Requires PHP 5.3
/* replace variables {{ group.key }} in $content to values from $rep[group][key] array */
$parsed = preg_replace_callback('/{{.([a-z]+\.[a-z]+).}}/i',
function($v) use ($rep) {
$match = $v[0];
$match = str_replace(' ', '', $match);
$match = str_replace('{', '', $match);
$match = str_replace('}', '', $match);
list($group, $key) = explode('.', $match);
return isset($rep[$group][$key]) ? $rep[$group][$key] : $v[0] ;
@fordnox
fordnox / jekins_server.sh
Created September 25, 2011 10:22
Install Jenkins server on Ubuntu
#!/bin/sh
sudo apt-get update
sudo apt-get install openjdk-6-jre
sudo apt-get install openjdk-6-jdk
sudo wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
sudo apt-get install ant
@fordnox
fordnox / build.xml
Created September 29, 2011 15:02
Ant target to push source to staging server
<target name="stage" depends="build-source">
<property name="remote.user" value="username" />
<property name="remote.address" value="hostname" />
<property name="remote.path" value="~/v_${version}" />
<property name="remote.shared_path" value="~/v_shared" />
<echo message="Deploying project ${ant.project.name} source ${source} to server ${remote.address} ${remote.path}" />
<exec dir="." executable="rsync" failonerror="true">
<arg line="-avPe ssh ${source}/ ${remote.user}@${remote.address}:${remote.path}" />
@fordnox
fordnox / Uploader.php
Created April 14, 2012 14:19
Uploader message executor file
<?php
/*
* This file is part of Queue Manager.
*
* (c) 2011 SparkleBit <info@sparklebit.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@fordnox
fordnox / svmserver.sh
Created July 27, 2012 12:31
Restart svn server deamon
#!/bin/sh
killall -9 svnserve
svnserve -d -r /var/repositories/