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
const putS3StringObject = async (bucket, key, str) => { | |
try { | |
const s3 = new aws_sdk_1.S3(); | |
const buf = Buffer.from(str); | |
await s3.putObject({ | |
Key: key, | |
Bucket: bucket, | |
Body: buf, | |
ContentEncoding: 'base64' | |
}).promise(); |
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
const axios = require('axios'); | |
const fs = require('fs'); | |
const headers = { 'x-vol-tenant': '5c49cda1ddca5800122fad4e' }; | |
const materialApi = 'https://api.material.com/images'; | |
const getImages = async (url, headers) => { | |
if (!fs.existsSync('404s.txt')) { | |
fs.writeFileSync('404s.txt', ''); | |
} | |
const params = { |
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
python3 -m cProfile -s cumulative script.py > profile.txt |
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
DO $func$ | |
BEGIN | |
EXECUTE ( | |
SELECT | |
'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE' | |
FROM | |
pg_class | |
WHERE | |
relkind = 'r' | |
AND relnamespace = 'schema_name'::regnamespace); |
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
find the difference between the arc lengths of the inner and outer radius you want and divide by the kerf width, that'll give you the number of cuts, then space them evenly |
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
#!/bin/bash | |
function containerCommand() { | |
# Given a string, search for the matching running docker containers. | |
# If more than one argument is passed, attempt to run remaning arguments | |
# on that docker container. | |
container=`docker ps --format '{{.ID}} {{.Names}}'1`; | |
shift; | |
if [[ ! -z "$@" ]] | |
then |
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
#!/bin/bash | |
# Requirements: | |
# - gcloud/gsutil is installed on the box | |
# - gcloud is logged in as a user with write access to Google Cloud Storage | |
# - The file has execution rights so that it can be run in cron | |
# - The Google Cloud Storage bucket already exits | |
# Exit on any error | |
set -e |
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
kccontexts() { | |
# Works with kubectl v1.4.0 and the config file generated by gcloud containers clusters get-credentials | |
# If you pass in an arg, then we will filter the contexts for that string | |
# The following block creates a list of the contexts and filters if an argument | |
# is passed in. | |
if [[ $1 ]] | |
then | |
options=(`kubectl config get-contexts -o name | sort | grep $1`) | |
else |
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
# To determine which node a container is on: | |
kubectl get pods -o wide | |
# To view current resource usuage and limits of a cluser | |
kubectl describe nodes <cluster name> | |
# To view what is happening on a container | |
kubectl attach <container-name> | |
# To start an interactive shell on a container |
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
def find_attribute_class(model, attribute): | |
""" | |
If the attribute is found, it returns an array of places the attribute is defined. | |
The array is ordered by priority, the first element being the one that is called. | |
If not found, returns an empty array. | |
""" | |
return [m for m in model.mro() if attribute in m.__dict__] |
NewerOlder