Skip to content

Instantly share code, notes, and snippets.

@mRB0
mRB0 / break_upload.ino
Created June 30, 2012 23:46
Arduino Mega 2560 sketch that hangs on upload
prog_uint8_t const wavelet[] PROGMEM =
// On Arduino Mega 2560:
// When uncommented, this breaks the upload.
{ 0x1f, 0x1f, 0x22, 0x24, 0x24, 0x22, 0x20, 0x22, 0x1f, 0x20, 0x22, 0x21, 0x3f, 0x21, 0x1f, 0x21, 0x3f, 0x3e, 0x3e, 0x3c, 0x1f, 0x21, 0x3e, 0x3c, 0x3c, 0x3e, 0x3e, 0x3d, 0x39, 0x3c, 0x21, 0x1f, 0x21, 0x21, 0x25, 0x26, 0x26, 0x3e, 0x3c, 0x3e, 0x1f, 0x3c, 0x39, 0x3a, 0x22, 0x23, 0x1f, 0x20, 0x3c, 0x20, 0x20, 0x3b, 0x3e, 0x21, 0x3c, 0x3b, 0x36, 0x3c, 0x3b, 0x3e, 0x3e, 0x3c, 0x39, 0x3e, 0x3e, 0x1f, 0x3b, 0x3e, 0x20, 0x21, 0x3e, 0x21, 0x23, 0x23, 0x21, 0x3e, 0x22, 0x26, 0x2a, 0x22, 0x20, 0x3b, 0x1f, 0x3f, 0x3c, 0x39, 0x25, 0x2f, 0x2d, 0x2f, 0x2c, 0x2b, 0x2c, 0x24, 0x28, 0x2a, 0x22, 0x26, 0x23, 0x22, 0x20, 0x3e, 0x3c, 0x3a, 0x38, 0x1f, 0x3e, 0x3a, 0x32, 0x35, 0x35, 0x35, 0x2f, 0x2f, 0x32, 0x35, 0x35, 0x35, 0x37, 0x3e, 0x20, 0x3d, 0x38, 0x34, 0x38, 0x3b, 0x3e, 0x3c, 0x20, 0x28, 0x24, 0x20, 0x20, 0x21, 0x29, 0x22, 0x1f, 0x24, 0x20, 0x3e, 0x37, 0x36, 0x3b, 0x3b, 0x1f, 0x20, 0x3b, 0x1f, 0x1f, 0x20, 0x37,
--
-- compiles
--
main = do
handler <- streamHandler stderr DEBUG
updateGlobalLogger rootLoggerName $ setHandlers [handler]
--
-- doesn't compile (added setFormatter)
<NSLayoutConstraint:0x786308a0 'UIView-Encapsulated-Layout-Width' H:[COSEventTitleCell:0x7917b820'COSEventTitleCell'(10000)]>,
<NSLayoutConstraint:0x7865c710 'UIView-Encapsulated-Layout-Height' V:[COSEventTitleCell:0x7917b820'COSEventTitleCell'(10000.5)]>,

Keybase proof

I hereby claim:

  • I am mrb0 on github.
  • I am mrb0 (https://keybase.io/mrb0) on keybase.
  • I have a public key whose fingerprint is CD09 A721 5E85 9024 4F77 E3A1 2811 75B4 AE5B 4A73

To claim this, I am signing this object:

@mRB0
mRB0 / gist:740c25fdae3dc0b0ee7a
Created June 2, 2015 17:35
why aren't all objective-C programs written in python?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from contextlib import contextmanager
import ctypes
import ctypes.util
from ctypes import CFUNCTYPE
objc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('objc'))
@mRB0
mRB0 / ntfs-find-files-affected-by-ddrescue-bad-chunks.py
Created March 19, 2016 18:43
After you use gnu ddrescue on a drive with an NTFS filesystem, this script uses your ddrescue logfile & ntfs-3g to list files affected by unrecoverable bad chunks
#!/usr/bin/env python
import sys
import os
import subprocess
import re
from StringIO import StringIO
# usage:
#

ASP.NET AJAX: Inside JSON date and time string

The AJAX JSON serializer in ASP.NET encodes a DateTime instance as a JSON string. During its pre-release cycles, ASP.NET AJAX used the format "@ticks@", where ticks represents the number of milliseconds since January 1, 1970 in Universal Coordinated Time (UTC). A date and time in UTC like November 29, 1989, 4:55:30 AM would be written out as "@62831853071@." Although simple and straightforward, this format cannot differentiate between a serialized date and time value and a string that looks like a serialized date but is not meant to be deserialized as one. Consequently, the ASP.NET AJAX team made a change for the final release to address this problem by adopting the "\/Date(ticks)\/" format.

The new format relies on a small trick to reduce the chance for misinterpretation. In JSON, a forward-slash (/) character in a string can be escaped with a backslash (\) even though it is not strictly required. Taking advantage of this, the ASP.NET AJAX team mod

Aug 24 20:14:39 pfSense php-cgi: rc.initial.reboot: Stopping all packages.
Aug 24 20:14:58 pfSense php-cgi: rc.initial.reboot: The command '/etc/rc.reboot > /dev/null 2>&1' returned exit code '139', the output was ''
Aug 24 23:14:58 pfSense kernel: pid 7216 (shutdown), uid 0: exited on signal 11 (core dumped)
@mRB0
mRB0 / share.bash
Last active March 18, 2017 16:49
A shell script replacement for the Dropbox public folder, using S3 for storage and serving.
#!/usr/bin/env bash
#
# Usage:
#
# share.bash file1 file2 file3 ...
#
#
# Simple setup:
@mRB0
mRB0 / gitconfig
Created May 11, 2017 13:21
git alias for ahead-behind count
[alias]
aheadbehind = !"f() { against=${1:-master}; git rev-list --left-right --count $against...HEAD | awk '{print \"You are \" $2 \" commit(s) ahead of '$against' and \" $1 \" commit(s) behind\"}'; }; f"