Skip to content

Instantly share code, notes, and snippets.

View chaimleib's full-sized avatar

Chaim Halbert chaimleib

View GitHub Profile
@chaimleib
chaimleib / virtualenv.sh
Created June 26, 2014 20:31
Setup for virtualenv
function setup() {
pip install virtualenv
pushdir $1 # replace $1 with where the environment dir should be
virtualenv tincan
source tincan/bin/activate
popd
}
function remove() {
deactivate
@chaimleib
chaimleib / nameDownloaded.sh
Created October 22, 2014 04:55
Gets the actual name of a remote file, then downloads to an identically-named file
#!/bin/bash
function getUriFilename() {
header="$(curl -sI "$1" | tr -d '\r')"
filename="$(echo "$header" | grep -o -E 'filename=.*$')"
if [[ -n "$filename" ]]; then
echo "${filename#filename=}"
return
fi
@chaimleib
chaimleib / abspath.sh
Created October 22, 2014 04:59
Converts path to an absolute path. If no path given, gives current directory.
!/bin/bash
## Syntax:
## abspath [path]
# Converts path to an absolute path. If no path given, gives current directory.
function abspath() {
[[ -n "$1" ]] && pushd "$1" >/dev/null
pwd
[[ -n "$1" ]] && popd >/dev/null
}
-- "input" is a list of files.
-- In Automator, I used the "Ask for Finder items" block, and checked "Allow multiple selection".
property extension_list : {"doc"}
on run {input, parameters}
set newline to "
"
display dialog "Converting " & (count of input) & " files …"
repeat with i from 1 to the count of input
\paper {
%% tiny page size
#(set-paper-size "a9" 'landscape)
}
\header{
piece = \markup { \fontsize #-1 \bold "My vocal range with a cold" }
%% tagline copied and modified from Lilypond.app/Contents/Resources/share/lilypond/current/ly/titling-init.py
tagline = \markup {
@chaimleib
chaimleib / natural_sort.coffee
Last active January 26, 2019 00:08
sort strings containing numbers naturally
cmp = (a, b) ->
if a > b then return 1
if a < b then return -1
return 0
numeralizeRgx = /(_+)|([0-9]+)|([^0-9_]+)/g
naturalCmp = (a, b) ->
# Thanks, @georg on stackoverflow.com!
# http://stackoverflow.com/questions/15478954/sort-array-elements-string-with-numbers-natural-sort
ax = []
@chaimleib
chaimleib / rspec.sh
Last active December 1, 2015 18:01
Various rspec commands
function capybara_rspec() {
USING_CAPYBARA=true bundle exec rspec \
--color \
-r turnip/rspec \
-r turnip/capybara \
--order defined \
"$@"
#--format documentation \
}
function tests_ending_with() {
@chaimleib
chaimleib / debug.sh
Last active February 25, 2022 03:29
print variable name and its value in bash
#!/bin/bash
function debug() { echo "$1 => \"$(eval echo \$$1)\"" >&2; }
def test_interval_interval_cmp_with_objects():
iv0 = Interval(0, 10)
ivd0 = Interval(0, 1, {'a': 1})
ivd1 = Interval(0, 1, {'a': 1})
assert ivd1.__cmp__(ivd0) == 0
assert ivd0.__cmp__(ivd1) == 0
assert ivd0.__cmp__(iv0) == -1
assert iv0.__cmp__(ivd0) == 1

The tutorial on tenforums for moving the Users folder did not work. There was an issue at the Sysprep step, which couldn't verify my Windows installation. At that point, I switched to the sevenforums instructions, planning to re-activate the users afterwards. I ended up not using D:/relocate.xml.

  1. Win-X, then open the admin command prompt.
  2. net user Administrator /active:yes
  3. Log out, then login as the Administrator (default: no password)
  4. Win-X, then open the admin command prompt.
  5. For each user, run the following. Don't forget the slash. This command resolves issues with missing Start menu and search bar. net user /active:no
  6. Open Start > Settings, then go to Accounts > Other users and make sure no other users are present.
  7. Win-R, then run diskmgmt.msc.
  8. Change D: drive to X:, then back to D:. This is to make sure Windows doesn't reassign the Users drive to a different letter later automatically.