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
@jhihn
jhihn / tokenizer_serialization.py
Last active April 20, 2020 00:21
Keras Tokenizer Gist
# Keras tokenizer lacks serialization. Therefore I created the below to address this without changing the API.
# (Since I don't know how long it'll take for keras to support it)
# The Tokenizer __init__ should be modified to take the word_stats dictionary as a kwarg,
# and a method added to the class to return the stats
# Expiermentally this works, but I am not sure of any nuances in the Tokenizer class.
def test_tokenizer():
texts = ["It was the best of times, it was the worst of times, it was the age of wisdom",
"it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, ",
"it was the season of Light, it was the season of Darkness, it was the spring of hope, ",
@cheeyeo
cheeyeo / Enhance.js
Last active September 15, 2015 11:56 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@AllThingsSmitty
AllThingsSmitty / wrap.js
Created June 19, 2015 12:51
Great way to wrap non-React UI elements that manage lists of items and leverage VDOM diffing
const SourceElement = React.createClass({
componentDidMount: f() {
this.props.view.addSource(this.props.source);
},
componentWillUnumount: f() {
this.props.view.removeSource(this.props.source);
},
componentWillReceiveProps: f(nextProps) {
@brianhempel
brianhempel / enumerator_to_json.rb
Created February 17, 2015 17:32
Lazily convert an Enumerator or Enumerator::Lazy to a JSON array. Save as config/initializers/enumerator_to_json.rb
# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem.
# We want them to make an array, and do it lazily so we don't have to keep the items in memory!
class Enumerator
def to_json(state)
state.depth += 1
string = "[\n"
first_item = true
self.each do |item|
@rob-brown
rob-brown / mastermind.ex
Last active August 15, 2022 08:43
A Mastermind game implemented in Elixir.
defmodule Mastermind do
defstruct rounds: 10, choices: 6, answer: nil, guesses: []
def start, do: game_loop %Mastermind{}
defp game_loop(game = %Mastermind{answer: nil}) do
game
|> start_computer_mastermind
|> game_loop
@rhuss
rhuss / docker-enter.sh
Last active August 29, 2015 14:05
nsenter with boot2docker
#!/bin/sh
usage ()
{
cat <<EOF
docker-enter -- Enter a running container via boot2docker and nsenter
Usage: docker-enter <container_name_or_ID> [command]
See https://github.com/jpetazzo/nsenter for details.
defmodule FizzBuzz do
@doc """
Given a range, returns an array of values conforming to the FizzBuzz pattern.
## Example
FizzBuzz.calculate 1..15
-> 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
"""
def calculate(range) do
defmodule ReversingPlug do
use Plug.Builder
import Plug.Conn
plug :hello
plug :reverse
plug :sender
def hello(conn, _opts) do
%Plug.Conn{conn | resp_body: "Hello world"}
@cheeaun
cheeaun / rdrc2014.md
Last active August 29, 2015 14:03
RedDotRubyConf 2014 links & resources