Skip to content

Instantly share code, notes, and snippets.

View oskwazir's full-sized avatar

Omer Wazir oskwazir

View GitHub Profile
@oskwazir
oskwazir / rpn.erl
Created May 10, 2016 21:58
Reverse Polish notation calculator
% -*- coding: utf8 -*-
% From LearnYouSomeErlang Functionally Solving Problems
-module(main).
-export([main/0]).
main() ->
5 = rpn("2 3 +"),
87 = rpn("90 3 -"),
-4 = rpn("10 4 3 + 2 * -"),
-2.0 = rpn("10 4 3 + 2 * - 2 /"),
@oskwazir
oskwazir / rna_transcribe.erl
Last active May 10, 2016 16:52
Erlang String Operations
%% So Dna will be a string like "ABCDEFG"
%% and Erlang treats it like a list, but when you get the Head of the list
%% it's not like a regular String like I'm used to, so to pattern match it I used the $ thing.
%% Not sure what $ is called but it works to match when we get the character "G" from Dna.
%% Fall through needs to convert the binary form back to a list
%% So it looks like a String.
%% that's my explanation...
%%Dna = "ABCDEFG"
rna(Dna) ->
@oskwazir
oskwazir / namespacer.js
Created November 11, 2015 02:19
Namespacing utility
// Modified from http://addyosmani.com/blog/essential-js-namespacing/
// top-level namespace being assigned an object literal
var myApp = myApp || {};
// a convenience function for parsing string namespaces and
// automatically generating nested namespaces
function extend( namespace, namespace_string ) {
var parts = namespace_string.split('.');
var parent = namespace;
var partsLength;
var index;
@oskwazir
oskwazir / GET-AccountSummary-DefinitionsTrue.json
Created October 7, 2015 22:25
Destiny GET AccountSummary with query parameter definitions=true response
This file has been truncated, but you can view the full file.
{
"Response": {
"data": {
"membershipId": "4611686018431291900",
"membershipType": 2,
"characters": [
{
"characterBase": {
"membershipId": "4611686018431291900",
"membershipType": 2,
@oskwazir
oskwazir / functions.erl
Created July 28, 2015 06:15
Functions with pattern matching
-module(functions).
-compile(export_all). %%replace with -export() later!
head([H|_]) -> H.
second([_,X|_]) -> X.
same(X,X) ->
true;
same(_,_) ->
false.
-module(useless).
-export([add/2, hello/0, greet_and_add_two/1]).
add(A,B) ->
A + B.
%% Show greetings.
%% io:format/1 is the standard function use to output text.
hello() ->
io:format("Hello, world!~n").
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
/*
* See http://davidwalsh.name/flexbox-dice
* for this flexbox tutorial. I just wrote some code
* to see for myself what was happening.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
/*
* See http://davidwalsh.name/flexbox-dice
* for this flexbox tutorial. I just wrote some code
* to see for myself what was happening.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
/*
* See http://davidwalsh.name/flexbox-dice
* for this flexbox tutorial. I just wrote some code
* to see for myself what was happening.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
/*
* See http://davidwalsh.name/flexbox-dice
* for this flexbox tutorial. I just wrote some code
* to see for myself what was happening.