Skip to content

Instantly share code, notes, and snippets.

@zmoazeni
zmoazeni / gist:4b2b51f4315f325ca6cc
Last active August 29, 2015 14:10
Implicit key names - apparently ES6 can do this in vanilla javascript too
# this coffescript
some_object = { 'foo', 'bar' }
// generates this javascript
some_object = {
'foo': 'foo',
'bar': 'bar'
};
@zmoazeni
zmoazeni / 1-jruby.txt
Created December 23, 2013 03:35
csscss v1.3.2 performance between different ruby platforms
jruby-1.7.8 ~/projects/csscss-rb (master) ∴ time JAVA_OPTS='-Xms2g -Xmx2g' csscss -n 5 https://cache.harvestapp.com/assets/screen.css > /dev/null
real 0m34.301s
user 0m55.226s
sys 0m1.519s
jruby-1.7.8 ~/projects/csscss-rb (master) ∴ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
@zmoazeni
zmoazeni / 1-bundler.md
Created December 12, 2013 21:08
Bundler and Node pessimistic operator differences
# in ./config/spring.rb (or ~/.spring.rb)
module Spring
module Commands
class M
def env(*)
"test"
end
def exec_name
"m"
package parsing
import scala.util.parsing.combinator._
object CSS extends RegexParsers {
sealed abstract class CSSTerms
case class Declaration(property:String, value:String) extends CSSTerms
case class Ruleset(selector:String, declarations:List[Declaration]) extends CSSTerms
@zmoazeni
zmoazeni / Arith.scala
Created May 28, 2013 23:23
I'm learning Scala, so I toyed around with the built in parsing libraries
package parsing
import scala.util.parsing.combinator._
object Arith extends JavaTokenParsers {
def expr: Parser[Double] = term ~ rep("+"~term | "-"~term) ^^ {
case term ~ list => (term /: list) {
case (x, "+" ~ y) => x + y
case (x, "-" ~ y) => x - y
}
{-# LANGUAGE OverloadedStrings #-}
module Development.CSSCSS.RedundancyCalc where
import Data.Text (Text)
import Data.List
import Data.Map (fromListWith, toList)
import Development.CSSCSS.Rulesets
@zmoazeni
zmoazeni / check_various_indexes.rb
Created March 19, 2013 23:08
input_one_unicode_rest_ascii.css has an "em dash" in the first line, the String#index performance differs dramatically between the two. ~1.5sec for input_only_ascii.css and ~30sec for input_one_unicode_rest_ascii.css on my machine with 1.9.3-p385
#! /usr/bin/env ruby
raise "need a file name" unless ARGV[0]
contents = File.read(ARGV[0])
326_000.times do |i|
contents[(i + 23) % contents.size]
end
data LengthUnit = PX | EM | EX | EN
deriving (Eq, Show, Ord)
data HorizontalPoint = LeftPoint | RightPoint | HorizontalCenter
deriving (Eq, Show, Ord)
data VerticalPoint = TopPoint | BottomPoint | VerticalCenter
deriving (Eq, Show, Ord)
data Length = Percent Number | Length {getLength :: Number, getLengthUnit :: LengthUnit}
bg :: Parser Background
bg = do color <- try bgColor
image <- try bgImage
return $ Background color image