Skip to content

Instantly share code, notes, and snippets.

View alastairparagas's full-sized avatar

Alastair Paragas alastairparagas

View GitHub Profile
@alastairparagas
alastairparagas / IterativeStochasticGradientDescent.hs
Last active January 6, 2017 21:16
Stochastic Gradient Descent in Haskell. Stochastic Gradient Descent is a version of Linear Regression. LR allows us to train the computer to predict some continuous (non-discrete) value given some input features. Example of an input feature - house square footage, crime rate, etc. Example of a target value - mortgage price.
module IterativeStochasticGradient where
{-
Train is a function that accepts a:
- a list of training example that consists of a list
of input features and a target value
- a list of starting weights for each input feature
- an intercept value
- a learning rate
Outputs a tuple: list of weights for each corresponding input
@alastairparagas
alastairparagas / system_call.c
Last active January 29, 2017 02:36
Linux Kernel System Call
#include<linux/linkage.h>
#include<linux/sched.h>
#include<linux/time.h>
asmlinkage long sys_alastair_paragas(int pantherid)
{
// System Call - returns back provided panther id
// and the current system time in hh:mm:ss, month day, year format
struct timeval time_in_sec;
struct tm time_info;
@alastairparagas
alastairparagas / regular_expressions.py
Last active January 30, 2017 06:00
Theory of Algorithms: Chapter 3.1 - Regular Expressions
import greenery.lego as lego
import itertools
"""
Theory of Algorithms 3.1
An Introduction to Formal Languages and Automata
Solution Checker Program
"""
def unmatched_samples(regex1Obj, regex2Obj):
@alastairparagas
alastairparagas / instructions.md
Last active February 7, 2017 21:24
Instructions for shared folder

On the VirtualBox Menu:

  • -> Devices -> Shared Folders

Mount on OS:

  • sudo mount -t vboxsf -o uid=1000,gid=1000 cop4610 /home/cop4610/<folder path>

Edit fstab (add last line):

  • cop4610 /home/cop4610/ vboxsf defaults 0 0
@alastairparagas
alastairparagas / click.js
Created March 3, 2017 01:13
Refresh on clicking a elements
Array.prototype.slice.call(document.getElementsByTagName('a')).map(htmlNode => {
htmlNode.addEventListener('click', () => location.reload());
});
/*
* SLOB Allocator: Simple List Of Blocks
*
* Matt Mackall <[email protected]> 12/30/03
*
* NUMA support by Paul Mundt, 2007.
*
* How SLOB works:
*
* The core of SLOB is a traditional K&R style heap allocator, with
@alastairparagas
alastairparagas / slob.c
Created March 31, 2017 04:16
Such a SLOB
/*
* SLOB Allocator: Simple List Of Blocks
*
* Matt Mackall <[email protected]> 12/30/03
*
* NUMA support by Paul Mundt, 2007.
*
* How SLOB works:
*
* The core of SLOB is a traditional K&R style heap allocator, with
@alastairparagas
alastairparagas / Main.hs
Last active May 30, 2017 15:09
Haskell: Streaming Twitter Data
module Main where
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource (runResourceT)
import Data.Conduit (($$+-), ($=+), runConduit)
import Data.Conduit.List (mapM_, map, filter, catMaybes)
import qualified Data.ByteString.Char8 (pack)
import Data.Text (unpack)
import qualified Data.Text (pack)
import Data.Maybe (fromJust)
@alastairparagas
alastairparagas / Assignment2.fsx
Created June 6, 2017 04:41
Assignment #2, F#
(*
Homework 2.1
Write an uncurried F# function cartesian (xs, ys) that takes as input
two lists xs and ys and returns a list of pairs that represents the
Cartesian product of xs and ys. (The pairs in the Cartesian product
may appear in any order.)
*)
let rec cartesian = function
| (xs, []) -> []
| (xs, y::ys) -> List.map (fun x -> (x, y)) xs @ cartesian (xs, ys) ;;
@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