This file contains 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
# -*- coding: utf-8 -*- | |
class deep_dict(dict): | |
def __init__(self, value=None): | |
if isinstance(value, dict): | |
for key in value: | |
self.__setitem__( | |
key, | |
deep_dict(value[key]) if isinstance(value[key], dict) else value[key] | |
) | |
else: |
This file contains 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" | |
"math" | |
) | |
const MAX_DELTA = 0.01 | |
func isEnough(d float64) bool { |
This file contains 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 "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
slice := make([][]uint8, dy) | |
for iy := range slice { | |
slice[iy] = make([]uint8, dx) | |
for ix := range slice { |
This file contains 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" | |
// fibonacci is a function that returns | |
// a function that returns an int. | |
func fibonacci() func() int { | |
x, y := 0, 1 | |
return func() int { | |
new := x + y |
This file contains 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" | |
"log" | |
"net/http" | |
) | |
type String string |
This file contains 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 ( | |
"code.google.com/p/go-tour/tree" | |
"fmt" | |
"reflect" | |
) | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. |
This file contains 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
{{deck}} | |
{{#each cards}} | |
{{#each brothers}} | |
{{> tmpl bro=this card=parentHelper deck=parentHelper.parentHelper.deck}} | |
{{/each}} | |
{{/each}} |
This file contains 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 | |
set -e | |
FROM=/home/media/Downloads/complete | |
TO=/home/media/Video | |
for file in $FROM/*; do | |
echo "Where move file :$file" | |
select item in Shows Films Skip; do | |
case "$item" in |
This file contains 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
# -*- coding: utf-8 -*- | |
import re | |
def count_substrings_re(string, substring): | |
substring_re = '(?=(%s))' % re.escape(substring) | |
return len(re.findall(substring_re, string)) | |
def count_substrings(s, f): | |
ind = 1 | |
count = 0 |
This file contains 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
for i in `env`; do | |
key=${i%=*} | |
[[ -z $short_env ]] && short_env=$key; | |
[[ ${#key} -lt ${#short_env} ]] && short_env=$key; | |
done | |
echo "Shortest env variable: $short_env" |
OlderNewer