Skip to content

Instantly share code, notes, and snippets.

View vtno's full-sized avatar
👾
building

Tino Thamjarat vtno

👾
building
View GitHub Profile
@vtno
vtno / temp.js
Created February 22, 2018 04:44
searchBox.addListener('places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
var geometries = places.map(function(place) {
return place.geometry
});
@vtno
vtno / bx_port_calculation.rb
Last active December 21, 2017 05:27
(WIP) Calculate realized profit and some other values from BX transaction csv
# Run it like this in shell
#
# PATH_TO_REPORT=xxx/bx-999999.csv bx_port_calculation
#
# Notes:
# - PATH_TO_REPORT is relative to your home directory.
# - Change currencies to match your portfolio
# - WIP so it's probably need more work.
require 'csv'
@vtno
vtno / .vimrc
Created November 8, 2017 14:00
My vimrc
set nocompatible " be iMproved, required
filetype off " required
syntax on
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
set runtimepath^=~/.vim/bundle/ctrlp.vim
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@vtno
vtno / .zshrc
Created November 8, 2017 13:15
MY zsh config
autoload -U promptinit; promptinit
prompt pure
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
eval "$(rbenv init -)"
eval "$(pyenv init -)"
# Path to your oh-my-zsh installation.
export ZSH=/Users/vtno/.oh-my-zsh
export PATH="$HOME/.Pokemon-Terminal:${PATH}"
@vtno
vtno / circle.yml
Created November 2, 2017 09:17
My CircleCI 1.0 configuration to enable Chrome headless.
dependencies:
pre:
# install chrome
- wget -N https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P ~/
- sudo dpkg -i --force-depends ~/google-chrome-stable_current_amd64.deb
- sudo apt-get -f install -y
- sudo dpkg -i --force-depends ~/google-chrome-stable_current_amd64.deb
- sudo rm /usr/local/bin/chromedriver
# install chromedriver
- wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/
@vtno
vtno / capybara.rb
Created November 2, 2017 09:05
My capybara configuration with headless_chrome
# frozen_string_literal: true
require 'capybara/rspec'
IS_DEBUG_MODE = -> { ENV['DEBUG'].present? ? :chrome : :headless_chrome }
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
@vtno
vtno / atom-stylesheet
Created September 13, 2017 02:31
My atom stylesheet
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/
@vtno
vtno / preciseMath.js
Last active August 22, 2017 05:13
handle floating point annoying operation
const preciseOperation = f => (a, b, decimalDigits) => {
decimalDigits = decimalDigits || 12
+(f(a, b)).toFixed(decimalDigits)
}
const add = (a, b) => a + b
const minus = (a, b) => a - b
const multiply = (a, b) => a * b
const divide = (a, b) => a / b
export const preciseAdd = (a, b, decimalDigits) => preciseOperation(add)(a,b, decimalDigits)
export const preciseMinus = (a, b, decimalDigits) => preciseOperation(minus)(a,b, decimalDigits)
@vtno
vtno / functional_cart.rb
Last active July 14, 2017 11:39
My attempt on mixing functional programming and good ol' OO in Ruby.
Item = Struct.new(:amount, :price, :name) do
def total_price
amount * price
end
end
Cart = Struct.new(:items) do
# total amount is finding sum of item amount
def total_amount
# a.k.a finding sum by item.amount function
@vtno
vtno / parameterized_working_example.rb
Created July 13, 2017 05:09
This accept values for 2 reports and then calculate weight average by sale revenue of gross profit and cogs of those reports.
# frozen_string_literal: true
Report = Struct.new(:sale_revenue, :gross_profit, :cogs)
def main
puts '## First report ##'
puts 'Input revenue: '
revenue1 = gets.chomp.to_f
puts 'Input gross profit: '
gp1 = gets.chomp.to_f