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 ( | |
"flag" | |
"fmt" | |
"io" | |
"net/http" | |
"os" | |
"runtime" | |
"sync" |
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 ( | |
"flag" | |
"fmt" | |
"github.com/qiniu/api/auth/digest" | |
"github.com/qiniu/rpc" | |
"net/http" | |
) |
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 | |
//THE ALGORITHM IS FROM HERE: https://github.com/qiniu/qetag | |
import ( | |
"bytes" | |
"crypto/sha1" | |
"encoding/base64" | |
"fmt" | |
"io" | |
"os" |
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
//struct is copied by value | |
enum Rank :Int{ | |
case Ace = 1 | |
case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten | |
case Jack, Queen, King | |
func desc() -> String{ | |
switch self{ | |
case .Ace: |
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
//enum | |
enum Rank :Int{ | |
case Ace = 1 | |
case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten | |
case Jack, Queen, King | |
func desc() -> String{ | |
switch self{ | |
case .Ace: |
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
//willSet and didSet | |
class Shape{ | |
var oldName :String | |
var newName :String | |
var name :String{ | |
willSet{ | |
self.oldName=name | |
self.newName=newValue | |
println("WillSet: old values is \(name), new values is \(newValue)") | |
} |
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
//define a class | |
class Shape{ | |
var name :String | |
var numberOfSlides = 0 | |
let pi :Float = 3.14 | |
init(name :String){ | |
self.name=name | |
} |
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
//overload of functions | |
func greet(name :String, day :String) -> String{ | |
return "hello \(name), today is \(day)" | |
} | |
func greet(name :String) -> String{ | |
return greet(name, "fuckday") | |
} |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
let myWeight: Float = 4 | |
println(myWeight) | |
var myWeight2 = 4 | |
println(myWeight2) |
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
#include<stdio.h> | |
#include<string.h> | |
int main(int argc, char *argv[]) | |
{ | |
long sum=0; | |
int num=0; | |
char *option; | |
while(scanf("%d",&num)!=EOF) | |
{ | |
sum+=num; |