This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> 1.upto(Float::INFINITY).lazy. | |
irb(main):002:0* map { |x| puts "1 #{x}"; x * x }. | |
irb(main):003:0* map { |x| puts "2 #{x}"; x + 1 }. | |
irb(main):004:0* take(10).to_a | |
1 1 | |
2 1 | |
1 2 | |
2 4 | |
1 3 | |
2 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pods=($(kubectl get po | grep -E 'api|db' | awk '{print $1}')) | |
for var in "${pods[@]}" | |
do | |
case "$var" in | |
*api*) | |
api_cmd="kubectl port-forward $var 3000:3000" | |
;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func updateAll(ids []string) { | |
var params []string | |
var values []interface{} | |
for k, v := range ids { | |
params = append(params, fmt.Sprintf("$%d", k+1)) | |
values = append(values, v) | |
} | |
db := viper.Get("db").(*gorp.DbMap) | |
sql := "UPDATE stores SET active = false WHERE id IN (" + strings.Join(params, ",") + ")" | |
rs, err := db.Exec(sql, values...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BaseError ... | |
type BaseError struct { | |
s string | |
} | |
func (e *BaseError) Error() string { | |
return e.s | |
} | |
// SomeError ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$DECLARE quantity integer := 1; maxid integer; cnt integer; total integer := 0; | |
BEGIN | |
SELECT max(id) INTO maxid FROM google_places; | |
maxid := maxid + 10; | |
RAISE NOTICE 'maxid: %', maxid; | |
LOOP | |
UPDATE some_table t1 | |
SET some_column = ... | |
FROM another_table t2 | |
WHERE ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type A struct { | |
S1 string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"testing" | |
) | |
func BenchmarkAppendFloat(b *testing.B) { | |
benchmarks := []int{10, 100, 1000, 10000, 1e5} | |
for _, bm := range benchmarks { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://play.golang.org/p/CpPW7CxYBV | |
package main | |
import ( | |
"fmt" | |
) | |
type A struct { | |
X string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix keyboard | |
echo 0 > /sys/module/hid_apple/parameters/iso_layout | |
# prevent wakeup from usb | |
echo XHC1 > /proc/acpi/wakeup | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type A struct{} | |
func (A) hi() string { | |
return "hi A" |