Skip to content

Instantly share code, notes, and snippets.

View AJamesPhillips's full-sized avatar

Alexander James Phillips AJamesPhillips

View GitHub Profile
@AJamesPhillips
AJamesPhillips / gist:11308972
Last active August 29, 2015 14:00
Does not error
interface Animal {
size: number;
}
interface Cat extends Animal {
furry: boolean;
}
interface Human extends Animal {
name: string;
}
@AJamesPhillips
AJamesPhillips / output
Created November 3, 2012 11:57
phantomjs1.7 returning html elements from page
complete
on page, got: 3 results: [object HTMLLIElement],[object HTMLLIElement],[object HTMLLIElement]
From page, got: 3 results: [object Object],,
fs = require('fs');
function scrape() {
var url = "some local url with asset served";
var date = new Date();
var stamp = date.getTime();
console.log("scraping url: " + url);
//Screenshot 1 - Routes and Traffic Time Table
var page = require('webpage').create();
@AJamesPhillips
AJamesPhillips / gist:6899560
Created October 9, 2013 11:05
tldextract_cache
c__builtin__
frozenset
p1
((lp2
Vchikuho.fukuoka.jp
p3
aVthruhere.net
p4
aV\u0c2d\u0c3e\u0c30\u0c24\u0c4d
p5
import AIToolbox
import XCTest
@testable import ios_hub
class LogRegTests: XCTestCase {
func getSmallTestData() -> DataSet {
// Create test case
let data = DataSet(dataType: .Classification, inputDimension: 2, outputDimension: 1)
do {
// Code and tests adapted from Numpy library
func dot_product(in arr1: [Double], index1: Int, in arr2: [Double], index2: Int, n: Int, result_index: Int, inout result_arr: [Double]) {
var sum = 0.0;
for i in 0..<n {
sum += arr1[index1 + i] * arr2[index2 + i]
}
result_arr[result_index] = sum
}
import time
import threading
input_thread_values = []
def input_thread():
print('press s and enter to stop...')
global input_thread_values
@AJamesPhillips
AJamesPhillips / git_helper.py
Last active March 30, 2017 13:15
Display the number of additions and deletions per commit for a file
#!/usr/bin/env python3
"""
Display the number of additions and deletions per commit for a file e.g.
$ ./git_helper.py index.d.ts
commit added deleted
bd1de57 4 4 index.d.ts Error object fix
c3a54db 25 120 index.d.ts Merge branch 'master' into types-2.0
e9a0e98 58 10 index.d.ts Merge commit 'upstream/master~300' into merge_7_25
// Similar to Ruby array `last` method
Object.defineProperty(Array.prototype, "last", {
get: function(){
return this.length && this[this.length-1];
}
});
// Adapted from: https://nodejs.org/docs/latest/api/cluster.html
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running on ${numCPUs} numCPUs`);
// Fork workers.