Skip to content

Instantly share code, notes, and snippets.

View guyts's full-sized avatar
🌈
Multitasking

Guy guyts

🌈
Multitasking
View GitHub Profile
@guyts
guyts / postgres_queries_and_commands.sql
Created December 18, 2019 14:55 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@guyts
guyts / iterm2.md
Created November 28, 2019 19:15 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
from plotly.subplots import make_subplots
df2 = df[df.Magnitude < 7].copy()
df1 = df[df.Magnitude >= 7].copy()
fig = make_subplots(
rows=2, cols=2,
column_widths=[0.5, 0.5],
row_heights=[0.4, 0.6],
specs=[[{"type": "scattergeo", "colspan": 2}, None ],
@guyts
guyts / plotly-go-scatter-2.py
Created October 28, 2019 00:50
adding attributes to the graph-object
fig = go.Figure(data=go.Scattergeo(
lon = df['Longitude'],
lat = df['Latitude'],
text = [df['Magnitude'], df['date']],
mode = 'markers',
marker = dict(
size = 8,
opacity = 0.8,
autocolorscale = False,
symbol = 'diamond',
@guyts
guyts / plotly-go-scatter-1.py
Created October 28, 2019 00:45
graph object with a geo-scatter
fig = go.Figure(data=go.Scattergeo(
lon = df['Longitude'],
lat = df['Latitude'],
text = [df['Magnitude'], df['date']],
mode = 'markers',
marker_color = df['Magnitude'],
))
fig.update_layout(
title = 'Significant earthquakes since the year 2000',
@guyts
guyts / plotly-geoscatter-1.py
Last active October 28, 2019 00:40
geoscatter with plotly, example 1
import plotly.express as px
import plotly.io as pio
pio.renderers.default = 'browser'
fig = px.scatter_geo(df, lat = "Latitude", lon = "Longitude")
pio.show(fig)
@guyts
guyts / KmlToCsv.py
Created January 10, 2019 20:05 — forked from mciantyre/KmlToCsv.py
KML to CSV in Python
"""
A script to take all of the LineString information out of a very large KML file. It formats it into a CSV file so
that you can import the information into the NDB of Google App Engine using the Python standard library. I ran this
script locally to generate the CSV. It processed a ~70 MB KML down to a ~36 MB CSV in about 8 seconds.
The KML had coordinates ordered by
[Lon, Lat, Alt, ' ', Lon, Lat, Alt, ' ',...] (' ' is a space)
The script removes the altitude to put the coordinates in a single CSV row ordered by
[Lat,Lon,Lat,Lon,...]