Skip to content

Instantly share code, notes, and snippets.

🏗
Building a better world, one bit at a time

Nick Kocharhook nk9

🏗
Building a better world, one bit at a time
  • London, UK
Block or report user

Report or block nk9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nk9
nk9 / views.py
Last active Oct 22, 2019
Flask-Security registration with pending role
View views.py
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
When you parse a GeoJSON string containing a MultiPolygon, leaflet.draw throws exceptions when you try to edit the resulting layer.
View leaflet.draw-error.html
<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>
View keybase.md

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 Jul 11, 2016
Mis-directed links in Ada
View adaWrongTarget.py
#!/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)
@nk9
nk9 / cfnetwork-map.json
Created Feb 5, 2015
This is a JSON mapping of CFNetwork versions to OS X versions. It's been culled from UserAgent strings.
View cfnetwork-map.json
{
"CFNetwork/1.1": "10.2",
"CFNetwork/1.2.1": "10.3.2",
"CFNetwork/1.2.2": "10.3.9",
"CFNetwork/1.2.6": "10.3.9",
"CFNetwork/128": "10.4.0 (PPC)",
"CFNetwork/128": "10.4.1 (PPC)",
"CFNetwork/128.2": "10.4.2 (PPC)",
"CFNetwork/129.10": "10.4.4",
"CFNetwork/129.10": "10.4.5",
@nk9
nk9 / largestFiles.py
Last active Dec 9, 2019
Python script to find the largest files in a git repository.
View largestFiles.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python script to find the largest files in a git repository.
# The general method is based on the script in this blog post:
# http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
#
# The above script worked for me, but was very slow on my 11GB repository. This version has a bunch
# of changes to speed things up to a more reasonable time. It takes less than a minute on repos with 250K objects.
#
View git-show-all-objects.sh
#!/bin/sh
set -e
cd "$(git rev-parse --show-cdup)"
# Find all the objects that are in packs:
if [ "$(ls -A .git/objects/pack)" ]
then
You can’t perform that action at this time.