Skip to content

Instantly share code, notes, and snippets.

Avatar

Tobsn tobsn

  • San Francisco/Diego, USA; Munich, Germany;
View GitHub Profile
View strip_markdown.php
<?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;
View gist:cb182cbe03d4cbeabb572c1391ef1ec4
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))
View Tags > Facebook Checkout.html
<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 Dec 10, 2010
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
View jquery.loader.js
(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 {
View gist:0761b9d657fa7757df982c7a62b51fb9
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
@tobsn
tobsn / LocalSettings.php
Created Mar 27, 2018 — forked from amrav/LocalSettings.php
Slack integration using Redis
View LocalSettings.php
# Slack integration
require_once "$IP/extensions/Slack/Slack.php";
# Slack extension configuration options
$wgSlackWebhookURL = "https://hooks.slack.com/services/some-webhook-url"
$wgSlackUserName = "batman";
$wgSlackChannel = "#recent-changes";
$wgSlackIconURL = "http://i.picresize.com/images/2015/09/20/tdpsU.jpg";
$wgSlackLinkUsers = true;
@tobsn
tobsn / .ebextensions production.config
Last active Mar 1, 2018
elastic beanstalk RDS wordpress with S3 media upload
View .ebextensions production.config
option_settings:
- namespace: aws:autoscaling:asg
option_name: MinSize
value: 2
- namespace: aws:autoscaling:asg
option_name: MaxSize
value: 6
- namespace: aws:elasticbeanstalk:application:environment
option_name: env
value: production
@tobsn
tobsn / localstorage.polyfillcheck.js
Last active Dec 12, 2017
localStorage polyfill with check first
View localstorage.polyfillcheck.js
(function(){
if(
!(function(t){
try {
window.localStorage.setItem(t,t);
window.localStorage.removeItem(t);
return true;
} catch(e) {
return false;
}
@tobsn
tobsn / info.txt
Last active Nov 24, 2017 — forked from rpgreen/master.vm
API Gateway "Send Everything" Mapping Template
View info.txt
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 / gist:796fcbea5b3aa0827ae20a62ec277986
Created Nov 23, 2017
Set subdomain Allow Origin on Apache and return 200 OK on OPTONS preflight request for ajax use without jsonp
View gist:796fcbea5b3aa0827ae20a62ec277986
SetEnvIf Origin ^(https?://.+\.yourdomain\.com(?::\d{1,5})?)$ CORS_ALLOW_ORIGIN=$1
Header always set Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
Header merge Vary "Origin"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
You can’t perform that action at this time.