Skip to content

Instantly share code, notes, and snippets.

@jake-low
jake-low / .block
Last active October 2, 2017 00:01
world population density (2015)
license: gpl-3.0
height: 600
scrolling: no
border: yes
@jake-low
jake-low / keybase.md
Created August 16, 2016 02:25
Keybase proof

Keybase proof

I hereby claim:

  • I am jake-low on github.
  • I am jakelow (https://keybase.io/jakelow) on keybase.
  • I have a public key ASBPRVrv4XQRXkl38Q7ZVSn0ODXbUBIgdFwWVUZRrfSFRgo

To claim this, I am signing this object:

@jake-low
jake-low / intro.md
Last active August 29, 2015 14:20
google/protobuf (v2.5.0) python vs cpp behaviour comparison: parsing empty string

This gist is a demonstration of an inconsistency between the google/protobuf Python and C++ implementations (in protobuf release version 2.5.0).

The inconsistency is in parsing of protobuf messages from strings. In C++, attempting to parse a message with one or more required fields fails if the input string is empty. In python, a message can always be parsed from the empty string, even if it has required fields.

Below you'll find a simple program. A Teacher object and a Student object are instantiated. The teacher administers a simple test to the student. They communicate via serialized protobuf messages. First, the teacher serializes a real MultipleChoiceQuestion message and the student replies to it. Then, the teacher attempts to "trick" the student by having them attempt to decode a MultipleChoiceQuestion from an empty string, instead of from a buffer containing a serialized message. The teacher checks whether the student "notices" that the message is empty (

#!/bin/sh
#
# git-svn-diff
#
# Generate an SVN-compatible diff against the tip of the tracking branch. Useful if you
# use git svn (ie. your organization is on SVN but you prefer git) and you need to be
# able to generate SVN-compatible patches for code review tools like ReviewBoard, or
# other code-sharing purposes.
#
# Modified from Cristoph's script, as posted here: http://stackoverflow.com/a/4308184/1085300

"Connection reset by peer" is the TCP/IP equivalent of slamming the phone back on the hook. It's more polite than merely not replying, leaving one hanging. But it's not the FIN-ACK expected of the truly polite TCP/IP converseur.

From here

std::list<int> myList = { 4, 1, 2, 2, 9, 3 };
std::list<int>::const_iterator it = myList.begin();
if (it != myList.end()) {
printf("has an element");
while (++it != myList.end()) {
printf("has another element");
}
}
#!/bin/fish
docker stop (docker ps -a -q)
docker rm (docker ps -a -q)
,[.[-],]
copy input stream to output (like a pipe)
>,[>,]<[<]>[.>]
copy input string to output
>,[>,]<[.<]
reverse input
>>,[>>,]<<[[-<+<]>[>[>>]<[.[-]<[[>>+<<-]<]>>]>]<<]
#!/bin/sh
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "*click*"