Skip to content

Instantly share code, notes, and snippets.

View akoskovacs's full-sized avatar

Ákos Kovács akoskovacs

View GitHub Profile
@akoskovacs
akoskovacs / scode.c
Created January 5, 2013 15:14
32bit self-modifying multiplying Intel code.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
typedef int (*func_t)(void);
int main(int argc, char *argv[])
{
/* push %ebp
@akoskovacs
akoskovacs / smod.c
Created January 5, 2013 14:42
Self modifing code in C.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
typedef int (*func_t)(void);
int main(int argc, char *argv[])
{
char *fstart = "\x55\x48\x89\xe5\x48\x31\xc0";
@akoskovacs
akoskovacs / hello.c
Created December 3, 2012 00:31
AkLisp hello, world module
#include <aklisp.h>
#include <stdio.h>
AKL_CFUN_DEFINE(hello, in, args)
{
printf("Hello, world from 'hello' module!\n");
/* Every function must return something,
the type of 'akl_value' */
return &NIL_VALUE;
}
@akoskovacs
akoskovacs / pgen.rb
Created November 28, 2012 23:15
pgm picture generator (gray gradient pattern)
#!/usr/bin/env ruby
HEIGHT = 1024
WIDTH = 1024
f = File.new("sample.pgm", "w")
f.puts "P2"
f.puts "#{HEIGHT} #{WIDTH}"
f.puts 255
f.puts "# Generated by pgen.rb (C) Akos Kovacs"
HEIGHT.times do |row|
@akoskovacs
akoskovacs / chat.rb
Last active September 13, 2023 22:38
Ruby chat server
#!/usr/bin/env ruby
# Run with
# $ chmod +x chat.rb && ./chat.rb
# or
# $ ruby chat.rb
require 'socket'
require 'thread'
@akoskovacs
akoskovacs / .vimrc
Created June 18, 2011 16:39
My .vimrc
syntax on
set autoindent
set smartindent
set nocp
filetype plugin on
au BufRead,BufNewFile *.rc set filetype=rc
set tabstop=4
set shiftwidth=4
set expandtab
set number