View role.go
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
type Role int | |
const ( | |
RoleUnknown Role = iota | |
_ | |
_ | |
RoleUser | |
_ | |
_ | |
RoleAdmin |
View user_context.go
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
import ( | |
"context" | |
"net/http" | |
) | |
type key int | |
var contextKey = key(22) | |
func SetUser(usr *User, r *http.Request) { |
View kttime.go
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
// KTTime is an example of a type that is aliased to time, than implements the json marshaling functions. | |
// This is an example for how to build serialization interopability with kotlin/gson. | |
package kttime | |
type KTTime time.Time | |
func (t KTTime) MarshalJSON() ([]byte, error) { | |
gt := time.Time(t) | |
f := gt.Format(ktFormat) | |
return json.Marshal(f) |
View synergy_build
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
I was able to get this working on Yosemite with the following command: | |
./hm.sh conf -g2 --mac-sdk 10.10 --mac-identity Yosemite | |
Of course, this will only work given you have the dependencies. You can install them with the Homebrew package manager. | |
brew install cmake qt | |
Additionally, you'll want to build it with: | |
./hm.sh build | |
And finally, to install it, you'll get the compiled results from the bin folder, i.e. Synergy.app |
View fedora_mp3
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
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm | |
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm | |
yum install gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg | |
## java ## | |
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000 | |
## javaws ## | |
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000 |
View mysql_user
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
GRANT ALL PRIVILEGES ON dbTest.* To 'user'@'hostname' IDENTIFIED BY 'password'; |
View golang_time
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
func timeTrack(start time.Time, name string) { | |
elapsed := time.Since(start) | |
log.Printf("%s took %s", name, elapsed) | |
} | |
func factorial(n *big.Int) (result *big.Int) { | |
defer timeTrack(time.Now(), "factorial") | |
// ... do some things, maybe even return under some condition | |
return n | |
} |
View git_retieve
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
git checkout <rev> filename |
View read_line.go
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
func readLine(path string) { | |
inFile, _ := os.Open(path) | |
defer inFile.Close() | |
scanner := bufio.NewScanner(inFile) | |
scanner.Split(bufio.ScanLines) | |
for scanner.Scan() { | |
fmt.Println(scanner.Text()) | |
} | |
} |
View golang_concurrency
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
// http://talks.golang.org/2012/concurrency.slide | |
func Google(query string) (results []Result) { | |
c := make(chan Result) | |
go func() { c <- Web(query) } () | |
go func() { c <- Image(query) } () | |
go func() { c <- Video(query) } () | |
for i := 0; i < 3; i++ { | |
result := <-c | |
results = append(results, result) |
NewerOlder