Required tools for playing around with memory:
hexdump
objdump
readelf
xxd
gcore
#ifndef HASHMAP_H | |
#define HASHMAP_H | |
/* | |
* Generic implementation of hash-based key-value mappings. | |
* See Documentation/technical/api-hashmap.txt. | |
*/ | |
/* FNV-1 functions */ |
'use scrict'; | |
var fs = require('fs'); | |
var stat = fs.stat; | |
function copy(src, dest){ | |
fs.readdir(src, function(err, paths) { | |
if (err) { | |
console.log(err); | |
throw err; |
var config = make(map[string]interface{}) | |
func loadConfig(path string) (err error) { | |
if _, err := os.Stat(path); os.IsNotExist(err) { | |
log.Fatal("config file path is not exist") | |
} | |
file, err := os.Open(path) | |
if err != nil { | |
log.Fatal("can not open: ", path) |
package main | |
import ( | |
"container/list" | |
"fmt" | |
"time" | |
"math/rand" | |
) | |
func init() { | |
rand.Seed(time.Now().UnixNano()) |
#!/bin/sh | |
# Create message to be encrypted | |
echo "Creating message file" | |
echo "---------------------" | |
echo "My secret message" > message.txt | |
echo "done\n" | |
# Create asymmetric keypair | |
echo "Creating asymmetric key pair" | |
echo "----------------------------" |
# tcpdump the localhost port to a pcap file | |
tcpdump -i lo 'port 3000' -w result.pcap | |
# view the pcap file using tcpdump | |
tcpdump -qns 0 -A -r result.pcap | |
# tcpdump the to dest host package to a pcap file | |
tcpdump -i eth1 -vv -n dst host 9.78.206.6 -w result.pcap |
#include <stdio.h> | |
void pbits(char); | |
int main() { | |
int n = 1025; | |
char* p = (char*)&n; | |
for (int i = 0; i < sizeof(n); i++) { | |
printf("%d byte: ", i); |
func ip2int(ip string) uint32 { | |
IP := net.ParseIP(ip) | |
if len(IP) >= 16 { | |
return binary.BigEndian.Uint32(IP[12:16]) | |
} else { | |
return 0 | |
} | |
} |
func GBKToUTF8(data []byte) []byte { | |
UTF8Reader := transform.NewReader(bytes.NewReader(data), simplifiedchinese.GBK.NewDecoder()) | |
b, e := ioutil.ReadAll(UTF8Reader) | |
if e != nil { | |
log.Error("read GBKReader failed, error: %s, GBKReader: %v", e.Error(), UTF8Reader) | |
return nil | |
} | |
return b | |
} |