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/bash | |
for cmd in "$@"; do { | |
echo "Process \"$cmd\" started..."; | |
$cmd & pid=$! | |
PID_LIST+=" $pid"; | |
} done | |
trap "kill $PID_LIST" SIGINT | |
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
CREATE TABLE `user_settings` ( | |
`userid` int(11) unsigned NOT NULL, | |
`name` varchar(50) NOT NULL, | |
`type` BOOL NOT NULL, | |
`value_int` int(10) DEFAULT NULL, | |
`value_str` varchar(100) DEFAULT NULL, | |
PRIMARY KEY (`userid`, `name`) | |
); | |
#`userid`: The user that this setting applies to |
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
//Create an ENCODABLE struct which will be used to create a POST body | |
struct createPost: Encodable { | |
let public_id: String | |
let action: String | |
let type: String | |
let value: String | |
} | |
//Let's assume the POST to the API will return a JSON object that looks like this: | |
//{ "action" : "create", "type": "bulletin", "result" : "Bulletin created successfully!" } |
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
//We'll use a NASA API response as an example | |
//https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?earth_date=2015-6-3&api_key=DEMO_KEY | |
//I like to start in the inner-most part of the nesting and work my way out | |
//"cameras" is the inner-most nest and it contains an array | |
//Each array has two key:value pairs, "name" and "full_name" | |
//Create a Decodable struct for a single object in the array | |
struct roverCamera: Decodable { | |
let 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
import fnmatch | |
l = ["imagine", "if", "this", "was", "a", "super", "duper", "long", "list"] | |
thisMatches = fnmatch.filter(l, "this") | |
print(thisMatches) | |
#['this'] | |
#Using ? as a single-character wildcard | |
uperMatches = fnmatch.filter(l, "?uper") |
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 pandas as pd | |
improt requests | |
#Use requests to hit the API | |
response = requests.get('https://official-joke-api.herokuapp.com/random_ten') | |
#Convert the JSON response to a list of dictionaries using json() | |
json = response.json() | |
#Create a pandas DataFrame from the list of dictionaries |
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
date +%Y-%m-%d | |
#2018-12-16 | |
#Set the date to a variable | |
rundate=$(date +%Y-%m-%d) | |
echo $rundate | |
#2018-12-16 |
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
#Checkout the master branch | |
git checkout master | |
#Merge the dev branch into the master branch | |
git merge dev | |
#Push the new merged master branch | |
git push | |
#Delete the dev branch locally |
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 | |
PNAME=$1 | |
ENDPOINT=$2 | |
GITREPO=$3 | |
#template | |
cat << EOF | |
Project name: $PNAME | |
API Endpoint: $ENDPOINT |
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
# print lines 10 to 20 in the file called file.txt | |
sed -n '10,20p' file.txt |