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 / Notes.md
Last active December 7, 2015 22:18
Access docker host from container

Docker host is reachable through the address of the Docker bridge, which happens to be the default gateway for the container.

From the host:

ip addr show docker0

From the container:

ip route show

#!/bin/sh

@cheeyeo
cheeyeo / article.md
Last active May 15, 2016 19:34
ansible layout / structure
@cheeyeo
cheeyeo / README.md
Created October 23, 2015 15:00 — forked from JoelQ/README.md
Using Shell Scripts for a Better User Experience (source for https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts)

Server scripts

This is the source for the scripts discussed in https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts

Both scripts are in the bin/ directory of the repo that contains all the markdown documents for blog posts. Users run bin/server and everything is automatically set up for them to view a local preview of the blog. bin/server-setup is a dependency of bin/server and is never run directly by users.

Maitre-d is the name of the "blog engine" discussed in the article.

@cheeyeo
cheeyeo / optparse-template.rb
Created September 30, 2015 13:33 — forked from rtomayko/optparse-template.rb
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@cheeyeo
cheeyeo / csp.rb
Last active September 19, 2015 20:21
CSP
module GitHub
module CSP
# Public: Constants for CSP keywords
NONE = "'none'".freeze
SELF = "'self'".freeze
UNSAFE_INLINE = "'unsafe-inline'".freeze
UNSAFE_EVAL = "'unsafe-eval'".freeze
# Public: Constants for CSP directive names
BASE_URI = "base-uri".freeze
@cheeyeo
cheeyeo / application.rb
Last active September 16, 2015 23:38
CORS Rails 4+
config.middleware.insert_before 0, "Rack::Cors", debug: true, logger: ->{Rails.logger} do
allow do
origins 'localhost:3000'
resource %r{/users\/?\d*},
:headers => ['Origin', 'Accept', 'Content-Type','Token'],
:methods => [:get, :put, :delete],
:max_age => 0
end
end
@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() {
@cheeyeo
cheeyeo / importer.rb
Last active August 29, 2015 14:27 — forked from yellow5/importer.rb
Ruby spec stubbing a block using mocha
class Importer
def parse_csv_file(csv_file)
File.open(csv_file) do |file|
ActiveRecordModel.transaction do
import_csv_stream(file)
end
end
end
end