Skip to content

Instantly share code, notes, and snippets.

@mknz
mknz / kafka_gpt2.ipynb
Created July 27, 2022 18:54
kafka_gpt2.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@willwade
willwade / keyboardHook.py
Created December 18, 2018 01:04
convert all keypresses and turn to HEX codes ready for BLE / AT Commands
"""
Convert the pressed up/down key to the hexcode of all keys and send to BLE
"""
import sys
sys.path.append('..')
import keyboard
import warnings
import serial
import serial.tools.list_ports
#!/bin/bash
SECURE_WORD="76492d1116743f0423413b16050a5345MgB8AE4AeQBTAHMAbABvAGEAMAAvADYAdwBiADQASABPAFgAZABVAFYATQAzAHcAPQA9AHwAYgAzAGUAZgBjAGEAZgBiAGQAMwBiAGMAMwBiAGMAZgAwADUAYQAyADEAMABlADgAMABkADEAYgA5AGIAYQA1ADMAYgBlADQAZgBmAGUAYgBhAGUAMAA5ADcAYQA4AGIAMQBiAGMAZQA4AGEAMwBlADQAZQA1ADAANgAyADcAYgBmADIANQA1AGYANgA1ADMAOQAzAGEAZAA4ADIAOAA3ADgANAA5AGIAYwBiAGQAMAA5AGMAYQBmADUAYgA5ADYAOAA4AGQANwBhAGIAYwA1AGIAOQAxAGYAOAAwADIAMgA3ADEAMgBlAGUANAAzADgANgAyADYAMwBhAGIAZgA2ADcAMAA4ADYAMQAzADkAMQA0ADAAYQAzAGQAOAA4ADMAZAAyAGIANAAzAGMAZABmADEAYwBjAGYANwA5ADYAYQAxADIAYwAxAGMAYgA2ADIAOQAwAGQAMQBhAGUAZAA0AGIAOQA5ADkAZABiAGIANABlADAAZQA4ADkANQA2ADQAMQA3AGEAMgAwADYAZQAwAGYAYwA5ADIANQA1ADcAMwA5AGQAMgBjAGIAZgA4AGUANgA0ADYAOQA3ADEAYwBiAGUAOQAwADEANQBkADMAYwAzAGYAZQBjADQAZQA2ADYANAAzADQAYQA1ADMAYQBhAGIAZQBiADgANgA1ADkANwA0ADgAYgA1AGIAOAA3AGYAMwA2ADgAYQA3AGUAMABiAGMAMAAzAGUANQA5ADYAZAAyAGUAMgAzADcAOQA4ADkAZgA4ADkAYwBmADUANwA2AGQAOQBkAGIAOQBkADcAZAAxAGUAYgA2ADgANQAzAGIAYgA0ADkANgAwADgAOABiADYANQBmAGEANQBhADEAMABkAGQANgBmADcANABhAGI
@dpatschke
dpatschke / Readme.md
Created April 9, 2018 02:49
Numba Ball Tree (ParallelAccelerator)

Numba Ball Tree (ParallelAccelerator)

This is a modified gist of Jake Vanderplas wonderful Numba Ball Tree code from the following gist. This gist basically adds the 'nopython' parameter in the jit decorators from the original gist and parallelizes the nearest neighbor query for each of the points.

Timings

With some of the new advances in numba and the modifications

@vvksh
vvksh / rolling_mean.py
Created November 18, 2017 21:32
plot of rolling mean using pandas
#say `x` is list of noisy values
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(size=100)
mean_x = pd.Series(x).rolling(window=2).mean()
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active July 14, 2024 18:27
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@jakebrinkmann
jakebrinkmann / connect_psycopg2_to_pandas.py
Created July 3, 2017 14:19
Read SQL query from psycopg2 into pandas dataframe
import pandas as pd
import pandas.io.sql as sqlio
import psycopg2
conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
sql = "select count(*) from table;"
dat = sqlio.read_sql_query(sql, conn)
conn = None
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@simonw
simonw / recover_source_code.md
Last active June 21, 2024 00:11
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@ravibhure
ravibhure / git_rebase.md
Last active June 25, 2024 13:44
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream