Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nk9's full-sized avatar
🏗️
Building a better world, one bit at a time

Nick Kocharhook nk9

🏗️
Building a better world, one bit at a time
  • London, UK
View GitHub Profile
[tool.isort]
profile = "black"
multi_line_output = 3
known_first_party = ["tests"]
skip_glob = ["migrations/*"]
[tool.black]
extend-exclude = "^/migrations/"
line-length = 120
@nk9
nk9 / github_user_script.js
Created December 29, 2022 19:30
User script for scraping GitHub results as URLs
// ==UserScript==
// @name Copy GitHub results
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/search*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@nk9
nk9 / get_dropbox_url.py
Last active April 19, 2023 12:32
Python script to get the URL of a file in the Dropbox folder
#
# Don't use this version, it is out of date.
# See the newest version in the GitHub repository:
#
# https://github.com/nk9/get_dropbox_link
#
@nk9
nk9 / KVLWindow.swift
Last active May 7, 2021 08:56
A window that uses overlays to show its first responder and ALL of the views which have that responder as their nextValidKeyView. Useful for debugging key view loop issues in macOS applications.
//
// KVLWindow.swift
// KVLTest
//
// Created by Nick Kocharhook on 04/05/2021.
// Based in part on LMWindow by Micha Mazaheri
//
// Released under the MIT License: http://opensource.org/licenses/MIT
//
// Copyright 2021 Nick Kocharhook
@nk9
nk9 / LMWindow.m
Last active August 25, 2020 16:25 — forked from mittsh/LMWindow.m
How to debug your key view loop: highlights
/*
* Copyright (c) 2013 Micha Mazaheri
* Released under the MIT License: http://opensource.org/licenses/MIT
*
* Updated to work on Xcode 11 in 2020 by Nick Kocharhook
*/
#define LMWindowDEBUGResponders
#ifdef LMWindowDEBUGResponders
@nk9
nk9 / nick.zsh-theme
Created February 17, 2020 18:57
My oh-my-zsh theme
setopt prompt_subst
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )%{$reset_color%}"
PROMPT+=' %(!.%{$fg[red]%}.%{$fg[green]%})$(shrink_path -l -t)%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} '
RPROMPT='%*'
ZSH_THEME_GIT_PROMPT_PREFIX=" ("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_DIRTY=" ✗"
ZSH_THEME_GIT_PROMPT_CLEAN=" ✔"
@nk9
nk9 / views.py
Last active January 13, 2024 15:17
Flask-Security registration with pending role
from flask_security.decorators import anonymous_user_required
from flask_security.utils import encrypt_password
from flask_security.confirmable import send_confirmation_instructions
@bp.route('/register/', methods=['GET', 'POST'])
@anonymous_user_required
def register():
form = ExtendedRegistrationForm(request.form)
if form.validate_on_submit():
@nk9
nk9 / leaflet.draw-error.html
Last active May 25, 2019 16:05
When you parse a GeoJSON string containing a MultiPolygon, leaflet.draw throws exceptions when you try to edit the resulting layer.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet-src.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw-src.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.css"/>
</head>
<body>
<div id="map" style="width: 500; height: 500"></div>

Keybase proof

I hereby claim:

  • I am nk9 on github.
  • I am k9 (https://keybase.io/k9) on keybase.
  • I have a public key ASDidn08tGKp2M4ugDD0cE1gl-8vD44qx5oRz9jJrjUPpgo

To claim this, I am signing this object:

@nk9
nk9 / adaWrongTarget.py
Last active July 11, 2016 21:22
Mis-directed links in Ada
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
urlFormat = "http://www.ada.auckland.ac.nz/ada1%d.htm"
urls = [urlFormat % x for x in range(1, 40)] # Only chapteres 1-39 are annotated
for url in urls:
response = requests.get(url)