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" | |
"runtime" | |
"runtime/debug" | |
) | |
// 返回生成自然数序列的管道: 2, 3, 4, ... | |
func GenerateNatural() chan int { |
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 ( | |
"fmt" | |
"reflect" | |
) | |
func Map(slice interface{}, fn func(a interface{}) interface{}) interface{} { | |
val := reflect.ValueOf(slice) | |
out := reflect.MakeSlice(reflect.TypeOf(slice), val.Len(), val.Cap()) | |
for i := 0; i < val.Len(); i++ { |
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 "log" | |
type MyError struct{} | |
func (err *MyError) Error() string { | |
return "MyError" | |
} | |
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" | |
type int byte | |
func (p int) Foo() { | |
fmt.Printf("int.Foo: %v\n", p) | |
} |
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 main() { | |
defer func() { for {} }() | |
} | |
func main() { | |
defer func() { select {} }() | |
} | |
func main() { | |
defer func() { <-make(chan 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
:: Script to build Lua with MSVC. | |
:: Copyright (C) 2010-2011 ChaiShushan<chaishushan{@}gmail.com>. | |
:: | |
:: Either open a "Visual Studio .NET Command Prompt" | |
:: Then cd to this directory and run this script. | |
@if not defined INCLUDE goto :FAIL | |
@setlocal | |
cd %~dp0 |
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 "db_lib.h" | |
#include <ctype.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdarg.h> | |
#include <assert.h> |
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 <stdlib.h> | |
// return m*PI((p-1)/p); | |
int fEuler(int m, int p[]) { | |
int a = 1, b = 1, t = m; // a分子, b分母 | |
for(int i = 0; ; ++i) { | |
div_t dt = div(t, p[i]); | |
// 如果break, 则t为素数 |
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 ( | |
"bufio" | |
"bytes" | |
"flag" | |
"fmt" | |
"github.com/golang/groupcache" | |
"github.com/ha/doozer" | |
"io" |
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
<link rel="import" href="../topeka-elements/category-icons.html"> | |
<link rel="import" href="../core-icon/core-icon.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; |
OlderNewer