Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@xeoncross
xeoncross / algo.php
Created June 8, 2011 22:54
Backtracking, prementions, and 8-Queens
<?php
// http://paulbutler.org/archives/n-queens-in-a-tweet/
$n=$argv[1];$s=range(1,$n);while($i<$n*10000){shuffle($s);$a=s($s,range(1,$n));$b=s(s($s,range($n,1)),2*$n);$c=array_merge($a,$b);if(count(array_unique($c))==2*$n){die(join(',',$s));}$i++;}function s($a,$b){if(!is_array($b))$b=array_fill(0,count($a),$b);foreach($a as $i=>$k)$r[$i]=$k+$b[$i];return $r;}
@xeoncross
xeoncross / .bashrc
Created July 11, 2011 17:06
bashrc functions and aliases
# showa: to remind yourself of an alias (given some part of it)
showa () { /usr/bin/grep -i -a1 $@ ~/.aliases.bash | grep -v '^\s*$' ; }
# sourcea: to source this file (to make changes active after editing)
alias sourcea='source ~/.aliases.bash'
# Search current directory (and subdirectories) for files with "word"
function rg(){ grep -rl --exclude=\*/.svn/\* --exclude=\*/.git/\* --exclude=\*.swp $1 * }
# find_larger: find files larger than a certain size (in bytes)
@xeoncross
xeoncross / SoapClientTimeout.php
Created July 20, 2011 16:21
Custom SOAP client request
// http://www.darqbyte.com/2009/10/21/timing-out-php-soap-calls/
// Uses cURL instead of default SOAP request method to allow timeouts of problem requests
class SoapClientTimeout extends SoapClient
{
private $timeout;
public function __setTimeout($timeout)
{
if (!is_int($timeout) && !is_null($timeout))
@xeoncross
xeoncross / xdebug.ini
Created July 23, 2011 00:31
xDebug.ini settings for ubuntu
[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
; General
@xeoncross
xeoncross / autoexec.cfg
Created July 26, 2011 01:43
Reduced Violence Mode - Team Fortress 2
// Disable *almost* all blood and gore in Team Fortress 2
// Save the following in your autoexec.cfg file to apply
cl_phys_props_enable "0"
cl_phys_props_max "0"
r_propsmaxdist "1"
props_break_max_pieces "0"
cl_playerspraydisable "1"
violence_agibs "0"
violence_hgibs "0"
<?php
require_once('/home/alix/_.php');
ph();
function Purify($html, $tags = null)
{
$html = preg_replace('~<(script|style)[^>]*>.*?(?:</\1>|\z)~is', '', $html);
$html = strip_tags($html, '<' . implode('><', array_keys((array) $tags)) . '>');
@xeoncross
xeoncross / hacks.css
Created August 10, 2011 18:28
CSS hacks
/*
Comprehensive List of Browser-Specific CSS Hacks
http://paulirish.com/2009/browser-specific-css-hacks/
*/
/***** Selector Hacks ******/
/* IE6 and below */
* html #uno { color: red }
@xeoncross
xeoncross / save.changes.js
Created August 23, 2011 19:36
Alert user about unsaved form changes!
var isDirty = false;
$(document).ready(function()
{
// Alert user about unsaved changes!
$(':input').change(function(){
if(!isDirty) isDirty = true;
});
window.onbeforeunload = function(){
@xeoncross
xeoncross / run.php
Created August 30, 2011 01:45 — forked from greut/run.php
A web server in pure PHP (non-concurrent and concurrent)
#!/usr/bin/env php
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Hello World!</title>
@xeoncross
xeoncross / slider.html
Created August 31, 2011 03:19 — forked from jsok/slider.html
Simple jquery slider
<!DOCTYPE html>
<html lang="en-GB">
<head>
<title>iTunes slider</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
</head>