Skip to content

Instantly share code, notes, and snippets.

@aquilax
aquilax / index.html
Created May 15, 2021 13:47
Textarea sorting bookmarklet
<a href="javascript:(function(){Array.from(document.querySelectorAll('textarea')).map(function(b){var a=document.createElement('div');var d=document.createElement('button');d.textContent='↑';d.addEventListener('click',function(f){f.preventDefault();b.value=b.value.split('\n').sort().join('\n')});var c=document.createElement('button');c.textContent='↓';c.addEventListener('click',function(f){f.preventDefault();b.value=b.value.split('\n').sort().reverse().join('\n')});a.appendChild(d);a.appendChild(c);b.parentNode.insertBefore(a,b)})})();">Sort textareas</a>
@aquilax
aquilax / bookmarklet_raw.js
Last active May 15, 2021 08:49
Sort lines bookmarklet
javascript:(function(){
var container = document.createElement('div');
container.setAttribute('style', 'position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9999');
var textarea = document.createElement('textarea');
textarea.setAttribute('style', 'width:99%; height: 20em');
var close = document.createElement('button');
close.textContent = 'Close'
close.addEventListener("click", function() {
import pandas as pd
df = pd.read_csv('en_bigram.csv')
st = df[df["right"] == "some_text"]["left"]
st[st.str.startswith("My")].to_list()
# using a dict reader
import csv
result = []
with open("en_bigram.csv") as f:
@ameerkat
ameerkat / worldnews_fastai_classifier.ipynb
Last active April 10, 2021 17:16
fast.ai example notebook for training a classifier on reddit
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MineRobber9000
MineRobber9000 / donotuse3.py
Last active February 8, 2024 12:48
How to NEVER use lambdas - Python 3 edition
###########################################################
# How to NEVER use lambdas. An inneficient and yet educa- #
# tonal [sic] guide to the proper misuse of the lambda #
# construct in Python 3.x. [DO NOT USE ANY OF THIS EVER] #
# original by (and apologies to): e000 (13/6/11) #
# now in Python 3 courtesy of: khuxkm (17/9/20) #
###########################################################
## Part 1. Basic LAMBDA Introduction ##
# If you're reading this, you've probably already read e000's
@davidkyle
davidkyle / README.md
Last active December 12, 2020 09:50
Aggregations and Visualisations supporting the Inference Pipeline Agg blog

Getting started with the Inference Aggregation

First ingest the customer churn data and trained model

Ingest the linked csv files above into Elastic using the Kibana Data Visualizer. You will find the Data Visualizer in the Machine Learning section. Ingest into the indices calls and customers.

@miladfa7
miladfa7 / gpt2_from_scratch.py
Last active April 30, 2023 06:54
Train GPT-2 from Scratch on your own language(Persain) | GPT-2 Training on non-english text
from simpletransformers.language_modeling import LanguageModelingModel
import logging
logging.basicConfig(level=logging.INFO)
transformers_logger = logging.getLogger("transformers")
transformers_logger.setLevel(logging.WARNING)
train_args = {
@benkehoe
benkehoe / aws-profile-for-bashrc.sh
Last active April 2, 2024 10:41
AWS_PROFILE env var management
# MIT No Attribution
#
# Copyright 2022 Ben Kehoe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so.
#
@sebsto
sebsto / gist:2ce59d80a3b5d30bb1ee456e96bf0fb0
Last active March 12, 2023 20:12
Redshift Materialized View Demo
drop table store;
drop table sales;
drop materialized view city_sales;
CREATE TABLE "sales" (
"id" int PRIMARY KEY,
"item" varchar,
@psychemedia
psychemedia / setup.txt
Created March 2, 2020 10:39
Initial test file for starting to look at binder config merge
mkdir -p binder binder_1 binder_2
cat > binder_1/requirements.txt << EOF
pandas
scipy
EOF
cat > binder_2/requirements.txt << EOF
ipython-sql
pandas