Skip to content

Instantly share code, notes, and snippets.

Avatar
💭

Guillermo Iguaran guilleiguaran

💭
View GitHub Profile
View camelize.ex
def camelize(""),
do: ""
def camelize(<<?_, t :: binary>>),
do: camelize(t)
def camelize(<<h, t :: binary>>),
do: <<to_upper_char(h)>> <> do_camelize(t)
defp do_camelize(<<?_, ?_, t :: binary>>),
View compressor.rb
module Uglifyrb
# A wrapper around the UglifyJS interface
class Compressor
def initialize(options = {})
end
def compress(source)
f = Tempfile.new("jstemp")
f.write(source)
f.close
View rps.clj
; Adapted from: http://tech.puredanger.com/2013/07/10/rps-core-async/
(ns clojure.core.typed.test.rps-async
(:require [clojure.core.typed :as t]
[clojure.core.async :as a]
[clojure.core.typed.async :as ta]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Types
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
View types101.ex
# From http://learnyouahaskell.com/types-and-typeclasses
@ann map :: ([A], (A -> B) -> [B])
@ann remove_non_uppercase :: [Char] -> [Char]
@ann add_three :: Int, Int, Int -> Int
@ann factorial :: Int -> Int
View contracts.ex
@requires x >= 0
@ensures (result * result) <= x && (result + 1) * (result + 1) > x
def sqrt(x) do
# ...
end
View examples.ex
@annotate inc(Int) :: Int
def inc(num), do: num + 1
@annotate id(A) :: A
def id(x), do: x
@annotate map([A], (A -> B)) :: [B]
def map(x, f), do: Enum.map(x, f)
@annotate abs(Number) :: Number
View log.cpp
int log(int x)
//@requires x >= 1;
//@ensures \result >= 0;
//@ensures (1 << \result) <= x;
{ int r = 0;
int y = x;
while (y > 1)
//@loop_invariant y >= 1 && r >= 0;
//@loop_invariant y * (1 << r) <= x;
{
View _dashboard.css.scss.diff
diff --git a/app/assets/stylesheets/_dashboard.css.scss b/app/assets/stylesheets/_dashboard.css.scss
index 3c3d962..7b9f2df 100644
--- a/app/assets/stylesheets/_dashboard.css.scss
+++ b/app/assets/stylesheets/_dashboard.css.scss
@@ -10,7 +10,7 @@
li {
margin-bottom: 1em;
- list-style-type: none;
+ list-style-type: circle;
View script.rb
require 'sprockets'
project_root = File.expand_path(File.dirname(__FILE__))
assets = Sprockets::Environment.new(project_root) do |env|
env.logger = Logger.new(STDOUT)
env.register_transformer 'text/sass', 'text/css', Sprockets::SassCProcessor.new
end
assets.append_path(File.join(project_root, 'source', 'assets', 'stylesheets'))
View HindleyMilner.scala
/*
* http://dysphoria.net/code/hindley-milner/HindleyMilner.scala
* Andrew Forrest
*
* Implementation of basic polymorphic type-checking for a simple language.
* Based heavily on Nikita Borisov’s Perl implementation at
* http://web.archive.org/web/20050420002559/www.cs.berkeley.edu/~nikitab/courses/cs263/hm.html
* which in turn is based on the paper by Luca Cardelli at
* http://lucacardelli.name/Papers/BasicTypechecking.pdf
*