Skip to content

Instantly share code, notes, and snippets.

@stetro
stetro / ipcheck.sh
Created April 16, 2012 18:13
IP Checker
for i in "139.6.57.1" "139.6.57.8" "139.6.57.11" "139.6.57.63" "139.6.57.66"
do
ping -c 1 $i > /dev/null
if [ $? == 0 ]
then
echo "$i is online : $i"
else
echo "$i is offline : $i"
fi
done
@stetro
stetro / calculator.c
Created April 27, 2012 07:08
C Parameter Taschenrechner
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char* argv[])
{
int i=0; // Laufvariable fuer alle Parameter
long int solution; // Ergebnisvariable
char op; // aktueller Operand
// Wenn keine Parameter angegeben sind
@stetro
stetro / env.c
Created April 27, 2012 07:09
C Umgebungsvariablen auslesen, erstellen und ändern
#include<stdio.h>
#include<stdlib.h>
// #include<unistd.h> (char ** environ) (alternative zu char*envp[])
int main(int argc, char* argv[],char *envp[])
{
char * variable; // Definierte Variable
int i = 0; // Laufvariable
// Gib alle Variablen aus wenn keine Parameter gegeben sind
@stetro
stetro / forks.c
Created April 27, 2012 07:10
C Prozesse Erzeugen und Ausgaben generieren
#include<stdio.h>
#include<stdlib.h>
#define PROCESS 3
#define LOOP 20
// Prozessinstruktionen
void run_process(int i);
@stetro
stetro / pipe.c
Created April 27, 2012 07:12
C Pipe zwischen 2 Programmen erstellen und beide Programme aufrufen
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#define PARAM_ERROR "Falsche Angabe von Parametern !\n"
#define FORK_ERROR "Kinprozess konnte nicht erzeugt wernden !\n"
#define PIPE_ERROR "Pipe konnte nicht erzeugt werden !\n"
#define DUP2_ERROR "IO-Stream konnte nicht dupliziert werden !\n"
/*
@stetro
stetro / fifo.c
Created April 27, 2012 07:16
C Benannte Pipe Erstellen und Client/Server Applikation
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<errno.h>
#define FIFO_NAME "fifo"
#define ARGUMENT_ERROR "a.out < s/r >\n"
@stetro
stetro / pisspott1.c
Created June 1, 2012 12:57
Piss Pott mit raceconditions
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#define MAXCOUNT ((FUSS_B+FUSS_A)*17)
#define FUSS_B 15.51337
@stetro
stetro / rcanalyse.sh
Created June 1, 2012 13:01
Analyse Shellskript für Piss Pott mit Racecondition (https://gist.github.com/gists/2851948)
#!/bin/bash
#GNUPLOT WIRD BENOETIGT !!!!
#Getestete Ausgabe:
# RaceCondition Verhalten
#
# 30 ++------------+-------------+-------------+-------------+------------++
# ******** + + Raceconditions zu Wartezeit ****** +
# | * : : + + |
# 25 ++......*............................................................++
@stetro
stetro / pisspott2.c
Created June 1, 2012 13:02
Piss Pott Ohne Raceconditions mit Semaphoren
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/wait.h>
#define MAXCOUNT ((FUSS_B+FUSS_A)*17)
@stetro
stetro / pisspott2.c
Created June 4, 2012 15:16 — forked from stetro/pisspott2.c
Piss Pott Ohne Raceconditions mit Semaphoren
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/wait.h>
#include <errno.h>
#include <string.h>