Skip to content

Instantly share code, notes, and snippets.

View allenluce's full-sized avatar

Allen Luce allenluce

  • Seattle, WA
View GitHub Profile
diff --git a/lyfe-mobile/openx_proto/openx_proto.pb.go b/lyfe-mobile/openx_proto/openx_proto.pb.go
index 2f2f102..e6db8cf 100644
--- a/lyfe-mobile/openx_proto/openx_proto.pb.go
+++ b/lyfe-mobile/openx_proto/openx_proto.pb.go
@@ -631,6 +631,44 @@ func (m *User) GetExt() []*ExtKeyValue {
return nil
}
+type App struct {
+ id *string `protobuf:"bytes,1,opt,name=idb" json:"id,omitempty"`
% ./sleeper &
[1] 6078
% ./sleeper
[1] + 6078 running ./sleeper
var startupErr error
startupTimeoutChan := make(chan bool)
go func() {
for i := 5; i >= 0; i-- {
time.Sleep(time.Second)
startupTimeoutChan <- i == 0
}
}()
@allenluce
allenluce / base.js
Created November 12, 2015 19:12
One way of cross-module node.js inheritance
module.exports = function() {
console.log("In base constructor.");
}
module.exports.prototype.myfunc = function() {
console.log("This is the base.");
}
@allenluce
allenluce / bench.js
Created December 9, 2015 21:39
Benchmarking hasOwnProperty vs. conditional test for property
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var req = {
someProperty: "some value"
};
var property = "someProperty";
var notAProperty = "someProperty";
@allenluce
allenluce / gist:7df5c26f4930ca77e481
Created January 26, 2016 22:21 — forked from mejibyte/gist:1233426
My implementation of Aho-Corasick's algorithm for string matching.
using namespace std;
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
describe('proxy', function () {
it('context', function () {
const sandbox = {
p: new Proxy.ProviderProxy('hey')
}
const context = new vm.createContext(sandbox)
const script = new vm.Script('value = p._get()')
script.runInContext(context)
expect(sandbox.value).to.equal('hey')
})
@allenluce
allenluce / gist:f71c89414e4c422102ec5ac8f9c8b966
Created June 30, 2016 19:12
Simple packet printer for scapy
from scapy.all import *
INPUTFILE = "rmp.imps"
for pkt in PcapReader(INPUTFILE):
if TCP in pkt:
length = pkt[IP].len-40
if length > 0:
ack = pkt[TCP].ack # Acknowledged sequence number seq = pkt[TCP].seq # Packet sequence number ip_src=pkt[IP].src
ip_dst=pkt[IP].dst
calc.Dimension = &[2]map[string]*int32{
{
"dim1": i(31),
"dim2": i(37),
"dim3": i(41),
"dim4": i(43),
},
{
"dim5": i(47),
"dim6": i(53),
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 4 Or Target.Column = 5 Or Target.Column = 6 Then
Target.Value = Target.Value * 0.22
End If
Application.EnableEvents = True
End Sub