d=2015-12-31
while [ "$d" != 2017-01-01 ]; do
echo $d
d=$(date -I -d "$d + 1 day")
done
# pyhton 2
python -c "import json, urllib2;\
print json.load(urllib2.urlopen('https://www.howsmyssl.com/a/check'))['tls_version']"
# pyhton 3
python3 -c "import json, urllib.request;\
print(json.loads(urllib.request.urlopen('https://www.howsmyssl.com/a/check').read().decode('UTF-8'))['tls_version'])"
>>> from OpenSSL import SSL
print(SSL.OPENSSL_VERSION_NUMBER)
def example = 2 // evaluated when called
val example = 2 //evaluated immediately
lazy val example = 2 //evaluated once when needed
def square(x: Double) // call by value def square(x: => Double) // call by name def myFct(bindings: Int*) = { ... } // bindings is a sequence of int,
// containing a varying # of arguments
val list: List[Int] = List(1, 2, 3, 4, 5)list.fold(0)(_ + _) // op function takes 2 Int and returns sum(Int)// possible orders of parallel execution for fold0 + 1 = 1 0 + 2 = 2 0 + 4 = 4 // 1st parallel operation1 2 + 3 = 5 4 + 5 = 9 // 2nd parallel operation1 5 + 9 = 141 + 14 = 15
val list: List[Int] = List(1, 2, 3, 4, 5)list.foldLeft(0)(_ + _)// Only possible iteration sequence0 + 1 = 11 + 2 = 33 + 3 = 66 + 4 = 1010 + 5 = 15
val list: List[Int] = List(1, 2, 3, 4, 5)list.foldRight(0)(_ + _)// Only possible iteration sequence, Reverse access to elements0 + 5 = 55 + 4 = 99 + 3 = 1212 + 2 = 1414 + 1 = 15
print datetime.datetime.strptime(ts[:-6],'%Y-%m-%dT%H:%M:%S')+\ datetime.timedelta(hours=int(ts[-5:-3]), minutes=int(ts[-2:]))*int(ts[-6:-5]+'1')
type("text")
>> <type 'str'>
type(u"text")
>> <type 'unicode'>
//below is just a declaration of a map pointer holder, no map object is instantiatedvar dat map[string]string //Now unmarshall the byte array into assign the map object to the pointer in second argumentif err := json.Unmarshal(body,&dat); err != nil { panic(err) } fmt.Println(dat)
fmt.Printf("%s\n",body)
buff := bytes.NewBuffer(body) fmt.Println(buff.String())
:= short assignment statement can be used in place of a var declaration with implicit type.func Reverse(s string) string {r := []rune(s)for i,j := 0,len(r)-1 ; i < len(r)/2 ; i,j=i+1,j-1 {r[i],r[j] = r[j],r[i]}return string(r)}
package main
import "fmt"
func main() {
fmt.Println(string([]rune("Hello, 日本語")[1])) // UTF-8
fmt.Println(string([]rune("Hello, 日本語")[8])) // UTF-8}
Pizza is an exported name, as is Pi, which is exported from the math package.| Term | (Document,Frequency) |
| Hello | (1,1) |
| World | (1,1) |
| Elasticsearch | (1,1),(2,1) |
| hello | (2,1) |
| world | (2,1) |
| Term | (Document,Frequency) |
| hello | (1,1),(2,1) |
| world | (1,1),(2,1) |
| Elasticsearch | (1,1),(2,1) |