Skip to content

Instantly share code, notes, and snippets.

View junzis's full-sized avatar

Junzi Sun junzis

View GitHub Profile
@junzis
junzis / catorpy_example.py
Created August 13, 2020 12:58
Catorpy examples
from cartopy.feature import NaturalEarthFeature
import cartopy.crs as ccrs
plt.figure(figsize=(6, 6))
ax = plt.axes(projection=ccrs.EuroPP(), zorder=1)
land = NaturalEarthFeature(
category="cultural",
name="admin_0_countries",
scale="10m",
facecolor="none",
@junzis
junzis / profile.sh
Last active November 3, 2017 14:21
python profiling
python -m cProfile -o profile.pstats script.py
gprof2dot -f pstats profile.pstats | dot -Tsvg -o profile.svg
@junzis
junzis / network-manager.txt
Last active October 17, 2017 08:54
Difficult Ubuntu bug fixes
Ubuntu network manager permission problem
--------------------------------------------
edit: /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
and change:
[Adding or changing system-wide NetworkManager connections]
Identity=unix-group:admin;unix-group:sudo
Action=org.freedesktop.NetworkManager.settings.mod ify.system
@junzis
junzis / install_basemap_commands
Last active December 4, 2021 01:22
install basemap quickly on ubuntu
sudo apt-get install libgeos-3.X.X
sudo apt-get install libgeos-dev
pip install --user https://github.com/matplotlib/basemap/archive/master.zip
@junzis
junzis / python_time.py
Last active February 11, 2024 14:44
Time conversions in python
from datetime import datetime
import time
#-------------------------------------------------
# conversions to strings
#-------------------------------------------------
# datetime object to string
dt_obj = datetime(2008, 11, 10, 17, 53, 59)
date_str = dt_obj.strftime("%Y-%m-%d %H:%M:%S")
print date_str
@junzis
junzis / lowpass.py
Last active December 6, 2022 08:16
Python Lowpass Filter
# https://stackoverflow.com/questions/25191620/
# creating-lowpass-filter-in-scipy-understanding-methods-and-units
import numpy as np
from scipy.signal import butter, lfilter, freqz
from matplotlib import pyplot as plt
def butter_lowpass(cutoff, fs, order=5):
nyq = 0.5 * fs
# a set of useful scripts for mongodb
- batch deleting collections
- extract subset using fast aggregation method
- export query to csv (quick and dirty)
@junzis
junzis / start-stop-example.sh
Last active September 17, 2015 14:25 — forked from alobato/start-stop-example.sh
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar