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 / create_countrycodes.php
Created August 1, 2012 23:18
laravel migration for country codes table
<?php
class Create_Country_Codes_Table {
/**
* Make changes to the database.
*
* @return void
*/
public function up()
@tobsn
tobsn / info.txt
Last active November 6, 2023 21:41 — forked from rpgreen/master.vm
API Gateway "Send Everything" Mapping Template
https://rpgreen.wordpress.com/2016/02/23/a-mapping-template-to-send-everything-to-your-backend-integration/
location/cookie headers:
https://stackoverflow.com/questions/35595672/aws-api-gateway-use-302-redirect-and-set-cookie-header
https://blog.hiramsoftware.com/blog/day-one-aws-api-gateway/
@tobsn
tobsn / composer.json
Created September 13, 2023 02:45
digitalocean php serverless function hardcoded local simulation & composer base config incl mongodb
{
"config": {
"platform": {
"php": "8.0.28",
"ext-mongodb": "1.9.0RC1"
}
},
"require": {
"mongodb/mongodb": "^1.4",
},
@tobsn
tobsn / strip_markdown.php
Created February 12, 2019 13:20
Strips Markdown from Text - PHP port of https://github.com/stiang/remove-markdown
<?php
function strip_markdown( $md = '', $options = [] ) {
// char to insert instead of stripped list leaders (default: '')
$options['listUnicodeChar'] = isset( $options['listUnicodeChar'] ) ? $options['listUnicodeChar'] : false;
// strip list leaders (default: true)
$options['stripListLeaders'] = isset( $options['stripListLeaders'] ) ? $options['stripListLeaders'] : true;
// support GitHub-Flavored Markdown (default: true)
$options['gfm'] = isset( $options['gfm'] ) ? $options['gfm'] : true;
@tobsn
tobsn / url.query.js
Created September 14, 2012 03:29
node.js parse array form from query string into array like php does
url.query = function( url ) {
var parsed = this.parse( url, true, false ),
query = Object.keys( parsed.query ),
result = {};
if( query.length > 0 ) {
query.forEach(function(key){
if( key.match( /([^\[]+)\[([^\]]+)\]/g ) ) {
key.replace( /([^\[]+)\[([^\]]+)\]/g, function( $0, $1, $2 ) {
result[$1] = result[$1] || {};
result[$1][$2] = parsed.query[key];
@tobsn
tobsn / pastebin.class.php
Created May 29, 2011 09:04
pastebin scraper
<?php
class pastebin {
private $folder = './pastebins';
public $pastes = array();
function __construct( $folder = false ) {
if( $folder ) {
$this->folder = $folder;
}
$this->folder = rtrim( $this->folder, '/' );
@tobsn
tobsn / gist:cb182cbe03d4cbeabb572c1391ef1ec4
Created March 22, 2019 00:24
osx battery low apple script
set Cap to (do shell script "ioreg -w0 -l | grep ExternalChargeCapable")
tell Cap to set {wallPower} to {last word of paragraph 1}
set CurrentVolume to output volume of (get volume settings)
if wallPower = "Yes" then
return 0
else
set Cap to (do shell script "ioreg -wO -l | grep Capacity")
tell Cap to set {Available, Max} to {last word of paragraph 2, last word of paragraph 1}
set Pct to round (100 * (Max / Available))
@tobsn
tobsn / Tags > Facebook Checkout.html
Created October 24, 2018 23:01
GTM Facebook Pixel Loader
<script>
(function(){
var FBDATA = {
sku: JSON.parse('{{CHECKOUT SKUS}}'), // cookie variable with array of SKUs (products on checkout page)
ids: {{A - EDIT THIS - FACEBOOK PIXEL ID LIST}}, // Variable with Pixel IDs
host: '{{Page Hostname}}'
};
for( var k in FBDATA.ids ) {
@tobsn
tobsn / jquery.loader.js
Created December 10, 2010 19:50
there are many problems when you act as third party that offers a javascript file and you want to use jquery - this solved all of my problems. the little function checks if jquery is already embedded, includes it and waits until its loaded if its missing
(function(j,q,u,e,r,y,R,o,x){try{o=jQuery;if(o&&(!R||(R&&o.fn.jquery==R))){x=true}}catch(er){}if(!x||(R&&o.fn.jquery!=R)){(q=j.createElement(q)).type='text/javascript';if(r){q.async=true}q.src='//ajax.googleapis.com/ajax/libs/jquery/'+(R||1)+'/jquery.min.js';u=j.getElementsByTagName(u)[0];q.onload=q.onreadystatechange=(function(){if(!e&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){e=true;x=jQuery;jQuery.noConflict(true)(function(){y(x)});q.onload=q.onreadystatechange=null;u.removeChild(q)}});u.appendChild(q)}else{y(o)}})(document,'script','head',false,false,(function($){$(function(){
/* code goes here */
console.log($.fn.jquery);
})}));
// readable:
(function (j, q, u, e, r, y, R, o, x ) {
// IE8 undefined crash fix
try {
var poptin, poptin_position, jQ224, all_poptins, test, query_string = new Object,
env = "app",
api_link = "https://display.popt.in",
cdn_server = "https://cdn.popt.in",
poptin_il_url = "https://www.poptin.co.il/",
poptin_com_url = "https://www.poptin.com/",
html_poptin_x_button = '<button type="button" id="closeXButton" onclick="closePoptinOnXclick(this);" class="close-x-button" style="text-align: right;display:none; margin-top: -2px;-webkit-appearance: none;cursor: pointer;background: 0 0;border: 0;float: right;padding:0pxfont-size: 20px;line-height: 0.5;color: #000;text-shadow: #fff 0px 0px 10px;filter: alpha(opacity=20);text-transform: none;overflow: visible;margin: 0;font-size:53px;line-height: 31px;z-index: 9999;position: relative;">&times;</button>',
html_poptin_skip_button = '<button type="button" id="closeXButton" onclick="closePoptinOnXclick(this);" class="close-x-button" style="text-align: right;display:none; margin-top: -2px;-webkit-appearance: none;padding: 5px;cursor