Skip to content

Instantly share code, notes, and snippets.

View FanchenBao's full-sized avatar

Fanchen Bao FanchenBao

View GitHub Profile
@davidteren
davidteren / nerd_fonts.md
Last active May 18, 2024 14:05
Install Nerd Fonts via Homebrew [updated & fixed]
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 17, 2024 05:23
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@gitaarik
gitaarik / git_submodules.md
Last active May 15, 2024 09:34
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@defulmere
defulmere / settings.py
Last active May 11, 2024 03:18
How to override an old sqlite3 module with pysqlite3 in django settings.py
# ⚠️ USE AT YOUR OWN RISK
# first: pip install pysqlite3-binary
# then in settings.py:
# these three lines swap the stdlib sqlite3 lib with the pysqlite3 package
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
DATABASES = {
@rjz
rjz / ngrok_hostname.sh
Created August 9, 2016 16:20
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#
@treyhunner
treyhunner / time_dict_merge.py
Last active November 3, 2023 08:13
Test performance of different dictionary merging functions in Python
"""
Results:
multiple_update: 33 ms
copy_and_update: 27 ms
dict_constructor: 29 ms
kwargs_hack: 33 ms
dict_comprehension: 33 ms
concatenate_items: 81 ms
union_items: 81 ms
@dropmeaword
dropmeaword / wifiscanner.py
Created June 20, 2017 22:38 — forked from D4rKP01s0n/wifiscanner.py
A simple python script which records and logs wifi probe requests.
#########################################################################
# Wifiscanner.py - A simple python script which records and logs wifi probe requests.
# Author - D4rKP01s0n
# Requirements - Scapy and Datetime
# Inspiration - Tim Tomes (LaNMaSteR53)'s WUDS https://bitbucket.org/LaNMaSteR53/wuds/
# Reminder - Change mon0 (around line 65) to your monitor-mode enabled wifi interface
#########################################################################
from datetime import datetime
@biggates
biggates / petstore_oas3_requestBody_example.json
Last active February 2, 2023 23:33
Example of OpenAPI Specification v3.0.0, containing multiple examples of requestBody
{
"openapi": "3.0.2",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
@beeleebow
beeleebow / group_by_intervals_postgres.sql
Last active January 16, 2023 00:28
PSQL - Group Rows with timestamp interval
-- POSTGRES SQL.
-- Count of rows where a timestamp column falls in interval.
-- This example uses a 5 minute interval ( 300 seconds = 5 minutes).
-- You need to replace the things inside square brackets, i.e. provide
-- the name of the table and timestamp column.
SELECT COUNT(*) cnt,
to_timestamp(floor((extract('epoch' from [Timestamp Column]) / 300 )) * 300)
AT TIME ZONE 'UTC' as expiry_interval
FROM [Table] GROUP BY expiry_interval
order by expiry_interval
@clane9
clane9 / plotly_dash_crossfilter_recipe.py
Created November 21, 2022 15:57
Fixed generic crossfilter recipe for Plotly Dash
from dash import Dash, dcc, html
import numpy as np
import pandas as pd
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate
import plotly.express as px
def get_figure(df, x_col, y_col, selectedpoints=None, selectedpoints_local=None, pad=0.04):
if selectedpoints is None: