Skip to content

Instantly share code, notes, and snippets.

View MapleLove2014's full-sized avatar
🎯
Focusing

maplelove MapleLove2014

🎯
Focusing
View GitHub Profile
/* At run-time deserialization of a protobuf buffer to a C++ object example
* Based on https://cxwangyi.wordpress.com/2010/06/29/google-protocol-buffers-online-parsing-of-proto-file-and-related-data-files/
* @author: Floris Van den Abeele <floris@vdna.be>
*
* Starting from a protobuf definition, main() does the following:
* 1) Translate protobuf definition to FileDescriptorProto object using the
* Parser from protoc. FileDescriptorProto seems to be nothing more than an
* in-memory representation of the proto definition.
* 2) Use a DescriptorPool to construct a FileDescriptor. FileDescriptor
* seems to contain all necessary meta data to describe all the members of a
@DmitrySoshnikov
DmitrySoshnikov / lex-start-conditions.md
Last active April 26, 2023 11:46
Lexer start conditions

Start conditions of lex rules, and tokenizer states

Start conditions are declared in the definitions (first) section of the input using unindented lines beginning with either %s or %x followed by a list of names. The former declares inclusive start conditions, the latter exclusive start conditions. A start condition is activated using the BEGIN action. Until the next BEGIN action is executed, rules with the given start condition will be active and rules with other start conditions will be inactive. If the start condition is inclusive, then rules with no start conditions at all will also be active. If it is exclusive, then only rules qualified with the start condition will be active. A set of rules contingent on the same exclusive start condition describe a scanner which is independent of any of the other rules in the flex input. Because of this, exclusive start conditions make it easy to specify "mini-scanners" which scan portions of the input that are syntactically different from the res

@samuel
samuel / thriftserde.go
Created May 27, 2014 18:25
Example of Thrift struct serialization / deserialization
package main
import (
"bytes"
"log"
"github.com/samuel/go-thrift/thrift"
)
type testStruct struct {
@goodmami
goodmami / logging.bash
Last active March 30, 2023 03:49
Basic logging commands for Linux shell scripts
#!/bin/bash
##
## Simple logging mechanism for Bash
##
## Author: Michael Wayne Goodman <goodman.m.w@gmail.com>
## Thanks: Jul for the idea to add a datestring. See:
## http://www.goodmami.org/2011/07/simple-logging-in-bash-scripts/#comment-5854
## Thanks: @gffhcks for noting that inf() and debug() should be swapped,
## and that critical() used $2 instead of $1
@hectormenendez
hectormenendez / extend.js
Created November 17, 2011 15:06
jQuery.extend
jQuery.extend = jQuery.fn.extend = function() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;