Skip to content

Instantly share code, notes, and snippets.

View ckarnell's full-sized avatar

Cohen Karnell ckarnell

  • https://trialspark.com/
  • New York City
View GitHub Profile
from flask import Flask
import random
import re
import chardet
app = Flask(__name__)
def detect_encoding(filename):
with open(filename, 'rb') as f:
raw_data = f.read()
file:///Users/cohen/midas-configuration/node_modules/axios/lib/core/settle.js:19
reject(new AxiosError(
^
AxiosError: Request failed with status code 413
at settle (file:///Users/cohen/midas-configuration/node_modules/axios/lib/core/settle.js:19:12)
at Unzip.handleStreamEnd (file:///Users/cohen/midas-configuration/node_modules/axios/lib/adapters/http.js:570:11)
at Unzip.emit (node:events:525:35)
at Unzip.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
@ckarnell
ckarnell / gist:8632685e240a017c74307e0ae9ad7e3a
Last active April 22, 2023 22:51
Remove twitter blue and blocked tweets from twitter on load and on scroll
// ==UserScript==
// @name Remove Verified and Blocked Accounts on Twitter Scroll
// @namespace remove-verified-blocked-accounts-on-twitter-scroll
// @version 1
// @description Remove verified and blocked accounts when you finish scrolling down the Twitter feed.
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
(function() {
#include "modes/PikaPalBattlefield.hpp"
#define ANALOG_STICK_MIN 48
#define ANALOG_STICK_NEUTRAL 128
#define ANALOG_STICK_MAX 208
#define ANALOG_STICK_NEUTRAL_TO_EDGE 80
PikaPalBattlefield::PikaPalBattlefield(socd::SocdType socd_type) : ControllerMode(socd_type) {
_socd_pair_count = 4;
_socd_pairs = new socd::SocdPair[_socd_pair_count]{
from typing import Any, Callable, Optional, Type, TypeVar
from mypy.plugin import Plugin, FunctionContext # pylint: disable=no-name-in-module
from mypy.types import TypedDictType # pylint: disable=no-name-in-module
A = TypeVar('A')
def safe_typeddict_cast(_: Type[A], data: Any) -> A:
# This function does nothing on its own, but the types are checked in mypy_plugin.py.
# The goal is to safely convert the data argument to the type of the first argument.
# The type will only be converted if it passes type checks. If it doesn't pass,
class CustomPlugin(Plugin):
def get_class_decorator_hook(self, fullname: str) -> Optional[Callable[[ClassDefContext], None]]:
def add_attributes_to_class_def_context(cls_def_context: ClassDefContext) -> None:
# Add types for values injected by container.inject
info = cls_def_context.cls.info
if fullname == 'nook.container' and 'primary_model' in info.names:
# import pdb
# pdb.set_trace()
# # TODO: Delete
for idx in range(len(cls_def_context.reason.arg_names)):
Commands are written in quotes below. u=up, r=right, d=down, and l=left.
Quick start:
Switch characters (defaults to P1): "p1" or "p2"
Move in a direction: "u" / "r" / "d" / "l"
Weak attack (A button): "a"
Medium attacks (directional): "tu", "tr", "td", "tl"
Strong attacks (C-stick directions): "cu" / "cr" / "cd" / "cl"
Jump: "j"
Special moves (directional): "bu" / "br" / "bd" / "bl"
# Add these to your .bashrc for fancy git logging:
# This optionally accepts a number as an argument (e.g. `gl 10`) to show that many commits.
# `gl` by itself will show all commits like a normal `git log`.
function gl {
if [ -z "$1" ]
then
git log --pretty=format:'%C(bold blue)%h %C(bold green)(%ar) %C(magenta)%an %Creset%s%C(bold yellow)%d'
else
git log --pretty=format:'%C(bold blue)%h %C(bold green)(%ar) %C(magenta)%an %Creset%s%C(bold yellow)%d' -$1
" Add this to your .vimrc and you will be able to use ':Ag <pattern>' to silver search from wherever you opened vim.
" You can also use 'ack' or whatever you want to use as a search tool as long as you have it installed.
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
command! -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
endif
" When you use ':Ag <pattern>' you can quickly look through / search each file containing the pattern and pick one to edit.
" YOU CAN ALSO DO ':cfdo <command>' TO RUN A COMMMAND ON EACH FILE IN THE SEARCH RESULT!!!
# Fancy git log. 'gl' shows the whole log, 'gl 5' shows the last 5 commits, etc.
function gl {
if [ -z "$1" ]
then
git log --graph --pretty=format:'%C(bold blue)%h %C(bold green)(%ar) %C(magenta)%an %Creset%s%C(bold yellow)%d'
else
git log --graph --pretty=format:'%C(bold blue)%h %C(bold green)(%ar) %C(magenta)%an %Creset%s%C(bold yellow)%d' -$1
fi
}