Skip to content

Instantly share code, notes, and snippets.

@tomsseisums
tomsseisums / gist:1505803
Created December 21, 2011 12:11
PHP and headers and... aye, it sucks
<?php
// a function to check if a specific header exists, current way due to headers_list() returning numeric array
function header_exists($lookup)
{
$headers = headers_list();
foreach($headers as $header){
if(0 !== stripos($header, $lookup)){ // or other lookup...
continue;
}else{
return true;
@tomsseisums
tomsseisums / gist:1673294
Created January 24, 2012 23:00
sevensounds player, needs optimization, probably old
$(function(){
var seek = false, volume = false, _playing = false, muted = false, _playlist, _songID = 0, oldposition = 0, largeplaylist;
function getRandomNumber(range){
return Math.floor(Math.random() * range);
}
function getRandomChar(){
var chars = "0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
return chars.substr( getRandomNumber(62), 1 );
@tomsseisums
tomsseisums / breakexp.php
Created August 13, 2012 00:08
HTML breaks, new line, carriage return regex
<?php
// matches <br>, <br/>, <br />, \n, \r
$pattern = '/(<br(\/|\s\/)?>|\n|\r)/';
@tomsseisums
tomsseisums / dump.php
Last active December 14, 2015 23:49
`dump()` is a debugging helper that mimics the output of `var_dump()` wrapped in `<pre/>` and then returned as a string. I made the function because I hate that var_dump() echoes directly and may consume the overall page style. This gives me the good old var_dump() which I can then pass directly into my logging mechanisms, or even pass to backed…
<?php
/**
* Returns a string containing var_dump() for each argument wrapped in a <pre>
*
* @author joltmode
* @return string
*/
function dump()
{
@tomsseisums
tomsseisums / array_push_after.php
Last active December 15, 2015 11:29
array_push_after
<?php
function array_push_after(&$array, $key, array $value)
{
$keys = array_keys($array);
$_keyPosition = array_search($key, $keys);
// TODO: Fix indexed value
$array = array_slice($array, 0, $_keyPosition + 1, true) + $value + array_slice($array, $_keyPosition, count($array) - $_keyPosition, true);
@tomsseisums
tomsseisums / draft.php
Last active December 16, 2015 05:48
Smart helpers for PHP
<?php
function is(&$variable, $filters)
{
$filters = explode('|', $filters);
$state = false;
foreach ($filters as $filter)
{
<?php
/**
* CIDR.php
*
* Utility Functions for IPv4 ip addresses.
*
* @author Jonavon Wilcox <[email protected]>
* @version Sat Jun 6 21:26:48 EDT 2009
* @copyright Copyright (c) 2009 Jonavon Wilcox
*/
@tomsseisums
tomsseisums / jsbin.upUFIbO.css
Last active July 22, 2016 16:04
A very dirty extension for Highcharts, that makes the leftmost and rightmost points, areas extend to plot areas edges.
#chart
{
width: 90%;
margin: 0 auto;
min-height: 350px;
}
@tomsseisums
tomsseisums / global.php
Created April 28, 2014 06:56
Laravel separator (app/start)
<?php
/** @append */
/*
|--------------------------------------------------------------------------
| Require project specific logic separation files
|--------------------------------------------------------------------------
|
| Next we will load files that help us to separate some logic, therefore
| keep the application as readable and consistent as possible.
|
@tomsseisums
tomsseisums / createsblmlink.py
Last active August 29, 2015 14:05
Sublime Text 3 compatible protocol handler for Windows (dirty edit)