Skip to content

Instantly share code, notes, and snippets.

@edc
edc / search.sh
Created August 28, 2015 06:20
Find big files committed recently in Git
#!/bin/bash
# Taken from http://gregmac.net/git/2013/06/13/locating-large-objects.html
GIT_CMD=/usr/local/bin/git
RANGE=$1 # like '1.month.ago'
SIZE_THRESHOLD=$2 # size in bytes
# Iterate over a list of commits
for commit in $(${GIT_CMD} rev-list --all --since={${RANGE}} --pretty=oneline | cut -d' ' -f1); do
@edc
edc / mock_import.py
Created July 30, 2015 17:56
How to fail an import in tests
import mock
import sys
class Finder(object):
def find_module(self, name, path=None):
print name, path
raise ImportError
import threading
@edc
edc / Time stamp on photo
Created February 18, 2011 04:02
Add time stamp on photos for printing
#!/bin/bash
echo Processing $1
SIZE=`convert -identify -ping $1 /dev/null | cut -d ' ' -f 3`
X=`echo $SIZE | cut -d 'x' -f 1`
Y=`echo $SIZE | cut -d 'x' -f 2`
X=`expr $X - 1500`
Y=`expr $Y - 100`
mv $1 _$1
set -o verbose
convert _$1 -font ~/Downloads/digital_7/digital-7-mono.ttf -pointsize 300 -fill red -annotate +$X+$Y %[exif:DateTimeOriginal] $1
@edc
edc / gen-bootstrap.py
Last active December 16, 2015 10:49
A simple bootstrap generator using virtualenv. It packs a standalone script (`src.py`), a run script (`run.sh`) into the generated bootstrap script. The bootstrap script will also install dependency based on `requirements.txt`, and run the pip command in a controlled shell environment declared in `bootstrap.env`. The controlled environment allow…
import sys
import os
import json
import virtualenv
SOURCE = 'src.py'
RUNSH = 'run.sh'
REQUIREMENTS = 'requirements.txt'
BOOTSTRAPENV = 'bootstrap.env'
@edc
edc / gist:5520005
Created May 5, 2013 07:14
Boilerplate code for Core Data project
- (NSManagedObjectContext *) managedObjectContext {
if (_managedObjectContext != nil) {
return _managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
_managedObjectContext = [[NSManagedObjectContext alloc] init];
[_managedObjectContext setPersistentStoreCoordinator: coordinator];
}
@edc
edc / clone-youtube-playlist.js
Last active September 21, 2018 23:30
Add a whole Youtube playlist to watch later - so you can clone the list easily
// this script copies a youtube playlist to the "watch later" list, so you can easily clone the
// list by creating a new one off the watch later list. You must run this on a playlist overview
// page like http://www.youtube.com/playlist?list=xxxxxxxxx
// this script is meant to be converted into a bookmarklet, using something like http://mrcoles.com/bookmarklet/
// after conversion, it becomes this:
// javascript:(function()%7Bvar%20buttons%20%3D%20document.querySelectorAll(%22button.addto-watch-later-button%22)%3Bvar%20videos%20%3D%20document.querySelectorAll(%22.playlist-video-item%22)%3Bif%20(videos.length%20!%3D%20buttons.length)%20%7Balert(%22Some%20videos%20are%20already%20in%20watch%20later!%20Found%20%22%20%2B%20videos.length%20%2B%20%22%20videos%20but%20%22%20%2B%20buttons.length%20%2B%20%22%20buttons.%20Abort%20now.%22)%3B%7D%20else%20%7Bif%20(confirm(%22Add%20%22%20%2B%20buttons.length%20%2B%20%22%20videos%3F%22))%20%7Bvar%20dialog%20%3D%20document.createElement(%22h1%22)%3Bdialog.innerHTML%20%3D
@edc
edc / README.md
Last active November 8, 2018 17:48
tensorflow + eGPU on Ubuntu

GPU Driver

Run sudo ubuntu-drivers devices to find what drivers are available, and then use apt to install the driver. In my case, it is apt install nvidia-driver-390. Reboot after installation completes, and use nvidia-smi command to ensure the driver is loaded.

Install Anaconda

Use Anaconda to simplify the process of installing tensorflow and related packages. Install it with wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh and then execute it.

Install TensorFlow with GPU Support with Anaconda

@edc
edc / tensorflow_1_8_high_sierra_gpu.md
Last active July 14, 2020 09:53 — forked from Willian-Zhang/tensorflow_1_8_high_sierra_gpu.md
Install TensorFlow 1.8 on macOS High Sierra 10.13.6 with CUDA

Tensorflow 1.8 with CUDA on macOS High Sierra 10.13.6

Forked from @William-Zhang's gist

Requirements

  • NVIDIA Web-Drivers 387.10.10.10.30.106 for 10.13.4 (17E199) (w/o Security Update)
  • CUDA-Drivers 387.128
  • CUDA 9.1 Toolkit
  • cuDNN 7.0.5 (latest for macOS)