Skip to content

Instantly share code, notes, and snippets.

View cheeyeo's full-sized avatar
💭
Researching on use of transformers in computer vision

Chee Yeo cheeyeo

💭
Researching on use of transformers in computer vision
View GitHub Profile
@cheeyeo
cheeyeo / samples.exs
Last active August 29, 2015 14:05
Try elixir code samples
# Expressions
iex> 40 + 2
iex> "hello" <> " world"
#Basic types
iex> 1 # integer
iex> 0x1F # integer
iex> 1.0 # float
iex> :atom # atom / symbol
iex> "elixir" # string
@cheeyeo
cheeyeo / websockets_raw.ex
Created August 4, 2014 19:05
Raw websockets in elixir
# You can wire up a cowboy specific websocket handler with the following:
defmodule MyRouter do
use Phoenix.Router
dispatch_option "/ws", MyCowboyWebsocketHandler
end
defmodule MyCowboyWebsocketHandler do
@behaviour :cowboy_websocket_handler
class Hash
# Returns a new hash with the results of running +block+ once for every value.
# The keys are unchanged.
#
# { a: 1, b: 2, c: 3 }.transform_values { |x| x * 2 }
# # => { a: 2, b: 4, c: 6 }
def transform_values
result = self.class.new
each do |key, value|
result[key] = yield(value)
@cheeyeo
cheeyeo / gist:33e9c62a31f76d67a774
Created July 7, 2014 20:11
Google web fundamentals
https://developers.google.com/web/fundamentals/performance/
http://chimera.labs.oreilly.com/books/1230000000545/ch11.html#RESOURCE_INLINING
@cheeyeo
cheeyeo / gist:34ebefb10c001c28c3ec
Created July 5, 2014 17:44
Critical Render Path CRP

Steps to render a page:

  • browser reads html text as it's received and the tokeniser converts elements into tokens.
  • tokens are parsed to create DOM nodes
  • this process is incremental, meaning that the browser can start creating the DOM before it's received all of the html document.

once all of the css has been received, the css text is tokenised, and then these tokens converted into css object nodes, creating the CSSOM (CSS Object Model). unlike html, because later css can affect that defined earlier, css can't begin to be parsed until all of it is available. Thus css downloading blocks rendering Once the DOM and CSSOM are available, the browser puts them together to create the render tree.

  • the render tree only describes visible content.
  • the render tree enables the browser to calculate where elements should sit on the page, ie the layout
@cheeyeo
cheeyeo / sse.go
Created July 4, 2014 20:59 — forked from ismasan/sse.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// Example SSE server in Golang.
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
}
@cheeyeo
cheeyeo / example.rb
Last active August 29, 2015 14:02
Conversion Ratio
class Quantity
include Comparable
CoercedNumber = Struct.new(:value) do
def +(other) raise TypeError; end
def -(other) raise TypeError; end
def *(other)
other * value
end
def /(other) raise TypeError; end
@cheeyeo
cheeyeo / sse.go
Created June 24, 2014 19:47 — forked from ismasan/sse.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// Example SSE server in Golang.
@cheeyeo
cheeyeo / spec.rb
Created June 18, 2014 16:34
RSPEC Shared examples
shared_examples "collections" do
it "is empty when first created" do
expect(described_class.new).to be_empty
end
end
describe Array do
include_examples "collections", Array
end