Skip to content

Instantly share code, notes, and snippets.

View valarauca's full-sized avatar

Cody Laeder valarauca

  • San Jose CA
View GitHub Profile
struct tpacket_req {
unsigned int tp_block_size; /* Minimal size of contiguous block */
unsigned int tp_block_nr; /* Number of blocks */
unsigned int tp_frame_size; /* Size of frame */
unsigned int tp_frame_nr; /* Total number of frames */
};
@valarauca
valarauca / lib.rs
Last active May 13, 2017 19:20
Open a Socket
extern crate libc;
use libc::{socket,setsockopt,bind,mmap,SOCK_DGRAM, PF_PACKET};
use std::io::{self, Error};
const ETH_P_IP: i32 = 0x0800i32;
//Open The Socket
pub fn open_raw_ip_socket() -> io::Result<i32> {
let socket_type: i32 = SOCK_DGRAM;
//socket_type
@valarauca
valarauca / browsejson.rs
Created April 29, 2017 21:06
Life time elison
extern crate json;
use json::JsonValue;
use json::object::Object;
use std::iter::Iterator;
enum Output<'a> {
Nothing,
Obj(&'a JsonValue),
Val(u64)
}
@valarauca
valarauca / reader.go
Created April 28, 2017 19:43
Testing parsing java definations from javadocs
package main
import (
"fmt"
html "golang.org/x/net/html"
atom "golang.org/x/net/html/atom"
"net/http"
"os"
"regexp"
"strings"
pub struct Foo {
key: String,
value: String
}
//Notice this type DERIVES Copy?
//that means this type will Copy, not move.
#[derive(Copy)]
pub struct CopyExample {
pub data: u64,
pub other_data: u32
}
fn move_example() {
fn movement_example_1() {
let x = Type::default();
let y = x;
assert_eq!(y,x); //COMPILER ERROR!
}
@valarauca
valarauca / movement_example.rs
Last active January 20, 2017 15:29
for a blgo post
fn movement_example_2() {
let x = 5.0f64;
let y = x;
assert_eq!(y,x); //Test Passed
}