Skip to content

Instantly share code, notes, and snippets.

View TheSeamau5's full-sized avatar

Hassan Hayat TheSeamau5

  • Entrepreneur
  • Austin, TX
View GitHub Profile
@TheSeamau5
TheSeamau5 / HackerNewsExample.elm
Last active September 23, 2018 00:24
Hacker news requests example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn)
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --
@TheSeamau5
TheSeamau5 / pipeoperator.elm
Created April 22, 2015 11:54
Pipe operator in Elm
(->>) : a -> List (a -> a) -> a
(->>) x list = case list of
[] -> x
f :: fs -> (->>) (f x) fs
@TheSeamau5
TheSeamau5 / digits.elm
Created April 22, 2015 03:07
Extract digits from a float
import String exposing (toList)
import Maybe
import List exposing (member)
import Graphics.Element exposing (show)
toChar x =
if | x == 0 -> '0'
| x == 1 -> '1'
| x == 2 -> '2'
| x == 3 -> '3'
@TheSeamau5
TheSeamau5 / artistSearchExample.elm
Last active March 10, 2016 15:12
Artist Search Example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Json.Decode as Decode exposing (Decoder, object2, map, string, list, (:=))
import Task exposing (Task, andThen, succeed, fail, onError)
import Signal exposing (Signal, Mailbox, mailbox, message, send)
import String
-------------------------
@TheSeamau5
TheSeamau5 / MatchOn.elm
Created April 12, 2015 14:59
String Match On
matchOn : String -> String -> Maybe String
matchOn start string =
if startsWith start string
then
Just <| dropLeft (length start) string
else
Nothing
@TheSeamau5
TheSeamau5 / shrinkInt.elm
Created April 10, 2015 23:58
Shrink Strategy for Ints
shrinkInt : Int -> List Int
shrinkInt n =
if n < 0
then
-n :: List.map ((*) -1) (series 0 -n)
else
series 0 n
series : Int -> Int -> List Int
@TheSeamau5
TheSeamau5 / MacrosInProgrammingLanguages.md
Last active December 26, 2016 11:12
Macros in Different Programming Languages

Macros/Metaprogramming in Programming Languages

The following is a list of programming languages and their syntax for doing metaprogramming.

C

Macros in C are just glorified string substitution.

@TheSeamau5
TheSeamau5 / ReactNativeExample.jsx
Created March 26, 2015 21:56
React Native Example Reddit Client
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require("react-native");
var {
AppRegistry,

Record Example

The following is an example of how to:

  • create a nested record type
  • encode this as JSON
  • decode a JSON string to an entity
  • create a random Entity generator
  • test the JSON parsing of the Entity
@TheSeamau5
TheSeamau5 / RedditHomePage.elm
Last active March 10, 2016 15:14
Getting the Reddit Home Page using Elm Promises
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, succeed, andThen, onError)
import Json.Decode exposing (Decoder, object2, (:=), string, int, list, map)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --