Skip to content

Instantly share code, notes, and snippets.

View benaryorg's full-sized avatar

Katze benaryorg

View GitHub Profile
@benaryorg
benaryorg / mmapcat.c
Created May 1, 2015 22:10
mmap cat implementation
#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/mman.h>
int main(int argc,char **argv)
{
assert(argc==2);
int file=open(argv[1],O_RDONLY);
assert(file>0);
@benaryorg
benaryorg / httpget.rs
Last active August 29, 2015 14:21
get text from an HTTP server in rust
use std::net::*;
use std::io::prelude::*;
fn main()
{
let mut buf:String;
let ip="google.com";
let port=80;
@benaryorg
benaryorg / httpget2.rs
Last active August 29, 2015 14:21
get text from an HTTP server in rust with cli options
use std::env;
use std::net::*;
use std::io::prelude::*;
use getopts::Options;
extern crate getopts;
fn main()
{
let mut opts = Options::new();
@benaryorg
benaryorg / benarydev.c
Created May 14, 2015 18:34
linux device driver that grants arbitary memory access in a broken way
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/kdev_t.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/cdev.h>
static dev_t first;
@benaryorg
benaryorg / test1.sh
Created June 6, 2015 20:12
shell chaos
#!/bin/bash
set -E
trap '[ '$?' -ne 77 ] || exit 77' ERR
$(echo '$(exit 11)';exit 11)
(echo '(exit 11)';exit 11)
$(echo '$(exit 77)';exit 77)
@benaryorg
benaryorg / ui.qml
Last active September 3, 2015 22:06
very minimalistic editor in qml
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.0
ApplicationWindow
{
visible: true
title: "Meow"
id: win
@benaryorg
benaryorg / ui.qml
Last active September 3, 2015 22:05
qml button particles
import QtQuick 2.0
import QtQuick.Particles 2.0
import QtQuick.Window 2.0
import QtQuick.Controls 1.2
Window
{
visible: true
Rectangle
@benaryorg
benaryorg / alphabet.rs
Created July 15, 2015 17:04
writes the alphabet, each line shifted one character left
fn main()
{
for win in (0u32..26*8).collect::<Vec<_>>().windows(80)
{
for i in win
{
print!("{}",(('a' as u8)+((i%26u32) as u8)) as char);
}
println!("");
}
@benaryorg
benaryorg / getmyname.rs
Created July 16, 2015 17:05
get the name of the struct of a variable
#![feature(core_intrinsics)]
struct Something
{
data:u32,
}
impl Something
{
pub fn name(&self)->String
@AlisdairO As I already said over
[there](https://users.rust-lang.org/t/composed-iterators-compile-slowly/2114/4?u=benaryorg),
please format your code with triple backticks so we have some syntax
highlighting.
It works for rust:
```
fn main()
{