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
Greeter = Object.new
class << Greeter
def greet(name)
"HELLO, #{normalize(name)}!"
end
private
def normalize(name)
@booleanbetrayal
booleanbetrayal / Gruntfile.js
Last active November 23, 2024 05:09
Example GruntJS configuration for a replacement to the Sprockets Rails asset pipeline
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var paths = {
-module(chopstick).
-export([start/1, loop/2]).
start(Number) ->
spawn(chopstick, loop, [Number, nobody]).
loop(Number, Owner) ->
receive
{take, Owner} -> loop(Number, Owner);
{take, NewOwner} when Owner =:= nobody ->
# Given a controller that looks like this
class ModelsController < ApplicationController
load_and_authorize_resource #CanCan
def show
if stale? @model
respond_to do |format|
format.json do
@model
end
@meh
meh / lol.exs
Created December 16, 2013 17:29
defmodule Fun do
def arity(fun) do
case :erlang.fun_info(fun, :arity) do
{ :arity, arity } ->
arity
end
end
def adapt!(fun, 0) do
fn -> fun.([]) end
/**
* Multipromise
*
* A jQuery.Deferred() - like promise implementation
* that supports adding multiple child promises to it.
* done / fail callbacks will trigger multiple times as child promises are resolved / rejected
* Useful for streaming promise-based data flows
*
* Example
*
CREATE VIEW product_stats AS
SELECT organization_id,
SUM(CASE WHEN status = 'active' THEN 1 END) active_count,
SUM(CASE WHEN status = 'inactive' THEN 1 END) inactive_count
FROM products
GROUP BY organization_id
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@sgrif
sgrif / gist:7574451
Created November 21, 2013 01:23
Z Combinator in elixir
z = fn
f -> fn
x -> f.(fn y -> x.(x).(y) end)
end.(fn
x -> f.(fn y -> x.(x).(y) end)
end)
end
add_squares = z.(fn
f -> fn
@dfurber
dfurber / ruby_tail_recursion.rb
Last active November 24, 2017 21:39
Experiments in tail recursion with Ruby, implementing group_by, index_by, in_groups_of, and sort_by without iteration or conditionals. Because why not?
items = %w{foo bar baz goo gar gaz hoo har haz}
def recurse_array(ary, &block)
head, *tail = ary
head and block.call(head)
tail.any? and recurse_array(tail, &block)
end
puts "First the items in order:\n"
recurse_array items do |item|