Skip to content

Instantly share code, notes, and snippets.

View aitoroses's full-sized avatar

Aitor Oses aitoroses

View GitHub Profile
@aitoroses
aitoroses / gist:512d36d4353cf53bc98b386c9a82c722
Created May 7, 2019 19:01 — forked from relrod/gist:dd748c9ee0b111c3bd47
Pure IO in OCaml via the Free monad
(* Purely functional I/O in Ocaml via the Free monad.
* by Ricky Elrod <[email protected]>.
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@aitoroses
aitoroses / .hyper.js
Last active May 17, 2019 06:16
Hyper terminal configuration together with pure for zsh
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@aitoroses
aitoroses / Show.re
Created April 3, 2019 07:14
ReasonML adhoc polymorphism
module type SHOW = {
type t
let show: t => string
};
type show_impl('a) = (module SHOW with type t = 'a)
module Show_int: SHOW with type t = int = {
type t = int;
let show = string_of_int
@aitoroses
aitoroses / baby-lisper.js
Created April 16, 2018 14:38 — forked from jameslaneconkling/baby-lisper.js
A silly simple lisp parser in javascript
const rules = [
{ type: 'space', regex: /^\s/ },
{ type: 'lParen', regex: /^\(/ },
{ type: 'rParen', regex: /^\)/ },
{ type: 'number', regex: /^[0-9\.]+/ },
{ type: 'string', regex: /^".*?"/ },
{ type: 'variable', regex: /^[^\s\(\)]+/ } // take from the beginning 1+ characters until you hit a ' ', '(', or ')' // TODO - support escaped double quote
];
https://www.youtube.com/watch?v=iumlHzoVlJM
class Perceptron {
constructor (x_train, y_train, epochs=1000, learn_rate= 0.1) {
// used to generate percent accuracy
this.accuracy = 0
this.samples = 0
this.x_train = x_train
@aitoroses
aitoroses / kmskeys10.txt
Created November 11, 2017 15:26 — forked from CHEF-KOCH/kmskeys10.txt
Windows 10 KMS Keys
Windows.10.and.Office.2016.gVLK
#####################################################################
# Install/Uninstall keys #
#####################################################################
1.) Uninstall the current product by entering the “uninstall product key” extension:
slmgr.vbs /upk
2.) Install the key that you obtained above for “Windows Srv 2012R2 DataCtr/Std KMS for Windows 10”
@aitoroses
aitoroses / disable_nsurlsessionid.sh
Created August 21, 2017 15:09 — forked from akhy/disable_nsurlsessionid.sh
Disable NSURLSessionId
launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlstoraged.plist
launchctl unload /System/Library/LaunchAgents/com.apple.nsurlsessiond.plist
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlsessiond.plist
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlstoraged.plist
@aitoroses
aitoroses / app.ts
Last active June 1, 2017 08:33
Using angular DI to create a node app (POC)
import { bootstrap, Request, Response, MongooseFactory, Injectable } from './library'
@Injectable()
class UserModel {
private model
constructor(modelFactory: MongooseFactory) {
this.model = modelFactory.createModel('users', mongoose.Schema({
name: String
@aitoroses
aitoroses / Maybe.ts
Created May 31, 2017 11:12
Maybe Monad
interface MaybePattern<A, B> {
Just: (a: A) => B,
Nothing: () => B
}
class Maybe<A> {
static of<A>(a: A): Maybe<A> {
return a ? new Just(a) : new Nothing()
@aitoroses
aitoroses / typescript-pattern-matching.ts
Created May 27, 2017 11:12 — forked from rob3c/typescript-pattern-matching.ts
TypeScript pattern matching proof-of-concept
// preserved from my comment in this issue: https://github.com/Microsoft/TypeScript/issues/165#issuecomment-259598080
interface Type<T> { new(...args): T }
interface CaseResult<R> {
success: boolean;
result: R;
}
interface CaseFn<R> { (value: any): CaseResult<R> }