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
#!/usr/bin/env bash | |
DEVICES=$(camcontrol devlist | sed 's/.*,\(.*\)).*/\1/') | |
for DEV in $DEVICES; do | |
printf "%s: " "$DEV" | |
camcontrol epc "$DEV" -c status -P | |
done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 pandas as pd | |
# Input: | |
# a b c d e | |
# 0 Text Text NaN 0.0 5 | |
# 1 Text NaN 1.1.1.1 0.0 55 | |
# 2 Text.Text Text Text 0.4 555 | |
data = [ | |
{"a": "Text", "b": "Text", "d": 0, "e": 5}, |
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
SELECT | |
t.table_schema, | |
t.table_name, | |
c.column_name | |
FROM | |
information_schema.tables t | |
INNER JOIN information_schema.columns c ON c.table_name = t.table_name | |
AND c.table_schema = t.table_schema | |
WHERE | |
c.column_name ~ 'regex' |
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 advanced_dataframe_union(df1, df2): | |
df1_fields = set((f.name, f.dataType) for f in df1.schema) | |
df2_fields = set((f.name, f.dataType) for f in df2.schema) | |
df2 = df2.select( | |
df2.columns | |
+ [ | |
F.lit(None).cast(datatype).alias(name) | |
for name, datatype in df1_fields.difference(df2_fields) | |
] |
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
FROM alpine:3.10 | |
RUN apk add --no-cache \ | |
bzip2-dev \ | |
g++ \ | |
make | |
RUN cd /tmp/ && \ | |
wget -q https://launchpad.net/pbzip2/1.1/1.1.13/+download/pbzip2-1.1.13.tar.gz && \ | |
tar -xzf pbzip2-1.1.13.tar.gz && \ |
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 | |
from pyspark.sql.types import * | |
# Define the schema | |
schema = StructType( | |
[StructField("name", StringType(), True), StructField("age", IntegerType(), True)] | |
) | |
# Write the schema | |
with open("schema.json", "w") as f: |
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
psql -h hostname -U username -W -d database -t -A -F "," -c "SELECT * FROM table" > file.csv | |
# Explanation of the used options: | |
# -h Specifies the host name of the machine on which the server is running. | |
# -U Connect to the database as a specific user. | |
# -W Force psql to prompt for a password before connecting to a database. | |
# -d Specifies the name of the database to connect to. | |
# -t Turn off printing of column names and result row count footers, etc. | |
# -A Switches to unaligned output mode. | |
# -F Use separator as the field separator for unaligned output. |
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 pandas as pd | |
import numpy as np | |
import psycopg2 | |
from sqlalchemy import create_engine | |
engine = create_engine('postgresql+psycopg2://USER:PASSWORD@HOST:PORT/DBNAME') | |
df = pd.read_csv('local-file.csv', sep=',').replace(to_replace='null', value=np.NaN) | |
df.to_sql('dbtable', engine, schema='dbschema', if_exists='replace') |
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 | |
cd /path/to/git/repo/ | |
git add -A | |
git commit -m "Backup on `date`" | |
git push origin |
NewerOlder