Skip to content

Instantly share code, notes, and snippets.

View vochicong's full-sized avatar
🐒
NLP/ML/AI

Cong vochicong

🐒
NLP/ML/AI
View GitHub Profile
@vochicong
vochicong / file0.txt
Last active March 23, 2019 15:57
brew bundleでMacのアプリをまとめてインストール・管理 ref: https://qiita.com/vochicong/items/f20afc89a6847cd58f0f
# Brewfile
cask_args appdir: "/Applications"
tap "caskroom/cask"
tap "homebrew/bundle"
tap "homebrew/core"
cask "google-chrome"
cask "slack"
cask "github"
brew "git"
@vochicong
vochicong / after_rubo51.rb
Last active December 31, 2017 07:13
rubocop 0.51のStyle/SafeNavigation (&.)の重大バグ ref: https://qiita.com/vochicong/items/8f21d6045fab0d87f4fe
# rubocop v0.51 の変換結果、正しい
if user&.group&.admin?
puts 'userが管理者です'
else
puts 'userがnilか、管理者ではないです'
end
# rubocop v0.51は以下の様に間違って変換
if !user&.group&.admin?
puts 'userが普通ユーザです'
# File: config/initializers/params_snakeizer.rb
# Transform JSON request param keys from JSON-conventional camelCase to
# Rails-conventional snake_case
module ActionController
# Modified from action_controller/metal/strong_parameters.rb
class Parameters
def deep_snakeize!
@parameters.deep_transform_keys!(&:underscore)
self
end
@vochicong
vochicong / BleakWanZebrafinch.rb
Created December 9, 2017 05:38
BleakWanZebrafinch created by anonymous - https://repl.it/repls/BleakWanZebrafinch
3 <=> 4
3 > 4
Class Steak
include Comparable
attr_accessor grade
GRADES = { prime: 1, choice: 2, select: 3 }
def <=>(other)
@vochicong
vochicong / gist:eff000b99a8d8667c2d5c6007daa8cc1
Created October 1, 2017 12:15
Update to macOS High Sierra
macOS High Sierra
https://www.apple.com/jp/macos/high-sierra/
Xcode 9
https://developer.apple.com/download/
xcode-select --install
brew upgrade
@vochicong
vochicong / extract_json_from_csv.sh
Created September 12, 2017 05:50
jq to extract a json value from CSV
# Input: 901,1,187,7,1,example@gmail.com,"{""u"":""name"",""limit_date"":""2017/09/18 23:59"",""token"":""b0kasdfuadf3jdadfubd"",""language"":""ja""}",9/12/17 9:01,NULL,NULL,NULL,9/11/17 15:59,9/11/17 16:00,NULL
# Output: b0kasdfuadf3jdadfubd
cat token_lists.csv | jq -R 'split(",") | .[8] | split("\"") | .[6]' | sed 's/"//g'
@vochicong
vochicong / gem-rmagic-mac.sh
Created September 4, 2017 04:46
install rmagic on mac
brew install imagemagick@6
export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"
export LDFLAGS=-L/usr/local/opt/imagemagick@6/lib:$LDFLAGS
export CPPFLAGS=-I/usr/local/opt/imagemagick@6/include:$CPPFLAGS
export PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig:$PKG_CONFIG_PATH
gem install rmagic
# https://stackoverflow.com/questions/10063051/bundle-cant-install-rmagick-gem-on-mac-osx-10-7

Reset MySQL root password on Mac

On Terminal 1

mysql.server stop
mysqld_safe --skip-grant-tables

On Terminal 2

@vochicong
vochicong / mysql_macosx.md
Created August 10, 2017 00:05 — forked from jnoss/mysql_macosx.md
mysql on mac osx

Install and run mysql on mac os x

Instructions for installing mysql on mac os x via homebrew (a command line package manager for mac)

Install brew

Follow installation instructions at https://brew.sh/

Install mysql