Skip to content

Instantly share code, notes, and snippets.

@mjgpy3
mjgpy3 / TDNU.txt
Last active August 29, 2015 14:23
Expected TypesDoNotUnify
TypeConstructor Main.Person
Error:
Error in module Main:
Error in value declaration name:
Error checking that type
Main.Person
subsumes type
Prim.Int -> Main.Person
Error at /home/michael/dev/contrib/purescript/examples/failing/CaseDoesNotMatchAllConstructorArgs.purs line 12, column 17 - line 12, column 34:
Cannot unify type
@mjgpy3
mjgpy3 / gfl_backticks.md
Created August 12, 2015 14:53
Does GFL escape backticks?

a / b * b + (a mod b) = a

@mjgpy3
mjgpy3 / The Technical Interview Cheat Sheet.md
Created August 28, 2015 18:20 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@mjgpy3
mjgpy3 / StackVCounters.md
Created September 19, 2015 17:07
Stack vs Counters

Example failing with multiple counters:


@mjgpy3
mjgpy3 / CoolPythonStuff.mkd
Last active February 28, 2016 16:29
CoolPythonStuff.mkd

List comprehensions

[i for i in xrange(1, 20) if i % 3 == 0]

Dot

foo.bar()

In Object Oriented programming, send the message "bar" to foo

@mjgpy3
mjgpy3 / deepProperty.js
Created March 3, 2016 19:45
Deep property index in JavaScript
var deepProperty = function (properties) {
return function (obj) {
return properties.reduce(function (obj, key) {
return obj[key];
}, obj);
};
};
deepProp(['a', 'b', 'c'])({ a: { b: { c: 42 } }}) // => 42
@mjgpy3
mjgpy3 / pattern-matching.js
Created March 7, 2016 18:25
Easy pattern matching in JavaScript
'use strict';
const buildMatcher = (cases) => (actual) =>
cases
.find((cse) => cse.matches(actual))
.result(actual);
const buildNextOn = (previousCases) => {
var build = (matchesPred, result) => {
const cases = previousCases.concat(
@mjgpy3
mjgpy3 / io_examples.py
Created March 9, 2016 19:10
Python IO Examples
# Simple file IO
```python
with open('somefile.txt', 'w') as file:
file.write('foobar')
with open('somefile.txt', 'r') as file:
text = file.read()
print text
# => foobar
@mjgpy3
mjgpy3 / compose.js
Last active April 12, 2016 13:42
Function composition in JavaScript
function compose() {
return Array
.prototype
.slice
.call(arguments)
.reduce(compose2, identity);
}
function compose2(f, g) {
return function (x) {
@mjgpy3
mjgpy3 / some_lambda_calc_notes.mkd
Created April 13, 2016 02:36
Some Lambda Calculus Notes

Lambda Calculus

A programming language, with ONLY functions.

Consists of

  • Name (kind of like a variable)
  • Lambda functions (kind of like normal functions)
  • Application (how we apply functions)

Terms: