Skip to content

Instantly share code, notes, and snippets.

View 178inaba's full-sized avatar
🤔
hello, world

Masahiro Furudate 178inaba

🤔
hello, world
View GitHub Profile
@178inaba
178inaba / hello.java
Last active August 29, 2015 14:19
.javaから.jar、そして実行まで ref: http://qiita.com/inaba178/items/de261b83b378cd63f632
public class hello {
public static void main(String[] args) {
System.out.println("Hello " + args[0]);
}
}
@178inaba
178inaba / search1.go
Last active August 29, 2015 14:19
sort.SearchInts()はSort済みじゃないと動かない ref: http://qiita.com/inaba178/items/795c2e18078c4063a264
package main
import (
"fmt"
"sort"
)
func main() {
a := []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
res := sort.SearchInts(a, 7)
@178inaba
178inaba / file0.go
Created April 24, 2015 18:03
Macだと標準入力の最大文字数は1024文字(?) ref: http://qiita.com/inaba178/items/81ea3c2f763b45e7e3bc
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
package main
import (
"flag"
"fmt"
)
func main() {
fmt.Println("flag.NArg():", flag.NArg())
}
@178inaba
178inaba / collatz.dart
Last active August 29, 2015 14:20
hello worldより「コラッツの問題」書くほうがいろいろ学べそう ref: http://qiita.com/inaba178/items/9dc2026780ca7d148b26
library collatz;
collatz(int n) {
print(n.toString());
if (n > 1) {
if (n % 2 == 1) {
collatz(3 * n + 1);
} else {
collatz((n / 2).round());
@178inaba
178inaba / file0.txt
Created May 16, 2015 16:36
角括弧2個([[ 条件式 ]])の条件式でAND条件「-a」が使えない件(回避方法あり) ref: http://qiita.com/inaba178/items/b02662c3645595659156
$ [[ 11 -eq 11 -a "bb" = "bb" ]]; echo $?
-bash: syntax error in conditional expression
-bash: syntax error near `-a'
@178inaba
178inaba / auto_restart.sh
Last active August 29, 2015 14:21
ディレクトリ/ファイルを監視してsupervisorで再起動(自動化 ref: http://qiita.com/inaba178/items/f2599b75816f8b779043
#!/bin/sh
if [[ $# -ne 3 ]] ; then
echo argument is invalid.
exit
fi
while :
do
after=`ls -l $1`
if [[ $after != $before && $before != "" ]] ; then
@178inaba
178inaba / file1.txt
Last active August 29, 2015 14:24
シェルスクリプト変数のホームディレクトリ展開 ref: http://qiita.com/inaba178/items/3027defbc2aabaefab84
$ sh var.sh
A=/Users/user_name/.get
B=~/.get
C=~/.get
D=/Users/user_name/.get
E=$HOME/.get
@178inaba
178inaba / env.go
Created August 5, 2015 07:41
getenv to home from go
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Getenv("HOME"))
}
@178inaba
178inaba / increment.go
Last active August 29, 2015 14:26
go is can not increment the array subscript
package main
import "fmt"
func main() {
var a [10]int
for i := 0; i < 10; {
//a[i++] = 1
a[i] = 1