Skip to content

Instantly share code, notes, and snippets.

View benaryorg's full-sized avatar

Katze benaryorg

View GitHub Profile
@benaryorg
benaryorg / datarev.c
Last active August 29, 2015 14:03
C data reversal function (recursive)
void _datarev(char *base,char *data,const unsigned int len)
{
if(data-len<=base)
{
char ch=*data;
_datarev(base,data+1,len);
base[(base-data)+len]=ch;
}
}
@benaryorg
benaryorg / selfpointer.c
Created June 28, 2014 10:48
I am playing with some Pointers.
void ****************************getmemypointer(void)
{
void **tmp=malloc(sizeof(void *));
*tmp=(void *)&tmp;
//I am totally not sure if _this_ works.
return (void ****************************)tmp;
}
@benaryorg
benaryorg / split.cpp
Created July 6, 2014 20:50
C++ program to split a file into single words
/*
* This little program splits a whole file into single words,
* which get saved in a list.
* A word is everything between two non-printable characters.
*
* Made by @benaryorg (2014)
* License: WTFPL
*/
#include <cstdio>
@benaryorg
benaryorg / get.c
Created July 10, 2014 13:49
Minimal C program to get a website (only http) written to stdout
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <curl/curl.h>
size_t write(void *buffer,size_t size,size_t nmemb,void *userp)
{
char **data=(char **)userp;
@benaryorg
benaryorg / Main
Last active August 29, 2015 14:15 — forked from anonymous/Main
#include <iostream>
#include <cassert>
#include <string>
using namespace std;
const char EOI('.');
const char EOT('#');
const int MAX(10);
int main() {
### Keybase proof
I hereby claim:
* I am benaryorg on github.
* I am benaryorg (https://keybase.io/benaryorg) on keybase.
* I have a public key whose fingerprint is 4A1B 3155 6D86 7198 1370 C471 D007 3D31 AB13 D7F8
To claim this, I am signing this object:
@benaryorg
benaryorg / annoy.sh
Last active August 29, 2015 14:18
annoy people
#!/bin/sh
while :;do
xset dpms force off
done
@benaryorg
benaryorg / functs.c
Last active August 29, 2015 14:19
read/write file in C
#include <stdio.h>
#define USED_FILE "file.txt"
void write(void)
{
FILE *f=fopen(USED_FILE,"rb");
//I always use 'b' for binary because it does not make any difference except the thing with EOF.…
//in text mode -1==EOF, that means if a file contains the byte 0xff this is interpreted as EOF even if the file is longer
@benaryorg
benaryorg / Makefile
Last active August 29, 2015 14:19
somthing with ncurses I think
SRCPATH:=.
SRCS=$(shell find $(SRCPATH) -regextype posix-extended -regex '^.+\.(c)$$')
OBJS=$(addprefix build,$(addsuffix .o,$(basename $(SRCS:$(SRCPATH)%=%))))
CC:=gcc
LD:=gcc
LDFLAGS:=-lncurses
CFLAGS:=$(addprefix -I,$(SRCPATH))
@benaryorg
benaryorg / index.cgi
Created May 1, 2015 17:09
nginx getmyip site
#!/bin/sh
echo "Server: $SERVER_SOFTWARE
Content-Type: text/plain; charset=UTF-8
$REMOTE_ADDR:$REMOTE_PORT"