Skip to content

Instantly share code, notes, and snippets.

View intel352's full-sized avatar

Jonathan Langevin intel352

  • Elon, NC
  • 04:01 (UTC -04:00)
View GitHub Profile
@intel352
intel352 / ampscript-cheetsheet.txt
Created June 7, 2017 02:00
Dave's AMPScript cheat sheet
// Dave's AMPScript cheat sheet.
// AMPScript is ExactTarget (SFDC Marketing Cloud)'s server side scripting language.
// It's a bit of a pig, plus the docs are numerous and the examples aren't contextual.
// This assumes you don't need hand holding, and just need to get your head around it.
// It's also my reference for the snippets I use all the time (I'm a formatting stickler).
// These examples come from microsites I've written - adapt 'em for use elsewhere.
// Multi line AMPScript %%[contained within delimiters]%% gets interpreted on the server.
// Single line AMPScript %%=can use this style syntax=%% if you want.
// Assign URL key/value pairs to @someVar, eg: et.company.com/form?country=AU&bu=MP
set @countryCode = queryParameter("country")
@intel352
intel352 / PostalCode.ds
Created August 22, 2014 15:11
Postal code validation
importPackage( dw.system );
importScript("utils/Underscore.ds");
var _ = getUnderscore();
function PostalCode() {}
(function(){
// Sourced from http://unicode.org/cldr/trac/browser/tags/release-24/common/supplemental/postalCodeData.xml
PostalCode.patterns = [
@intel352
intel352 / rebrew.sh
Last active August 29, 2015 14:03
Brew (homebrew) reinstall packages - useful after upgrading OS versions or migrating
#!/bin/bash
brew list > ~/brewlist
brew remove --force $(brew list)
brew install $(cat ~/brewlist)
@pravj
pravj / treegen.sh
Last active September 8, 2021 09:43
bash script to generate tree structure of a directory
#!/usr/bin/env bash
# bash script to generate tree structure of a directory
# Pravendra Singh (@hackpravj)
pwd=$(pwd)
find $pwd -print | sed -e "s;$pwd;\.;g;s;[^/]*\/;|__;g;s;__|; |;g"
@madoke
madoke / bash-webtail
Last active December 15, 2015 17:49
Tails a remote file via HTTP. Polls the HTTP Headers, via curl, and when "Content-Length" has changed, fetches the remaining difference
#!/bin/bash
POLLING_INTERVAL=2
CONTENT_LENGTH=0
while true
do
FETCH_CONTENT_LENGTH=`curl -s -r 0-0 -I $1 | egrep -i "Content-Range" | cut -d/ -f2 | awk -F"\r" '{print $1}'`
TMP_CONTENT_LENGTH=$FETCH_CONTENT_LENGTH
@NoobsArePeople2
NoobsArePeople2 / gist:5121597
Last active November 10, 2023 14:33
Configure media keys on a non-Apple keyboard to control Spotify via AppleScript and USB Overdrive on OSX.

Requirements

  1. USB Overdrive
  2. A non-Apple keyboard with media keys (or keys you want to make "media" keys). For reference, I'm using a Microsoft Sidewinder X4

Set Up

  1. Plug in your keyboard and install USB Overdrive.
  2. Open USB Overdrive. Click into the Settings tab.
  3. Click the dropdown and select "Any Keyboard, Any Application"
@intel352
intel352 / Capfile
Last active December 13, 2015 20:28
A Capistrano capfile with support for running commands locally. Additionally has a variety of helper commands for various tasks.
require 'open3'
$CR = "\033[0m" # color reset
$red = "\033[1m\033[31m"
$green = "\033[1m\033[32m"
$yellow = "\033[1m\033[33m"
$blue = "\033[1m\033[34m"
ssh_options[:forward_agent] = true
ssh_options[:paranoid] = false
@intel352
intel352 / WidgetFactory.php
Last active September 20, 2019 02:18
Yii => custom WidgetFactory, adds onBeforeCreateWidget, onAfterCreateWidget events. An example of how the custom class can be used has been provided as well, in the process solving a typical Yii issue, regarding how to set the default pagesize for widgets that use dataproviders (due to dataproviders initializing pagination, by which widget pager…
<?php
// components/WidgetFactory.php
/**
* Custom WidgetFactory class
* Provides two new events:
* - onBeforeCreateWidget
* - onAfterCreateWidget
*
@RobThree
RobThree / SoapClientTimeout.class.php
Created April 25, 2012 14:55
PHP SoapClient with timeout
<?php
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout
//Usage: Exactly as PHP's SoapClient class, except that 3 new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
class SoapClientTimeout extends SoapClient
{
private $timeout = 0;
private $connecttimeout = 0;
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"