Skip to content

Instantly share code, notes, and snippets.

@leikind
leikind / SignalOfRandomNum.elm
Created December 15, 2015 20:19
A signal of random numbers every second where the first seed is a timestamp
module SignalOfRandomNum where
import Graphics.Element as GE
import Time
import Random
import Maybe exposing (..)
randomIntSignal : Int -> Int -> Signal Time.Time -> Signal Int
randomIntSignal lo hi inputSignal =
let
@leikind
leikind / day1.elm
Last active December 6, 2015 12:28
module Day1 where
import Graphics.Element as G
import String
import List
import Maybe exposing ( Maybe(..) )
instructions =
"(((())))()((((((((())()(()))(()((((()(()(((()((()((()(()()()()()))(((()(()((((((((((())(()()((())()(((())))()(()(()((()(()))(()()()()((()((()(((()()(((((((()()())()((((()()(((((()(())()(())((())()()))()(((((((())(()())(()(((())(()))((())))(()((()())))()())((((())))(()(((((()(())(((()()((()((()((((((((((())(()())))))()))())()()((((()()()()()()((((((())())(((()())()((()()(((()()()))(((((()))(((()(()()()(()(()(((())()))(()(((()((())()(()())())))((()()()(()()(((()))(((()((((()(((((()()(()())((()())())(()((((((()(()()))((((()))))())((())()()((()(()))))((((((((()))(()()(((())())(())()((()()()()((()((()((()()(((())))(()((())()((((((((()((()(()()(((())())())))(())())))()((((()))))))())))()()))()())((()())()((()()()))(()()(((()(())((((())())((((((((()()()()())))()()()((((()()))))))()((((()(((()))(()()())))((()()(((()))()()())())(((())((()()(())()()()(((())))))()())((()))()))((())()()())()())

Instead of implementing its own asset pipeline Phoenix uses Brunch, a fast and developer-friendly asset build tool. Phoenix comes with a default configuration for Brunch and it will work out of the box, but it is very easy to bend it to our needs, add support for various script and style languages, like CoffeeScript, JSX, or LESS.

Brunch has a very good tutorial, but this short guide should be enough to get us started with asset management from the Phoenix perspective.

Installation

Brunch is a Node.js application. A newly generated Phoenix project contains package.json which lists packages for installation with npm, the Node Package Manager . If we agree to install dependencies when running mix phoenix.new, Phoenix will run npm for us. If we don't, or if we change package.json, we can always do this ourselves:

@leikind
leikind / expand.ex
Last active August 29, 2015 14:18
Macro.expand and Macro.expand_once
defmodule UselessMacros do
defmacro bar(42) do
quote do
"the answer"
end
end
defmacro baz(42) do
quote do
@leikind
leikind / WiceGrid version 0.5.md
Last active August 29, 2015 14:12
WiceGrid version 0.5

OCTOBER 18, 2009

Today WiceGrid has reached the next level of maturity and was awarded the tag of version 0.5.

This version of WiceGrid is accompanied by an application called WiceGrid Examples running online and with source code available on GitHub.

Here's a list of changes as compared with version 0.4:

selected_records

@leikind
leikind / Moving to Ruby 1.9.1.md
Last active August 29, 2015 14:12
Moving to Ruby 1.9.1

FEBRUARY 28, 2010

Ruby 1.9.1 was released more than a year ago, but the migration to it has been slow. Looking forward to using the new Fiber class(1, 2), sexier functional syntax, and, of course, enjoying the speed, I decided to move a Rails app that I had started recently, to 1.9.1.

Here are a few tips:

Before you start, consider using Ruby Version Manager (RVM) to manage your Rubies and gems. RVM allows to quickly switch between various Ruby implementations (including such exotic implementations as MagLev), keeping a separate gem set for each interpreter. It even allows you to create your own named gem sets (per project, for example), which I find a very cool feature. If you use Mysql, follow the instruction on how to compile the Mysql gem here: [http://rvm.beginrescueend.com/integration/databases/](http://rvm.beginrescueend.com/integration/d

@leikind
leikind / WiceGrid and with_scope.md
Last active August 29, 2015 14:12
WiceGrid and with_scope

NOVEMBER 15, 2009

Methods with_scope and with_exclusive_scope in ActiveRecord scope parameters to method calls within the block. They can be nested, and when with_scope blocks are nested, the scope of the inner block is the merge of all the parent scopes:

class Task < ActiveRecord::Base
  class << self 
  
    def foo
@leikind
leikind / Errors and processes in erlang.md
Last active August 29, 2015 14:12
Errors and processes in erlang

DECEMBER 30, 2011

Previous posts about http://learnyousomeerlang.com: Dog FSM, Cat FSM.

Chapter Errors And Processes is closer to the beginning of the book and deals with core Erlang concepts: error propagation and error trapping.

First off, here is what I wrote to better understand the section that starts with words "the results of uncaught throws, errors and exits in neighboring processes":

leikind/1541608