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
| fmt.Println(request2curl(req)) | |
| func request2curl(req *http.Request) string { | |
| escaped := func(origin string) string { | |
| return `'` + strings.ReplaceAll(origin, `'`, `'\''`) + `'` | |
| } | |
| resource := req.URL.String() | |
| scheme := req.URL.Scheme | |
| if scheme == "" { |
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
| <?php | |
| $res = Bitrix\Main\UserTable::getList(Array( | |
| "select"=>Array("ID", "PERSONAL_PHOTO"), | |
| "filter"=>Array("!PERSONAL_PHOTO" => 0), | |
| )); | |
| $avatar = $other = 0; | |
| while ($arUser = $res->fetch()) { | |
| $fileID = (int) $arUser['PERSONAL_PHOTO']; | |
| $arFile = CFile::GetByID($fileID)->Fetch(); |
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
| // IsMatchedName implements case-insensitive search string value for pattern. | |
| // Pattern supports % and _ wildcards. Escape symbol is \. | |
| func IsMatchedName(pattern, value string) bool { | |
| if len(pattern) == 0 { | |
| return true | |
| } | |
| re := likeToRegexp(pattern) | |
| match, err := regexp.MatchString(strings.ToLower(re), strings.ToLower(value)) | |
| if err != nil { | |
| panic(err) |
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
| SELECT | |
| tablename, | |
| indexname, | |
| indexdef | |
| FROM | |
| pg_indexes | |
| WHERE | |
| schemaname = 'public' AND | |
| tablename = 'file_name_attribute_fact' | |
| ORDER BY |
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
| type MultipartForm struct { | |
| Body bytes.Buffer | |
| ContentType string | |
| } | |
| type multipartFormParams struct { | |
| File io.Reader | |
| FieldName string | |
| FileName string | |
| Extra map[string]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
| var urlInjector = &URLInjector{ | |
| Rules: map[string]URLGeneratorFunc{ | |
| entityUUIDKey: observableEntityURL, | |
| }, | |
| } | |
| // URLGeneratorFunc returns URL of entity/artifact/object/task... | |
| // BaseURL doesn't contain an ending slash, so remember to add leading slash at the begin of an URI. | |
| type URLGeneratorFunc func(baseURL string, uuidStr []byte) 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
| // RealProto is a helper used to determine protocol used on client's side of proxy. | |
| // Ensure the proxy configured correct before use this func in prod env. | |
| func RealProto(r *http.Request) string { | |
| proto := r.Header.Get("X-Forwarded-Proto") | |
| if proto == "" { | |
| if r.TLS == nil { | |
| proto = "http" | |
| } else { | |
| proto = "https" |
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 uniq(source []uuid.UUID) []uuid.UUID { | |
| m := make(map[string]bool) | |
| res := make([]uuid.UUID, 0, len(source)) | |
| for i := range source { | |
| if _, ok := m[source[i].String()]; ok { | |
| continue | |
| } | |
| m[source[i].String()] = true | |
| res = append(res, source[i]) | |
| } |
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
| var hostFmt = regexp.MustCompile("^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$") | |
| func canonize(addr string) (string, error) { | |
| addr = strings.ToLower(strings.Trim(addr, " ")) | |
| components := strings.Split(addr, "@") | |
| username, host := components[0], components[1] | |
| if len(addr) > 254 || username == "" || !hostFmt.MatchString(host) { | |
| return "", ErrInvalidEmailAddr | |
| } |
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
| #!/bin/sh | |
| printf "Switching php to version 5.6 with symlinks.\n" | |
| printf "Press any key to continue...\n" | |
| read CONTINUE | |
| printf "Creating backups..." | |
| # Backup original binaries |
NewerOlder