Skip to content

Instantly share code, notes, and snippets.

(function() {
// Temporary alert box killer - Derek Petersen
// Store the native alert/confirm functions for later
var _nativeAlert = window.alert;
var _nativeConfirm = window.confirm;
// Disregard all alert boxes
window.alert = function() {
return;
};
@tuxracer
tuxracer / cppv.sh
Created April 26, 2012 02:10
cp w/ progress bar and time estimate
#!/bin/bash
set -e
if [ $# -lt 2 ]; then
echo "cppv - copy files with progress bar and rate limiting ability"
echo "Usage: cppv source_file[s] destination_file_or_directory"
echo "No other non-positional command line arguments can be given"
echo "Always recurses like find"
echo "You can change copying speed limit on the fly with \"pv -R\" if you find out pv's PID"
script(id='BoardListTemplate', type='text/x-jQuery-tmpl')
| <p>${Title}</p>
| <ul id="${Id}" class="IterationBoardList">
| <li class="AddNewItem">Add new Item</li>
| {{tmpl(Items) "#BoardListItemTemplate"}}
| </ul>
@tuxracer
tuxracer / gist:2578547
Created May 2, 2012 17:37
Create multiple symlinks at once
for file in $(ls THEPATH); do ln -s NEWPATH$file .; done;
@tuxracer
tuxracer / striptags.js
Created June 17, 2012 19:47
Strip HTML tags
var StrippedString = OriginalString.replace(/(<([^>]+)>)/ig,"");
@tuxracer
tuxracer / readjson.js
Created July 10, 2012 23:05
Read JSON file in Win8
// read the file you want
function ReadAllDataFile(fileNameInLocalTree) {
var package = Windows.ApplicationModel.Package.current;
var installedLocation = package.installedLocation;
installedLocation.createFileAsync(fileNameInLocalTree, Windows.Storage.CreationCollisionOption.openIfExists).then(function (dataFile) {
dataFile.openAsync(Windows.Storage.FileAccessMode.read).then(function (stream) {
var size = stream.size;
if (size == 0) {
@tuxracer
tuxracer / gist:3751639
Created September 19, 2012 19:19
License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tuxracer
tuxracer / getProminent.coffee
Last active May 20, 2017 13:21
Find the prominent images on the page
getProminent = (limit = 25, minPixelCount = 50000) ->
imageEls = document.getElementsByTagName 'img'
matches = []
sortCollection = (collection, key) ->
collection.sort (a, b) ->
b[key] - a[key]
isInCollection = (collection, key, value) ->
collection.some (model) ->
@tuxracer
tuxracer / gnb.sh
Last active December 15, 2015 11:09
git new branch example: gnb another_branch Add to .bashrc
gnb() {
git checkout -b $1;
git branch --set-upstream-to remotes/origin/master;
git status;
git branch;
}
@tuxracer
tuxracer / gist:5987483
Last active December 19, 2015 16:59
restart google drive - workaround 'unable to sync' errors
for (( ; ; )) do open /Applications/Google\ Drive.app;sleep 30;killall 'Google Drive'; sleep 5; done