Skip to content

Instantly share code, notes, and snippets.

View AJamesPhillips's full-sized avatar

Alexander James Phillips AJamesPhillips

View GitHub Profile
@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
@AJamesPhillips
AJamesPhillips / rsa.py
Last active February 10, 2020 12:21
Reorder arguments in bruteForceV1 signature
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Simple example of encrypting, sending and decrypting a message using RSA.
Also included is how a third party without permission, would need
to use a very time consuming (brute force) approach to decrypt
the message. This is done by finding the two prime numbers that make up
part of the public key so that you can read the encrypted message.
@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 / gist:04f3047ca8770f4a3a58
Created May 2, 2014 15:18
Integration testing Scrapy spiders
import subprocess
import unittest
from scrapy.crawler import Crawler
from scrapy.utils.project import get_project_settings
from twisted.internet import reactor, task
from my_project.spiders.spider1 import Spider1
from my_project.spiders.spider2 import Spider2
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