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 {
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 - |
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. |
#!/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 |
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"; |
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 {
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
"net" | |
"os" | |
"time" | |
) |
package main | |
import ( | |
"bytes" | |
"encoding/gob" | |
"fmt" | |
) | |
type MyFace interface { | |
A() |
/// <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; |
mainly used in start-up script
When we play with iptables aka firewall we might end up in situation, where we execute rule, which has unforseen impact - lock yourself out. Recovering from this situation is necessity.
How to:
- Enable reboot via SMS.
- Test all commands in shell first before putting them into Start-up script. This way the command will be wiped out, when unit is rebooted.