Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# svnrepo/hooks/post-commit
cd /var/www/example.com
svn up
<?php
if ($handle = opendir('.')) {
echo '<ul>';
while (false !== ($file = readdir($handle))) {
if ($file[0] == '.') {
continue; // skip dot-files
}
if (is_dir($file)) {
$file .= '/';
<?php
if ($handle = opendir('.')) {
echo '<ul>';
while (false !== ($file = readdir($handle))) {
if ($file[0] == '.') {
continue; // skip dot-files
}
if (is_dir($file)) {
$file .= '/';
<?php
$bad_files = array('file1', 'file2', 'file3');
if ($handle = opendir('.')) {
echo '<ul>';
while (false !== ($file = readdir($handle))) {
if ($file[0] == '.') {
continue; // skip dot-files
}
@kastaneda
kastaneda / JsonResponse.php
Created April 27, 2011 10:05
A small suggestion
<?php
namespace Symfony\Component\HttpFoundation;
class JsonResponse extends Response
{
public function __construct($data)
{
parent::__construct(
json_encode($data),
#!/usr/bin/env php
<?php
// http://twitter.com/#!/Xopus/status/88187651705946112
// "We ask new devs to write program to find equation with 3, 6, 9, 12, 15
// (all) and +, -, *, / (any) which equals 381. Many struggle. Can you do it?"
// Let's rock! This one is for classic PHP4 style. Very dumb.
@kastaneda
kastaneda / gist:1476031
Created December 14, 2011 10:22
Test test test
<?php
$data = array(
array(
'id' => 101,
'name' => 'Foo',
),
array(
'id' => 102,
'name' => 'Bar',
@kastaneda
kastaneda / gist:1925978
Created February 27, 2012 18:24
Learning Python
#!/usr/bin/python
# this works as I expect, result is [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
q = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
# this works strange, result is [[7, 8, 9], [7, 8, 9], [7, 8, 9]]
q = [[0]*3]*3
z = 0
for y in range(3):
@kastaneda
kastaneda / gist:2411383
Created April 18, 2012 06:01
JS and semicolon - my opinion
// This code is OK
if (navigator.geolocation) {
deploySelfDrivingCar()
notifyFlyingMonkeys()
} else {
asknicelyforlocation()
}
// Not OK
foo(); bar();
@kastaneda
kastaneda / gist:3528766
Created August 30, 2012 13:41
my fluxbox and multimedia keys
% grep Audio ~/.fluxbox/keys
XF86AudioPlay :ExecCommand mpc toggle
XF86AudioPrev :ExecCommand mpc prev
XF86AudioNext :ExecCommand mpc next
XF86AudioStop :ExecCommand mpc stop
XF86AudioLowerVolume :ExecCommand aumix -v-10
XF86AudioRaiseVolume :ExecCommand aumix -v+10
XF86AudioMute :ExecCommand aumix -v 0