Skip to content

Instantly share code, notes, and snippets.

View FanchenBao's full-sized avatar

Fanchen Bao FanchenBao

View GitHub Profile
@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:
@davidteren
davidteren / nerd_fonts.md
Last active April 26, 2024 21:46
Install Nerd Fonts via Homebrew [updated & fixed]
@defulmere
defulmere / settings.py
Last active April 30, 2024 05:34
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 = {
@srenatus
srenatus / Rego.sublime-syntax
Last active February 14, 2020 13:57
@eephillip has created a package for the sublime syntax, see https://github.com/eephillip/rego.sublime-package
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Rego
file_extensions:
- rego
- Rego
scope: source.rego
contexts:
main:
@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
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 2, 2024 16:19
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
@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
@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