Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@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
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 / 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
@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 / build-precache-fixup.js
Created August 3, 2018 05:46
Work Around main.«hash».js missing from service-worker.js
#!/usr/bin/env node
// Works around issue described at
// https://github.com/facebook/create-react-app/issues/3574#issuecomment-410141752
// To use, add this as “&& ./build-precache-fixup.js” to
// package.json/scripts.build.
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
@binki
binki / gist:bf979cfaeb2ec503a2b6c96ee752de80
Created July 27, 2018 01:00
hexdump of extraneous carriage return in C# file CodeFixed to have missing using statement in visualstudio-15.7.5
binki@DESKTOP-QPI02O2 MSYS ~/source/repos/AddMissingUsingExtraneousCarriageReturn/AddMissingUsingExtraneousCarriageReturn
$ hexdump -C Class2.cs
00000000 ef bb bf 75 73 69 6e 67 20 53 79 73 74 65 6d 2e |...using System.|
00000010 49 4f 3b 0d 0a 75 73 69 6e 67 20 53 79 73 74 65 |IO;..using Syste|
00000020 6d 2e 54 65 78 74 2e 52 65 67 75 6c 61 72 45 78 |m.Text.RegularEx|
00000030 70 72 65 73 73 69 6f 6e 73 3b 0a 0a 6e 61 6d 65 |pressions;..name|
00000040 73 70 61 63 65 20 41 64 64 4d 69 73 73 69 6e 67 |space AddMissing|
00000050 55 73 69 6e 67 45 78 74 72 61 6e 65 6f 75 73 43 |UsingExtraneousC|
00000060 61 72 72 69 61 67 65 52 65 74 75 72 6e 0a 7b 0a |arriageReturn.{.|
00000070 20 20 20 20 63 6c 61 73 73 20 43 6c 61 73 73 32 | class Class2|
@binki
binki / code.csx
Created July 6, 2018 14:38
Type.IsAssignableFrom Truth Table
Console.WriteLine("| `left` | `right` | `left.IsAssignableFrom(right)` |");
Console.WriteLine("| --- | --- | --- |");
var types = new[] {
typeof(object),
typeof(string),
};
foreach (var left in types) {
foreach (var right in types) {
Console.WriteLine($"| {left} | {right} | {left.IsAssignableFrom(right)} |");
}
@binki
binki / glip-all-validate_string-excerpt-20180626.js
Last active September 25, 2018 13:53
Excerpt of Glip weird “do not send scripts” JavaScript
EC_Model.prototype.validate_string=function(a,b,c) {
if(!_.isNull(a)) {
if(_.isString(a)) {
if(a.length>b) {
return Errors.Too_Long(b);
}
if(a.match(/<script/gi)) {
return Errors.No_Script();
} }else {
return Errors.Invalid_Type();
@binki
binki / text.txt
Created June 26, 2018 15:17
text containing something that looks like an HTML/XML comment
a
<!-- hi -->
b
@binki
binki / gist:c8dfdf8ef3b7fde092f2b08ad235015a
Created June 18, 2018 15:16
Encoding.Default on Windows en-us
> System.Text.Encoding.Default.HeaderName
"Windows-1252"