Skip to content

Instantly share code, notes, and snippets.

View madx's full-sized avatar

François Vaux madx

View GitHub Profile
void sgf_append_block(OFILE* file) {
TBLOCK b;
int adr;
adr = alloc_block ();
if (adr <= 0) panic ("Disque plein");
set_fat (adr, FAT_EOF);
void sgf_read_bloc(OFILE* file, int nubloc) {
int adr = file->first,
nb_bloc, init, i;
nb_bloc = ((file->length + BLOCK_SIZE - 1) / BLOCK_SIZE);
if (nubloc < 0) panic ("Numéro de bloc <= 0");
if (nubloc > nb_bloc) panic ("Numéro de block > nb de blocs");
adr = (file->memo != -1) ? file->memo : file->first;
void sgf_remove(int inode) {
TBLOCK b;
int adr, i;
read_block (inode, &b.data);
/* Effacement en chaîne si le fichier est sur plusieurs blocs */
if (b.inode.first != FAT_EOF) {
int cur, next;
cur = get_fat(b.inode.first);
/* 1ère exécution */
== Listing du disque
34 essai.txt 156o
=> 987 blocs libres
== essai.txt:
"Ceci est un petit texte qui occupe
void print_fat() {
TBLOCK b,ib;
int adr;
int i, k;
read_block(ADR_BLOCK_DEF, &b.data);
adr = b.super.adr_dir;
read_block(adr, &b.data);
if (!fat.in_memory)
#ifndef NETKIT_H_
#define NETKIT_H_
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
void ui_run_algorithm (Ui *u) {
GPtrArray *A = u->polys[0],
*B = u->polys[1],
*Conv;
GdkPoint *a, *b, *c, *ap, *bp,
p, q;
guint i, j;
reorder (A);
reorder (B);
@madx
madx / dexp.rb
Created January 5, 2011 15:13
Dice rolling expressions in Ruby w/ Treetop
require 'forwardable'
module Dexp
class Roll
attr_reader :count, :sides, :modifier
def initialize(count, sides, modifier)
@count, @sides, @modifier = count, sides, modifier
end
@madx
madx / touchpad_toggle.sh
Created February 25, 2011 09:51
Toggles the touchpad state using xinput
#!/bin/bash
prop="Device Enabled"
id="$(xinput list | grep -i touchpad | sed 's/.*id=\([0-9]\+\).*/\1/')"
state="$(xinput list-props $id | grep "$prop" | cut -d: -f2 | sed 's/\s//g')"
if [ "$state" = 1 ]; then
xinput --set-prop $id "$prop" 0
else
@madx
madx / Instructions.mkd
Created February 23, 2012 15:10
Syslog Viewer

Instructions

MySQL

Create a MySQL database named syslog and a table called events (you may run the app once to automatically create the table). For rsyslog, you may use something like this :