Skip to content

Instantly share code, notes, and snippets.

View tfogo's full-sized avatar

Tim Fogarty tfogo

View GitHub Profile
<!DOCTYPE html>
<head>
</head>
<body>
<div id="song1">
<button onclick="playSong1()">play</button>
<button onclick="mySource.setPosition(-0.9, 8.9, 0)">right 1</button>
<button onclick="mySource.setPosition(-2, 8.9, -1)">right 2</button>
<button onclick="mySource.setPosition(-1, 8.9, -2)">right 3</button>
@tfogo
tfogo / index.py
Created October 8, 2017 04:58
Example Flask and Mongo
from flask import Flask
from pymongo import MongoClient
from bson.json_util import dumps
app = Flask(__name__)
db = MongoClient('mongodb://<dbuser>:<dbpass>@localhost:27017/mydb')['mydb']
@app.route('/')
def index():
return 'Hello, World!'
@tfogo
tfogo / Command to add data
Created October 7, 2017 05:39
Example data from petflix.io
mongoimport -h localhost -d dbname -c collectionname --jsonArray --file petflix.json
@tfogo
tfogo / bitmap.dyalog
Created March 5, 2017 07:46
Read a bitmap file with APL
:Class Bitmap
:Field Public FileTie
:Field Public BMPHeader
:Field Public DIPHeader
:Field Public ImageTable
:Field Public ImageWidth
:Field Public ImageHeight
:Field Public ImageDataOffset
:Field Public Bytes
@tfogo
tfogo / index.js
Created January 23, 2017 23:04
Call getPrimePhoneNumbers to test out your script
console.log('US numbers:');
getPrimePhoneNumbers('US', 650).then(data => console.log(data));
// Search by area code only works for US and Canada. Twilio just ignores it for other countries
console.log('UK numbers:');
getPrimePhoneNumbers('GB').then(data => console.log(data));
@tfogo
tfogo / _index.js
Last active January 23, 2017 23:17
var twilio = require('twilio');
var primality = require('primality');
var countries = require('./countries');
const accountSid = process.env.TWILIO_AC_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
var client = require('twilio')(accountSid, authToken);
function getRandomInt(min, max) {
// max and min numst be integers
@tfogo
tfogo / index.js
Last active January 23, 2017 22:18
function getPrimePhoneNumbers(isoCountry, areaCode) {
// ...
// Get the length of the country code so we know what to cut off from the number
let countryCodeLen = countries[isoCountry].code.length;
// assign the resolution of phonePromise to a variable
let primeNumberPromise = phonePromise.then(data => {
var verifiedPrimes = [];
let twilioPromise = client.availablePhoneNumbers(isoCountry).local.list({
Contains: getRandomInt(10,99),
areaCode: areaCode
});
function getPrimePhoneNumbers(isoCountry, areaCode) {
// ...
}
@tfogo
tfogo / countries.js
Last active January 23, 2017 23:16
Countries and area codes used by Twilio
module.exports = {
US: {
name: "United States",
code: "+1",
},
AU: {
name: "Australia",
code: "+61",
},
AT: {