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 execHelper(path, name string, arg ...string) (err error) { | |
cmd := exec.Command(name, arg...) | |
cmd.Dir = path | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
err = cmd.Run() | |
return | |
} |
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 helper | |
// closer close descriptor and log error | |
func closer(f io.Closer) { | |
err := f.Close() | |
if err != nil { | |
log.Errorln("closing ", err) | |
} | |
} |
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 ( | |
"context" | |
"flag" | |
"fmt" | |
"io" | |
"os" | |
"syscall" |
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 newFileName() string { | |
buff := make([]byte, 6) | |
rand.Read(buff) | |
return fmt.Sprintf("%v-%X\n", time.Now().UTC().Format("2006-01-02T150405"), buff) | |
} |
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 exemple | |
func MapIntervalFloat64(value, fromLow, fromHigh, toLow, toHigh float64) (ret float64) { | |
ret = (value-fromLow)*(toHigh-toLow)/(fromHigh-fromLow) + toLow | |
return | |
} | |
func SimpleMapIntervalFloat64(value, fromHigh, toHigh float64) (ret float64) { | |
ret = value * toHigh / fromHigh | |
return |
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
;;;; Creates a fake NAND gate and then creates all gates from NAND. | |
;;;; This is just an exercise, obviously has no practical application. | |
;;; NAND | |
(defun !& (a b) (if (and (= a 1) (= b 1)) 0 1)) | |
;;; NOT | |
(defun ! (a) (!& a 1)) | |
;;; AND |
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 ( | |
"net/http" | |
"github.com/aws/aws-lambda-go/events" | |
"github.com/aws/aws-lambda-go/lambda" | |
) | |
func handler(request events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error) { |
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" | |
"net" | |
"net/http" | |
"github.com/gorilla/mux" | |
) |
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 ( | |
"context" | |
"log" | |
"github.com/chromedp/chromedp" | |
) | |
func main() { |
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 json | |
def json_titles_tuple(payload_json, prefix=''): | |
jsonobj = json.loads(payload_json) | |
titles = () | |
for key, value in jsonobj.items(): | |
if isinstance(value, dict): | |
titles += json_titles_tuple(json.dumps(value), prefix + key + '_') | |
else: | |
titles += (prefix + key,) |