Skip to content

Instantly share code, notes, and snippets.

View fukaoi's full-sized avatar
:octocat:
deep dive in codes

fukaoi fukaoi

:octocat:
deep dive in codes
View GitHub Profile
@fukaoi
fukaoi / fibonacci.rb
Created January 31, 2014 08:37
Fibonacci ruby
#recurcive pattern, to sum
one = 1; two = 1
10.times do |i|
if i <= 1; calc = one
else
calc = one + two
one, two = two, calc
end
p calc
end
@fukaoi
fukaoi / gist:426856f4fca63c86a947
Created April 27, 2015 13:47
Use closure of stored dictionary data
import UIKit
class Demo: NSObject {
func clojure() -> (index:Int) -> Dictionary<Int, Int> {
var dict = [:] as Dictionary<Int, Int>
var r = { (index:Int) -> Dictionary<Int, Int> in
dict[index] = index * 10
return dict
}
return r
@fukaoi
fukaoi / clean-docker-container.s
Created January 18, 2018 01:25
All delete container files
#!/bin/bash
docker ps -a | awk '/[a-z0-9]+/ {print $1}' | xargs docker rm -f
@fukaoi
fukaoi / clean-docker-image.sh
Last active January 18, 2018 01:27
All delete docker images
#!/bin/bash
docker images | awk '/[a-z0-9]+/ {print }' | xargs docker rmi -f
@fukaoi
fukaoi / wifi-resume.service
Last active January 28, 2018 07:25
wifi resume scrypt in especially suspend and logout
# /etc/systemd/system/wifi-resume.service
# sudo systemctl enable wifi-resume.service
# [checking]systemctl list-unit-files -t service | grep wifi
[Unit]
Description=Restart networkmanager at resume
After=logout.target
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
# english/japanese dictionary
function dict() {
grep $1 $HOME/Documents/gene-utf8.txt -A 1 -wi --color
}
# Fix code when logout, suspend, dont work wifi
#sudo -s service network-manager restart
# get global ip
function gip() {
@fukaoi
fukaoi / apt installed package
Created February 4, 2018 06:03
Collect ubuntu installed package
sudo apt list --installed | grep -o -E "([a-z.0-9-]+)/" | grep -o -E "9-]+" | perl -pe 's/\n/ /g'
@fukaoi
fukaoi / Xmodmap
Created April 29, 2018 23:02
Xmodmap
remove mod1 = Alt_L Alt_R
keycode 64 = Zenkaku_Hankaku Kanji
keycode 108 = Zenkaku_Hankaku Kanji
@fukaoi
fukaoi / aws_cloudwatch_put_log.sh
Created June 9, 2018 15:29
Put cutom log on aws cloudwatch
#!/bin/bash
DATE=`date "+%s"`
echo $DATE
DATE2=$(($DATE*2))
echo $DATE2
aws logs put-log-events --log-group-name scorpio --log-stream-name app --log-events timestamp=$DATE2,message="Test event 1" --sequence-token $1
@fukaoi
fukaoi / adaptor.cr
Last active June 11, 2018 13:52
Adapter pattern in crystal-lang
class Demo
@obj: Coin
def initialize(name : String)
if name == "LTC"
@obj = LTC.new
elsif name == "ETH"
@obj = ETH.new
else
raise "Not found name"
end