This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convert_to(n, base) { | |
if (base < 2 || base > 16) { | |
throw new Error("Invalid base '" + base + "'. Base must be >= 2 or <= 16"); | |
} | |
if (n === 0) { | |
return 0; | |
} | |
var length = Math.floor(Math.log10(n) / Math.log10(base)) + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
import collections | |
import re | |
from prettytable import PrettyTable | |
from datetime import timedelta, date | |
from dateutil.parser import parse | |
from subprocess import PIPE, STDOUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pip_file = "requirements.txt" | |
try { | |
pip freeze > $pip_file | |
# PowerShell creates UTF16 LE with Windows line endings so we must convert | |
# for pip to consume | |
# http://stackoverflow.com/questions/8852682/convert-file-from-windows-to-unix-through-powershell-or-batch | |
Get-ChildItem $pip_file | ForEach-Object { | |
$contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function deferredResolve(response, milliseconds = 250) { | |
milliseconds = _.isInteger(milliseconds) ? milliseconds : 0; | |
return new Ember.RSVP.Promise((resolve, reject) => { | |
Ember.run.later(() => { | |
resolve(response); | |
}, milliseconds); | |
}); | |
} | |
export function deferredReject(response, milliseconds = 250) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
buffers=($(tmux list-buffer | cut -f1 -d ":")) | |
for i in "${buffers[@]}"; do | |
tmux delete-buffer -b "$i" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bug https://packagecontrol.io/browse/popular | |
var parent = $("ul.packages"); | |
var toggle_st3 = $('<label><input type="checkbox" style="-webkit-appearance:checkbox !important"/> Hide ST3</label>') | |
.click(function() { | |
var checked = $(this).find("input").is(":checked"); | |
var versions = $(".versions").parent(); | |
if (checked) { | |
versions.hide(); | |
} else { | |
versions.show(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bats | |
load 'test_helper/bats-support/load' | |
load 'test_helper/bats-assert/load' | |
print_horizontal_rule () { | |
let width="$(tput cols)" | |
# echo -n '─' | hexdump -C | |
printf -v dash "%b" "\xe2\x94\x80" && printf "%*s\n" "$width" | sed "s/ /${dash}/g" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" Convert values between RGB hex codes and xterm-256 color codes. | |
Nice long listing of all 256 colors and their codes. Useful for | |
developing console color themes, or even script output schemes. | |
Resources: | |
* http://en.wikipedia.org/wiki/8-bit_color | |
* http://en.wikipedia.org/wiki/ANSI_escape_code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for deleting large directories (e.g. node_modules) | |
function purge($target_dir) { | |
if (Test-Path -Path $target_dir) { | |
$uuid = [guid]::NewGuid().toString() | |
$empty_dir = "$env:temp$uuid.tmp" | |
New-Item -ItemType directory -Path $empty_dir | Out-Null | |
# delete using robocopy /NFL ... (options to suppress stdout) | |
robocopy $empty_dir $target_dir /MIR /MT | Out-Null | |
Remove-Item $empty_dir | Out-Null |