Skip to content

Instantly share code, notes, and snippets.

View tobsn's full-sized avatar

Tobsn tobsn

  • US/EU/SEA
View GitHub Profile
@tobsn
tobsn / cf.states.custom.html
Last active May 19, 2016 21:53
clickfunnel snippets
<div class="de elInputWrapper elSelectFormBox de-editable de-input-block elAlign_center elMargin0" id="tmp_select_input-97365" data-de-type="select-input" data-de-editing="false" data-title="select input form" data-ce="false" data-trigger="none" data-animate="fade" data-delay="500" type="state" style="margin-top: 10px; outline: none; cursor: pointer;">
<label class="elInputLabel">
<select name="state" class="elInput elSelectInput elInput100 elAlign_left elInputMid elInputStyl0 elInputBG1 elInputBR5 elInputI0 elInputIBlack elInputIRight required0 elInput-Select1 garlic-auto-save" data-type="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
function ismobile(){var a=navigator.userAgent||navigator.vendor||window.opera;return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|
@tobsn
tobsn / aws-sns-event-template-with-actual-ses-deliverynotification-sns-message Lambda function to process a Amazon SES Delivery Notification message from a SNS Topic into a DynamoDB Table
{
"Records": [
{
"EventSource":"aws:sns",
"EventVersion":"1.0",
"EventSubscriptionArn":"arn:aws:sns:us-west-2:xxxx:xxxx",
"Sns": {
"Type":"Notification",
"MessageId":"88B1B251-2E92-4FC3-BFAA-E3BBD0BAB10A",
"TopicArn":"arn:aws:sns:us-west-2:881222951025:survey-tool-ses-delivery",
@tobsn
tobsn / SecureSessionHandler.php
Last active March 18, 2016 14:51 — forked from eddmann/SecureSessionHandler.php
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
@tobsn
tobsn / encodedecode.js
Last active March 18, 2016 11:41
char code shifting encode decode
var z='',x='',s = 'now.something.com';
for( var i = 0; i < s.length; i++ ){
x += String.fromCharCode(s.charCodeAt(i)^6);
}
console.log(x)
for( var i = 0; i < x.length; i++ ){
z += String.fromCharCode(6^x.charCodeAt(i));
}
console.log(z)
@tobsn
tobsn / replace php
Created March 18, 2016 11:38
super simple token replace
$G['c2'] = 'bar';
$r='http://google.com/?s1=#c1#&s2=#c2#';
$r=preg_replace('/#([^#]+?)#/sUe','$G{"$1"}',$r);
http://google.com/?s1=&s2=bar
$var = 'zee,tv,Zee Khana Khazana,Mango,Kulfi,Khana Khazana (TV Program),Sanjeev Kapoor (Chef),Khoa (Dish),Condensed Milk (Invention),Mango Purée (Ingredient),Dessert (Type Of Dish)';
$var = array_filter(array_map(function($v){$v=mb_strtolower(trim($v));return (strlen($v)>2)?$v:0;},explode(',',preg_replace('/\s\([^)]+\)/','',$var))));
Array
(
[0] => zee
[2] => zee khana khazana
[3] => mango
[4] => kulfi
[5] => khana khazana
@tobsn
tobsn / getlang.php
Created March 18, 2016 11:31
get http accept language short
function lang($l=['en'],$u){
return $l[array_keys($l,substr(explode(',',$u?:$_ENV['HTTP_ACCEPT_LANGUAGE'])[0],0,2))[0]]?:$l[0];
}
@tobsn
tobsn / hbf.min.php
Last active March 9, 2016 15:09
new version of https://gist.github.com/tobsn/22108617b36d6c9adb79 - merges query parameters into url
<?php
function hbf($u,$p,$f=!1){is_string($u)&&parse_str(@parse_url($u)['query']?:'',$k);is_array($p)||parse_str(
$p,$p);is_array($f)&&count($f)>0&&$p=array_filter($p,function($k)use($f){return in_array($k,$f);},ARRAY_FILTER_USE_KEY);
return explode('?',$u)[0].'?'.http_build_query(array_replace_recursive($k,$p));}
@tobsn
tobsn / hbu.php
Last active March 4, 2016 13:57
merge query string $_SERVER['QUERY_STRING'] into existing URL / query string
<?php
function hbu($u,$p){$q='query';$t='path';$p=[$q=>$p];is_array($u)||$u=parse_url($u);isset($u[$q])&&is_string($u[$q])||
$u[$q]=!1;isset($p[$q])&&is_string($p[$q])||$p[$q]=!1;if($p[$q]){if($u[$q]){parse_str($u[$q],$k);parse_str($p[$q],$i);
$u[$q]=http_build_query(array_replace_recursive($k,$i));}else $u[$q]=$p[$q];}isset($u[$t])&&substr($u[$t],0,1)!=='/'&&
$u[$t]='/'.$u[$t];$s='';isset($u['scheme'])&&$s.=$u['scheme'].'://';isset($u['host'])&&$s.=$u['host'];isset($u['port']
)&&$s.=':'.$u['port'];$s.=!empty($u[$t])?$u[$t]:'/';isset($u[$q])&&$s.='?'.$u[$q];return preg_replace('/(\?$)/','',$s);}
echo hbu( 'https://test.com/?x=12&z=foo', 'x=asdjd&f=34&z=' );
?>