Skip to content

Instantly share code, notes, and snippets.

View artlogic's full-sized avatar

James Kruth artlogic

View GitHub Profile

Keybase proof

I hereby claim:

  • I am artlogic on github.
  • I am artlogic (https://keybase.io/artlogic) on keybase.
  • I have a public key whose fingerprint is 7284 4FEF E1E0 AB9F EEC1 5205 5EEA D6E4 206B 0AE9

To claim this, I am signing this object:

@artlogic
artlogic / error.js
Created December 15, 2016 01:42
Possible testdouble.js regression?
'use strict';
// Much of this was inspired by sequelize's error module
// https://github.com/sequelize/sequelize/blob/master/lib/errors.js
var util = require('util');
var error = {};
// Every built in error inherits from this error
var timeout = 5000; // 5 seconds
var p = new Promise(function (resolve, reject) {
setTimeout(function () {
resolve();
}, timeout);
});
p.then(function () {
console.log('this will run after 5 seconds!');
@artlogic
artlogic / scrape.py
Created August 25, 2016 18:01
GPS Scraper
from io import BytesIO
from bs4 import BeautifulSoup
import exifread
import requests
# the url to rip from... you could easily use .format to replace 1
# with any page you like, or even loop through many pages
url = 'http://tinypic.com/images.php?page=1'
@artlogic
artlogic / elemtree.py
Last active August 29, 2015 14:23
Element Tree
class Node:
def __init__(self, value):
self.value = value
self.children = []
self.complete = False
elemset = set() # let's assume this is filled with the elements (lowercased)
word = '' # let's assume this is the word
root = Node(None)
Verifying that +artlogic is my openname (Bitcoin username). https://onename.io/artlogic
require 'formula'
# NOTE: GCC 4.6.0 adds the gccgo compiler for the Go language. However,
# gccgo "is currently known to work on GNU/Linux and RTEMS. Solaris support
# is in progress. It may or may not work on other platforms."
def cxx?
ARGV.include? '--enable-cxx'
end
@artlogic
artlogic / ftprmtree.py
Created May 8, 2012 04:44
Python ftplib rmtree
def FtpRmTree(ftp, path):
"""Recursively delete a directory tree on a remote server."""
wd = ftp.pwd()
try:
names = ftp.nlst(path)
except ftplib.all_errors as e:
# some FTP servers complain when you try and list non-existent paths
_log.debug('FtpRmTree: Could not remove {0}: {1}'.format(path, e))
return
@artlogic
artlogic / copytree-headless.py
Created May 4, 2012 07:22
Like shutil.copytree, only no need for a containing directory at the source.
# copy headless tree
rootlen = len(source) + 1 # chop off the leading slash below
for root, dirs, files in os.walk(source):
diff = root[rootlen:]
for f in files:
shutil.copy2(os.path.join(root, f), os.path.join(dest, diff))
for d in dirs:
try:
os.mkdir(os.path.join(dest, diff, d))
except OSError:
@artlogic
artlogic / gist:1072135
Created July 8, 2011 15:56
Adding option tags to a select via jQuery.
$.each(selectValues, function(key, value) {
$('#mySelect')
.append($('<option>', { value : key })
.text(value));
});