Skip to content

Instantly share code, notes, and snippets.

Tobsn tobsn

  • San Francisco/Diego, USA; Munich, Germany;
Block or report user

Report or block tobsn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tobsn
tobsn / gist:11258483
Created Apr 24, 2014
php false true null horse;
View gist:11258483
<?php
echo true ? 'car' : true ? 'horse' : 'feet'; #horse
echo true ? 'car' : false ? 'horse' : 'feet'; #horse
echo false ? 'car' : false ? 'horse' : 'feet'; #feet
echo false ? 'car' : true ? 'horse' : 'feet'; #horse
echo false ? 'car' : null ? 'horse' : 'feet'; #feet
echo true ? 'car' : null ? 'horse' : 'feet'; #horse
echo null ? 'car' : null ? 'horse' : 'feet'; #feet
echo null ? 'car' : false ? 'horse' : 'feet'; #feet
echo null ? 'car' : true ? 'horse' : 'feet'; #horse
@tobsn
tobsn / gist:11258555
Created Apr 24, 2014
get random geo location points within a radius
View gist:11258555
<?php
function getLocation( $y0, $x0, $rad ) {
$rad = $rad / 111195.0;
echo '$rad: '.$rad."\n";
$u = (float)mt_rand() / (float)getrandmax();
$v = (float)mt_rand() / (float)getrandmax();
echo 'rand: '.$v.' '.$u."\n";
@tobsn
tobsn / curl.php
Last active Aug 29, 2015
curl request via CLI
View curl.php
<?php
function clearCookies($cookiejar = 'cookies') {
@unlink($cookiejar);
}
function POSTURL(
$url,
$referer = "",
$data = array(),
@tobsn
tobsn / base
Created May 28, 2014
nginx - sub_filter replace head with the current folder as base href for sub project folder structure
View base
location / {
if ($uri ~* ^/([^.\?/]+)) {
set $foldername "$1";
}
sub_filter "<head>" "<head><base href=\"${scheme}://${host}/${foldername}/\">";
}
@tobsn
tobsn / index.html
Created Jun 6, 2014
employee rating
View index.html
<html>
<head>
<meta charset="utf-8">
<title>Who Am I?</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
@tobsn
tobsn / script.js
Last active Aug 29, 2015
replace query variables within static html with javascript and jQuery as selector
View script.js
// http://jsfiddle.net/96q4m/17/ - old
// simulating GET variables
if(window.location.search.indexOf('test') < 0) window.location.search = window.location.search+'?test=123&img=https%3A%2F%2Fdrupal.org%2Ffiles%2Ftest-all-the-things.jpg';
// remove everything above this line - stop removing after
// closure compiled:
$(function(){function a(a){return decodeURIComponent(a.replace(b," "))}for(var b=/\+/g,c=/([^&=]+)=?([^&]*)/g,d=window.location.search.substring(1);y=c.exec(d);)$("#tpl-"+a(y[1])).length&&("IMG"!==$("#tpl-"+a(y[1]))[0].tagName?$("#tpl-"+a(y[1])).html(a(y[2])):$("#tpl-"+a(y[1])).attr("src",a(y[2])))});
@tobsn
tobsn / FormBuild.php
Last active Aug 29, 2015
Laravel 4.2 UrlGenerator and FormBuilder fixes for relative URLs for scheme-less URLs
View FormBuild.php
<?php namespace Common;
use \Illuminate\Html\FormBuilder;
class FormBuild extends FormBuilder {
protected function getRouteAction( $options ) {
if( is_array( $options ) ) {
return $this->url->route( $options[0], array_slice( $options, 1 ), 0 );
}
return $this->url->route( $options, [], 0 );
@tobsn
tobsn / .htaccess
Created Apr 10, 2015
slim smarty gump yamop (mongodb)
View .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
View states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
View gist:9df39ecca19f30c55689

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
You can’t perform that action at this time.