Skip to content

Instantly share code, notes, and snippets.

Ryan Levick rylev

Block or report user

Report or block rylev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rylev
rylev / monadfun.scala
Last active Aug 29, 2015
An explanation of the map function in Scala.
View monadfun.scala
/* Map */
class Future[A] {
map[B](someMapFunction: A => B): Future[B]
}
// Mapping lets you convert any Future of some type A to a Future of some type B
// For instance you can go from Future[String] to Future[Int]
val myFutureString : Future[String] = Future("some String")
View gist:50923650bc7e8828f4f9
=erl_crash_dump:0.2
Fri Sep 26 14:40:25 2014
Slogan: init terminating in do_boot ()
System version: Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Compiled: Tue Sep 3 19:23:51 2013
Taints:
Atoms: 4761
=memory
total: 10782344
processes: 3969496
View gist:b40ecce85750bd528c0d
if (resp.isSuccess)
Future{ NoContent }
else passthrough(resp)
if (resp.isSuccess) {
Future{ NoContent }
} else {
passthrough(resp)
}
View maybe.swift
enum Maybe<T> {
case Just(T)
case None
func maybe(def: T, fn: (T) -> (T)) -> T {
switch self {
case let Just(x): return fn(x)
case None: return def
}
}
View gist:6d9c934ad71e952e0fa1
### Keybase proof
I hereby claim:
* I am rylev on github.
* I am ryanlevick (https://keybase.io/ryanlevick) on keybase.
* I have a public key whose fingerprint is F379 58BE 0E1A ECE1 D1DB A8E5 243E 54BE D142 3716
To claim this, I am signing this object:
View gist:1da4bf6aeed4ca10141d
import Database.Redis
import Control.Monad.IO.Class
import Data.ByteString.Char8
main :: IO ()
main = do
conn <- connect defaultConnectInfo
runRedis conn $ do
set (pack "hello") (pack "hello")
hello <- get $ pack "hello"
@rylev
rylev / rgb.ex
Created Apr 8, 2014
Small Module For Parsing and Encoding RGB Values
View rgb.ex
defmodule RGB do
import Enum, only: [map: 2, join: 1, filter: 2, chunk: 2, count: 1]
def encode(rgb) when is_list rgb do
hex = rgb |>
map(&(integer_to_list &1, 16)) |>
map(fn [x] -> [x, x]; x -> x end) |>
map(&String.from_char_list!/1) |>
join
"#" <> hex
View user.exs
defmodule User do
defstruct firstname: "Ryan", lastname: "Levick"
def full_name(user) do
user.firstname <> " " <> user.lastname
end
end
user = %User{}
User.full_name(user) =>
@rylev
rylev / stark_params.rb
Created Mar 11, 2014
Strong Parameters Wrapper
View stark_params.rb
def TasksController
def index
Task.where(index_params)
end
def create
Task.create!(create_params)
end
private
@rylev
rylev / calc.hs
Created Feb 24, 2014
Simple and Incredibly Naive Calculator
View calc.hs
module Main where
import System.Environment
import Text.ParserCombinators.Parsec
import Control.Monad
import Data.Char
main :: IO ()
main = do putStrLn "What would you like to calculate:"
input <- getLine
putStrLn $ readExpr input
You can’t perform that action at this time.