Skip to content

Instantly share code, notes, and snippets.

@yatsu
yatsu / pyenv-python38-macos.sh
Created January 2, 2021 11:35
Install Python 3.8.6 with pyenv on macOS Big Sur (11)
#!/bin/sh
# 1) Install Xcode 12
# 2) Install command line tools: `xcode-select --install`
# 3) Install Homebrew
# 4) brew install zlib bzip2 xz
CFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix xz)/include" \
LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib -L$(brew --prefix xz)/lib" \
pyenv install 3.8.6
@yatsu
yatsu / numpy-openblas-macos-pip.sh
Created April 5, 2020 10:31
Install numpy with enabling openblas using pip on macOS
# Setup HomeBrew: https://brew.sh/
brew install openblas
pip download --no-binary :all: --no-deps numpy
unzip numpy-1.18.2.zip # (you may have newer version)
cd numpy-1.18.2
cat > site.cfg <<EOF
[openblas]
libraries = openblas
library_dirs = $(brew --prefix openblas)/lib
@yatsu
yatsu / deep_merge.py
Created April 28, 2018 13:43
Python dict deep merge
from copy import deepcopy
from functools import reduce
def deep_merge(*dicts, update=False):
"""
Merges dicts deeply.
Parameters
----------
@yatsu
yatsu / rbenv-ruby187-macos.sh
Last active July 13, 2023 19:36
Install ruby-1.8.7 with rbenv on macOS Catalina (10.15)
#!/bin/sh
# 1) Install Xcode 11
# 2) Install command line tools: `xcode-select --install`
# 3) Install HomeBrew
# 4) brew tap cartr/qt4 && brew install cartr/qt4/[email protected] subversion rbenv
# 5) Setup rbenv
# 6) Run this command
PKG_CONFIG_PATH="$(brew --prefix cartr/qt4/[email protected])/lib/pkgconfig" \
@yatsu
yatsu / javascript.snip
Last active April 24, 2021 10:22
neosnippet snippets for React/Redux
snippet pd
abbr preventDefault()
options word
preventDefault()
snippet render
abbr render() {...}
options head
render() {
return (
@yatsu
yatsu / countdown.sh
Last active January 4, 2017 14:45
Read tornado.process.Subprocess stdout
#!/bin/bash
sleep_sec=0
usage() {
echo "Usage: $0 [-s sleep_sec] <num>"
}
while getopts :s:h OPT; do
case $OPT in
from glob import glob
import os
import sys
os.environ['SPARK_HOME'] = 'C:\\Users\\MyName\\Documents\\spark-1.4.0-bin-hadoop2.6'
spark_home = os.environ.get('SPARK_HOME')
pyspark_path = os.path.join(spark_home, 'python')
sys.path.insert(0, pyspark_path)
for z in glob(os.path.join(pyspark_path, 'lib', 'py4j*.zip')):
sys.path.insert(0, z)
@yatsu
yatsu / doorkeeper.rb
Created July 13, 2012 19:02
Doorkeeper setting with User model and AdminUser model using Devise
Doorkeeper.configure do
resource_owner_authenticator do |routes|
current_user || warden.authenticate!(:scope => :user) # Devise
end
admin_authenticator do |routes|
authenticate_admin_user!
end
use_refresh_token
/* This is a template command */
CmdUtils.CreateCommand({
names: [ "markdown-copy" ],
homepage: "http://ubiquity.s21g.com/296703",
author: { name: "Masaki Yatsu", email: "[email protected]"},
license: "MIT",
description: "Copy url, title and selected text in Markdown format",
help: "Copy url, title and selected text in Markdown format",
arguments: [{ role: 'object', nountype: noun_arb_text, label: 'text' }],