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
@shockalotti
shockalotti / Go Golang - recursive function, fibonacci sequence
Created May 28, 2014 03:03
Go Golang - recursive function, fibonacci sequence
package main
import "fmt"
func fib(n uint) uint {
if n == 0 {
return 0
} else if n == 1 {
return 1
} else {
@jameslafa
jameslafa / mixpanel.coffee
Last active December 21, 2015 06:38
AngularJS MixPanel mock for testing
/*
* author: @jameslafa
* More details on http://blog.james-lafa.fr/angularjs-how-to-mock-mixpanel-inside-for-your-tests/
*/
class MixpanelMock
debug = false
log: (event, data) ->
if @debug
require 'csv'
def memstats
size = `ps -o size= #{$$}`.strip.to_i
end
memstats #4900
CSV.open('visitors.csv', headers: true) do |csv|
visitors = csv.each # Enumerator
memstats # 5164
@dch
dch / sha.erl
Created May 18, 2014 23:33
erlang quick conversion of binary sha hash to printable hex/ascii
(akai@akai)27> Hex=fun(<<Hash:20/big-unsigned-integer-unit:8>>) ->
lists:flatten(io_lib:format("~40.16.0b", [Hash])) end.
#Fun<erl_eval.6.106461118>
(akai@akai)28> Hex(<<200,152,0,191,200,46,208,30,214,227,191,213,64,140,81,39,68,145,247,212>>).
"c89800bfc82ed01ed6e3bfd5408c51274491f7d4"
(akai@akai)29>
@ismasan
ismasan / sse.go
Last active February 27, 2025 00:15
Example SSE server in Golang
// Copyright (c) 2017 Ismael Celis
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
MODES = { "0" => "---",
"1" => "--x",
"2" => "-w-",
"3" => "-wx",
"4" => "r--",
"5" => "r-x",
"6" => "rw-",
"7" => "rwx" }
def permissions(num)
@tadast
tadast / ssl_puma.sh
Last active January 21, 2025 16:20 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@mattbrictson
mattbrictson / application.html.erb
Last active February 23, 2025 03:58
Simpler nested layouts in Rails using the parent_layout helper
<%= render("shared/navbar") %>
<div class="container">
<%= render("shared/alerts") %>
<%= render("shared/page_header") %>
<%= yield %>
<%= render("shared/footer") %>
@justinweiss
justinweiss / filterable.rb
Last active January 30, 2025 13:06
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
Start every day coding, end every day thinking.
1. Warmup exercise (30 mins)
Make sure to have these ready the night before, pick stuff
that you can work on right away without having to study
in advance.
They can either be book exercises or stuff
from other sources, but they should be self-verifiable