Skip to content

Instantly share code, notes, and snippets.

View syntacticsugar's full-sized avatar
🎯
Focusing

RomyRomy syntacticsugar

🎯
Focusing
View GitHub Profile
import Either
--main = asText (filterrr (\x -> x > 2) [1, 2, 3, 4])
main = asText (map squirtWithError [-2, -1, 0, 16, 36])
-- types
data Option a = None | Some a

How to Use

Open up Terminal.app in your /Applications/Utilities directory, then type in these commands, one after each other:

  1. Create a temporary directory for cycript:

    mkdir cycript && cd cycript
    
  2. Pull the latest cycript from cycript.org:

@syntacticsugar
syntacticsugar / 44a_pentagonal_numbers.rb
Last active August 29, 2015 14:01
project euler #44 Pentagonal Numbers in Ruby. This is probably the most inefficient, naive way to solve it, but it solved the problem. blehhhhh
=begin
Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are:
1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ...
It can be seen that P^4 + P^7 = 22 + 70 = 92 = P^8.
However, their difference, 70 − 22 = 48, is not pentagonal.
Find a pair of pentagonal numbers P^j and P^k,
class GuessTheNumber
def play
@nnn = 1.upto(100).to_a.sample
# play game
puts "Alright, I have a number in mind from 1-100. Pick a number."
guess = gets.chomp
puts "You said #{guess}."
attempt guess
end
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="datetime"]:focus,
input[type="datetime-local"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
input[type="time"]:focus,
input[type="week"]:focus,
input[type="number"]:focus,
@syntacticsugar
syntacticsugar / maybe.sml
Created September 17, 2014 22:09
tutorial from Nicky Bicky
type Maybe a = Nothing | Just a
type Option a = None | Some a
type Result a = Failure | Success a
max [] ----> Failure
max [1,2,3] -----> Success 3
@syntacticsugar
syntacticsugar / js_recursion_simple.js
Created October 6, 2014 16:14
A simple JS recursion using slice.
function sum (numbers) {
return !numbers.length ? 0 : numbers[0] + sum(numbers.slice(1));
};
module Sinatra
module Kittens
module Helpers
def kittens_page(x = 200..500, factor = 0.2)
sample_method = RUBY_VERSION >= '1.9' ? :sample : :choice
x = x.to_a.send(sample_method)
y = ((x - factor*x).floor..(x + factor*x).ceil).to_a.send(sample_method)
<<-HTML
<!DOCTYPE html>
@syntacticsugar
syntacticsugar / defining_lists.elm
Created March 16, 2015 03:05
wherein we try defining `list`
import Text (asText)
type Collection a = Nada | Glue a (Collection a)
summm xs =
case xs of
Nada -> 0
Glue face body -> face + (summm body)
listToCollection collection =
@syntacticsugar
syntacticsugar / gist:1587748
Created January 10, 2012 07:59
(l.i.v.i.n.g) (s.o.c.i.a.l) part 2 response

Sae Rom Hong

Open Source Tech Evangelist / Front End Designer How to Fall in Love with the Command Line

Imagine a mythical forest. This is a forest that at first, exists only in the invisible nth-dimension of your imagination. Just like Peter Pan's Neverland. This forest is the world of the Linux/Unix command line, and everything is enshrouded in a thick, black, darkness. The only remnants of light glow and flicker between walls of forward slashes, glittering periods, and blinking cursors.

Deep inside the forest hides an elusive silver unicorn. The unicorn flits in and out, behind thick trunks of trees, a hint of a mane trailing in the darkness. You have heard a rumor that it is possible to catch a glimpse of this unicorn, if you use a little “magic”.