This file contains hidden or 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
function addCommaByID(id) { | |
var price; | |
price = ""; | |
var field = document.getElementById(id); | |
while (field.value.indexOf(',') != -1) { | |
field.value = field.value.replace(',', ''); | |
} | |
txt_field = field.value.length; |
This file contains hidden or 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 CallMethod(i interface{}, methodName string) interface{} { | |
var ptr reflect.Value | |
var value reflect.Value | |
var finalMethod reflect.Value | |
value = reflect.ValueOf(i) | |
if value.Type().Kind() == reflect.Ptr { | |
ptr = value |
This file contains hidden or 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 ( | |
"crypto/hmac" | |
"crypto/sha256" | |
"fmt" | |
) | |
func CheckMAC(message, messageMAC, key []byte) bool { | |
mac := hmac.New(sha256.New, key) |
This file contains hidden or 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://rosettacode.org/wiki/Levenshtein_distance#Go | |
package main | |
import "fmt" | |
func levenshtein(s, t string) int { | |
if s == "" { return len(t) } | |
if t == "" { return len(s) } | |
if s[0] == t[0] { |
This file contains hidden or 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 sample | |
import ( | |
"bytes" | |
"fmt" | |
"io" | |
"mime/multipart" | |
"net/http" | |
"os" | |
) |
This file contains hidden or 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
// test project main.go | |
package main | |
import ( | |
"crypto/sha1" | |
"fmt" | |
"time" | |
) | |
func main() { |
This file contains hidden or 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 ( | |
"strconv" | |
) | |
func ValidateIranianCode(code string) bool { | |
ToInt := func(str string) int { | |
if icode, err := strconv.Atoi(str); err == nil { | |
return icode |
This file contains hidden or 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" | |
"reflect" | |
) | |
type Test struct { | |
Name string | |
} |
This file contains hidden or 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
// | |
// Please read http://codepodu.com/subdomains-with-golang/ | |
// It's just copy and paste :smile: | |
// | |
// | |
// URLs : | |
// http://admin.localhost:8080/admin/pathone | |
// http://admin.localhost:8080/admin/pathtwo | |
// http://analytics.localhost:8080/analytics/pathone | |
// http://analytics.localhost:8080/analytics/pathtwo |
This file contains hidden or 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" | |
"io/ioutil" | |
"net/http" | |
"regexp" | |
) | |
func getTitle(url string) (string, error) { |
OlderNewer