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
| import Queue # or queue in Python 3 | |
| import threading | |
| class PrintThread(threading.Thread): | |
| def __init__(self, queue): | |
| threading.Thread.__init__(self) | |
| self.queue = queue | |
| def printfiles(self, p): | |
| for path, dirs, files in os.walk(p): |
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
| import threading | |
| list1Lock = threading.Lock() | |
| with list1Lock: | |
| # do sth |
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
| const fs = require('fs') | |
| const readFilePromise = (...args) => { | |
| return new Promise((resolve, reject) => { | |
| fs.readFile(...args, (err, data) => { | |
| if (err) return reject(err) | |
| resolve(data) | |
| }) | |
| }) | |
| } |
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
| # countasync.py | |
| import asyncio | |
| async def count(): | |
| print("One") | |
| await asyncio.sleep(1) | |
| print("Two") | |
| async def 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 ( | |
| "fmt" | |
| "time" | |
| ) | |
| func main() { | |
| c := time.Tick(5 * time.Second) | |
| for t := range c { |
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" | |
| "time" | |
| ) | |
| func main() { | |
| for { | |
| select { |
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
| #!/usr/bin/env python | |
| import threading | |
| def resubmit_dlq(): | |
| do_somethings() |
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
| session = boto3.Session() | |
| credentials = session.get_credentials() | |
| # Credentials are refreshable, so accessing your access key / secret key | |
| # separately can lead to a race condition. Use this to get an actual matched | |
| # set. | |
| #credentials = credentials.get_frozen_credentials() | |
| #access_key = credentials.access_key | |
| #secret_key = credentials.secret_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
| main() { | |
| if [[ "$*" == "-h" || "$*" == "--help" ]]; then | |
| usage | |
| exit | |
| fi | |
| local os | |
| for os in darwin linux; do | |
| log_info "Building roo for ${os}" | |
| env GOOS="${os}" GOARCH=amd64 go build -o bin/roo-${os}-amd64 -ldflags="-X 'github.com/Canva/roo/pkg/cli.BuildCommit=lalalala'" github.com/Canva/roo/pkg/cmd/roo | |
| done |
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 manifest | |
| import ( | |
| "net/http/httptest" | |
| ) | |
| func makeTestServer(statusCode int, responseBody string) *httptest.Server { | |
| srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
| w.WriteHeader(statusCode) | |
| _, _ = w.Write([]byte(responseBody)) |