Skip to content

Instantly share code, notes, and snippets.

View intel352's full-sized avatar

Jonathan Langevin intel352

  • Elon, NC
  • 14:12 (UTC -04:00)
View GitHub Profile
@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)
@intel352
intel352 / webtail
Created April 9, 2014 17:24
Webtail - continously tail a long-running remote webpage/file
#!/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
#!/usr/bin/env zsh
branch=`git rev-parse --abbrev-ref HEAD`
git show-branch | ack '\*' | ack -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
# How it works:
# 1| Display a textual history of all commits.
# 2| Ancestors of the current commit are indicated
# by a star. Filter out everything else.
@intel352
intel352 / boot.js
Last active August 29, 2015 13:56
(WIP) Jasmine 2.0 boot.js for CommonJS
// boot code for jasmine, require paths were customized for my env
// on my commonjs server, added boot.js as the main file of mod_jasmine, which is wrapping my copy of jasmine-core node package
var jasmineRequire = require('mod_jasmine/jasmine-core/lib/jasmine-core/jasmine.js');
var jasmine = jasmineRequire.core(jasmineRequire);
var consoleFns = require('mod_jasmine/jasmine-core/lib/console/console.js');
extend(jasmineRequire, consoleFns);
jasmineRequire.console(jasmineRequire, jasmine);
var env = jasmine.getEnv();
@intel352
intel352 / ab.dart
Last active December 31, 2015 23:19 — forked from okaq/godart.txt
import 'dart:html' show Console;
void main() {
var console = new Console();
console.log("ok ab dart!");
}
// to compile use:
// dart2js -oab.js ab.dart
@intel352
intel352 / PostalCode.js
Last active December 23, 2015 21:49
The following script was written as a server-side helper for validating international postal codes, for Demandware ecommerce websites. It depends on UnderscoreJS. With minor changes, this code is reusable for client-side validation as well.
/**
* PostalCode.ds
*/
importPackage( dw.system );
importScript("utils/Underscore.ds");
var _ = getUnderscore();
function PostalCode() {}
@intel352
intel352 / gist:6443489
Created September 4, 2013 22:06
Webdav get last modified (using curl)
curl -i -X PROPFIND --user 'user:pass' https://someserver.com/webdav/Sites/Logs/ --upload-file - -H "Depth: 1" <<end
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">
<a:prop><a:resourcetype/></a:prop>
<a:prop><a:getlastmodified/></a:prop>
</a:propfind>
end
@intel352
intel352 / apache.sh
Last active December 22, 2015 14:44
Handy one-liners
# List name vhosts on current server (excludes aliases)
sudo apache2ctl -S 2>&1 | grep -v 'Syntax OK' | grep 'namevhost' | tr -s ' ' | cut -d' ' -f5
# List all vhosts and aliases on current server
THECONFS="`apache2ctl -S 2>&1 | grep -oE '\/[^\:]+' | grep -vE '^\s*#'`"; for ACONF in ${THECONFS}; do cat ${ACONF} | tr '\t' ' ' | grep -E '^ *(ServerName|ServerAlias)' | sed -r 's/^( |ServerName|ServerAlias)+//g' | tr ' ' '\n'; done | sort -fu
@intel352
intel352 / php5_4_downgrade_5_3.sh
Last active December 18, 2015 08:59
Downgrade PHP from 5.4 to 5.3 on Ubuntu 13.04 (Raring)
#!/bin/bash
#
# Original for 5.3 by Ruben Barkow (rubo77) http://www.entikey.z11.de/
# release 1 PHP5.4 to 5.3 by Emil Terziev ( foxy ) Bulgaria
# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here's how to do the Apt magic to get PHP packages from the precise repositories:
echo "Am I root? "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
@intel352
intel352 / division with a remainder.sql
Last active December 15, 2015 09:18
Divided We Stand: The SQL of Relational Division -- excerpted SQL statements from article (https://www.simple-talk.com/sql/t-sql-programming/divided-we-stand-the-sql-of-relational-division/), so that I can refer back to the SQL with syntax highlighting ;-) Queries have been edited only for the purpose of removing html entities that exist in orig…
SELECT DISTINCT pilot_name
FROM PilotSkills AS PS1
WHERE NOT EXISTS
(SELECT *
FROM Hangar
WHERE NOT EXISTS
(SELECT *
FROM PilotSkills AS PS2
WHERE (PS1.pilot_name = PS2.pilot_name)
AND (PS2.plane_name = Hangar.plane_name)));