Skip to content

Instantly share code, notes, and snippets.

View iDanielLaw's full-sized avatar

Daniel Law iDanielLaw

  • Imagine No Limit Technology
View GitHub Profile
@masahirompp
masahirompp / User.ts
Last active May 5, 2021 20:04
mongoose + typescript
/// <reference path="../tsd/tsd.d.ts" />
import mongoose = require('mongoose');
import passport = require('passport');
interface IUser extends mongoose.Document {
provider: string;
id: string;
authorId: string;
displayName: string;
@whyrusleeping
whyrusleeping / gob.go
Created October 16, 2014 06:07
golang gob interface example
package main
import (
"bytes"
"encoding/gob"
"fmt"
)
type MyFace interface {
A()
@reterVision
reterVision / udp_client.go
Created July 12, 2014 07:50
A dummy UDP hole punching sample in Go
package main
import (
"encoding/json"
"fmt"
"log"
"net"
"os"
"time"
)
@axgle
axgle / sync.Pool.md
Last active December 18, 2022 09:56

What is sync.Pool in golang and How to use it

sync.Pool (1/2)

Many Go libraries include custom thread-safe free lists, like this:

var objPool = make(chan *Object, 10)

func obj() *Object {

select {

function construct(constructor, args) {
function F() {
return constructor.apply(this, args);
}
F.prototype = constructor.prototype;
return new F();
}
// Sanboxer
function sandboxcode(string, inject) {
"use strict";
@vishvananda
vishvananda / tunnel.sh
Created October 22, 2013 03:16
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift
@glennzw
glennzw / fcs.txt
Last active June 4, 2019 14:09
FCS - Frame Check Sequence
I'm capturing 802.11 frames - probe requests to be exact. I'm noticing occasional garbled data, so would to incorporate the Frame Check Sequence (FCS) to ensure frame integrity. I'd expect the card to dump failed checksum frames, but maybe this doesn't happen in promisc mode. We can see the FCS in action with tshark like so:
# tshark -i mon0 -R 'wlan.fcs' -T fields -e wlan.fcs_good -e wlan.fcs
1 0x5c1eecd5
0 0x8d425ccf
1 0xb28bb592
1 0xd2cb1bf6
...where wlan.fcs is the calculated checksum, and wlan.fcs_good is the boolean of the result.
DEFAULT ramdisk
LABEL ramdisk
kernel /casper/vmlinuz
append boot=casper initrd=/casper/initrd.img
LABEL isotest
kernel /casper/vmlinuz
append boot=casper integrity-check initrd=/casper/initrd.img
LABEL memtest
kernel /install/memtest
append -