Skip to content

Instantly share code, notes, and snippets.

View alastairparagas's full-sized avatar

Alastair Paragas alastairparagas

View GitHub Profile
@alastairparagas
alastairparagas / buffer.js
Last active June 22, 2018 16:19
Buffering nodes with an Observable
function bufferBy(observable, startingIndex=0, bufferLength=1) {
return observable.flatMap(nodes => Rx.Observable.create(observer => {
let index = startingIndex;
while ((index + bufferLength) <= nodes.length) {
observer.next(nodes.slice(index, bufferLength));
index += bufferLength;
}
while (index < nodes.length - 1) {
observer.next(nodes.slice(index, nodes.length - index));
@alastairparagas
alastairparagas / instructions.txt
Created June 11, 2018 22:17
COP4722 Project Plan
Instructions on getting the assignment setup (on a GCP Compute Engine Instance):
# Get Docker and Docker-Compose Installed
sudo yum install docker
sudo curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo service start docker
# Add user to docker permissions group
sudo groupadd docker
@alastairparagas
alastairparagas / test.swift
Last active July 29, 2018 15:03
Playing Around With Swift
func containedClosureIncrementer() -> (() -> Int) {
var anInt = 0
func incrementer() -> Int {
anInt = anInt + 1
return anInt
}
return incrementer
}
func containedClosureIncrementer2() -> () -> Int {
var anInt = 0
@alastairparagas
alastairparagas / csv_generator.py
Created December 13, 2017 06:48
CSV Matrix Generator
import random
import csv
def export_matrix(box, output_file='matrix.csv'):
with open(output_file, 'w') as f:
writer = csv.writer(f, delimiter=',')
for line in box:
writer.writerow(line)
unique_words = set()
lines = ["line1 has some words", "line 2 has some words"]
for line in lines:
words_in_line = line.split(" ")
for word in words_in_line:
unique_words.add(word)
unique_words_as_list = list(unique_words)
@alastairparagas
alastairparagas / body.js
Created September 8, 2017 13:08
Body Structure of an HTTP POST request to ZenodoAddon
{
"keyword": ["ghost", "electricity"] // Keyword tags a user gave
"ranker": "distance" // Could be distance, ppr, pprMean
"vertexFinder": "fulltext" // Could be fulltext, plain
"count": 20,
"addons": ["cache"] // Only available addon is cache for the moment. (optional)
}
<?php
namespace WikiLeaksEmailDump\Parser;
use \Generator;
use \DOMDocument;
use \DOMNode;
use \DOMXPath;
use \InvalidArgumentException;
@alastairparagas
alastairparagas / StartupArgs.scala
Created July 10, 2017 16:57
CLI Args and Environment Variables Parsing
package ZenodoAnomalyDetection
import scala.util.Try
import java.util.regex.Pattern
import org.rogach.scallop.ScallopConf
class StartupArgs
{
@alastairparagas
alastairparagas / index.js
Created June 29, 2017 07:36
Streams example with Highland.js
const highland = require('highland'),
PgCursor = require('pg-cursor'),
pg = require('pg').native;
async function dbDataGenerator(username, password, db, host, port) {
/**
* Async functions in ES2017 automatically return ES6 Promises.
* In async functions, you can use the "await" keyword to wait
* for Promises to resolve or reject.
*
@alastairparagas
alastairparagas / recommendations.md
Last active August 7, 2017 22:20
Programming List of Recommendations. This list will be continually updated - I just don't have time to write everything in one sitting!

🎆 Programming Recommendations

THIS WILL BE CONTINUALLY UPDATED!

What should I pick up?

A lot of people ask me questions on what programming languages to pick up - most of them asking if language X is better than language Y.

First off - whatever you can build in one programming language, you can build in another programming language. If I wanted to make a desktop application, I could use JavaFX or Swing all in Java, PyQt in Python, Threepenny-gui in Haskell or Electron in Javascript (NodeJS variant). If I wanted to build a mobile app, I could either make a web app that looks like a mobile app and has access to device sensors using Cordova with HTML, CSS and Javascript, build using the native GUI components of the mobile platform but use the convenience of Javascript using something like React Native, use something like Kivy if I am insistent on building it with Python, or use good old Java.

Choosing a programming language is more about what language suits the job more and