Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / email-portion.md
Created September 18, 2018 17:43
Apple mail-in repair shipping instructions email

What happens next?

Shipping

You'll need to send us your original product before we can send you a replacement. Be sure to send only the product itself. If you include extra items in the box, we won't be able to return them to you. Also, send it to us within 10 business days. Otherwise, this repair request will be canceled.

We recommend that you pack your product in its original packaging or a suitable alternative. Ship the package using a courier service that provides a tracking number and proof of delivery. You may want to insure the value of the product when arranging shipment, as this will not be covered by Apple. Please address the package as follows:

@binki
binki / nodejs-interactive-session-regExp.lastIndex.txt
Created September 27, 2018 15:13
Demonstrate regExp.lastIndex
> process.version
'v8.12.0'
> const re = /a/g
undefined
> re.lastIndex
0
> re.test('asdf')
true
> re.lastIndex
1
2018
1월 2월 3월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 6 1 2 3 1 2 3
7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10
14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17
21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24
28 29 30 31 25 26 27 28 25 26 27 28 29 30 31
@binki
binki / rectangle_collision.py
Created October 25, 2018 21:27
Collide rectangles in Python (touching considered not a collision) with tests
#!/usr/bin/env python
class Rectangle:
def __init__(self, x, y, width, height):
self.x = x
self.y = y
self.width = width
self.height = height
# Alternative way of thinking about things
a 0 2
a 0.1 4
a 0.2 6
a 0.3 10
a 0.4 24
a 0.5 20
a 0.6 14
b 0 10
b 0.1 11
b 0.2 12
@binki
binki / blah.py
Created November 27, 2018 02:56
Python function binding
#!/usr/bin/env python
def my_func(x):
print(x)
def build_my_func_call(x):
def f():
my_func(x)
return f
XDocument.Parse("<x xml:space=\"preserve\">&#xd;\n</x>").Root.Value == "\r\n"
XDocument.Parse(XDocument.Parse("<x xml:space=\"preserve\">&#xd;\n</x>").ToString(SaveOptions.DisableFormatting)).Root.Value == "\r\n"
@binki
binki / README.md
Created January 16, 2019 17:10
mysql connection pooling in node.js

This is in reaction to http://www.madhur.co.in/blog/2016/09/05/nodejs-connection-pooling.html

It is critical that you remember to release connections to the pool if you are using pooling with the mysql module. It is best to use the pool.query() command if you can. You’ll know if you can’t.

Examples of things which cannot use pool.query() but must use pool.getConnection() followed by connection.release() are:

  1. Using transactions where you send multiple commands to the server.
  2. Sharing per-session data objects between subsequent commands sent to the server such as temporary tables.
// Copyright 2019 Nathan Phillip Brink
//
// 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, subject to
// the following conditions:
//