Skip to content

Instantly share code, notes, and snippets.

View GiorgioRegni's full-sized avatar

Giorgio Regni GiorgioRegni

View GitHub Profile
; LOOP for(t=0; t<max, t++)
store i32 0, i32* %t.addr
br label %loop_over_t
loop_over_t:
%t = load i32* %t.addr ; %t contains the loop counter current value
; ... DO SOME WORK ...
; increment t and loop
%t_plus_1 = add i32 1, %t
For each pixel on the screen do:
{
x0 = scaled x co-ordinate of pixel (must be scaled to lie somewhere in the interval (-2.5 to 1)
y0 = scaled y co-ordinate of pixel (must be scaled to lie somewhere in the interval (-1, 1)
ESCAPE = 2*2
x = 0
y = 0
iteration = 0
<result> = add i32 4, %var ; yields {i32}:result = 4 + %var
<result> = fadd float 4.0, %var ; yields {float}:result = 4.0 + %var
<result> = sub i32 0, %val ; yields {i32}:result = -%var
<result> = fsub float 4.0, %var ; yields {float}:result = 4.0 - %var
<result> = mul i32 4, %var ; yields {i32}:result = 4 * %var
<result> = fmul float 4.0, %var ; yields {float}:result = 4.0 * %var
<result> = udiv i32 4, %var ; yields {i32}:result = 4 / %var
<result> = sdiv i32 4, %var ; yields {i32}:result = 4 / %var
<result> = fdiv float 4.0, %var ; yields {float}:result = 4.0 / %var
<result> = urem i32 4, %var ; yields {i32}:result = 4 % %var
; Mandelbrot fractal constant, play with it to generate cool images
@MAXITER = internal constant i32 200
@ESCAPE = internal constant double 4.0
@XC = internal constant double -0.10894500736830963 ; center point x
@YC = internal constant double -0.8955496975621973 ; center point y
@ZOOM = internal constant double 0.1 ; zoom into the fractal
@W = internal constant i32 2048 ; image width
@H = internal constant i32 2048 ; image height
void write_bmp(unsigned char *img, int width, int height) {
bmpfile_t *bmp;
int i, j;
rgb_pixel_t palette[PALETE_NUM_COLORS] = {0};
if ((bmp = bmp_create(width, height, 32)) == NULL) {
printf("Could not create bitmap");
exit(-1);
}
-module(utils).
-export([comball/1]).
-export([comball/2]).
-export([combuniq/1]).
%% Return all combinations of R elements in list L
comb([], _) -> [[]];
comb(_, 0) -> [[]];
comb(L, R) -> [[H|T] || H <- L, T <- comb(L -- [H], R-1)].
@GiorgioRegni
GiorgioRegni / agressor.sh
Created November 17, 2015 18:55
Test script for our network investigation
#!/bin/sh
VICTIM="$1"
echo "Starting network tests to $VICTIM"
for CONNECTIONS in 1 10 100 1000 10000 ; do
echo $CONNECTIONS connections
iperf -P $CONNECTIONS -c $VICTIM
done
#!/bin/bash
while true; do
WAIT="$(( $RANDOM % 10 + 1 ))"
echo "Waiting $WAIT seconds"
sleep $WAIT
echo "Killing metadata nodes"
docker exec -it scality-metadata bash -c "pkill node"
docker exec -it scality-metadata bash -c "pkill RepdServerMap"
let foo=0;
encode(json) {
foo++;
const string = JSON.stringify(json);
const len = Buffer.byteLength(string);
const buf = Buffer.allocUnsafe(4 + len);
buf.writeInt32BE(len);
#!/usr/bin/python
import sys
import leveldb
import json
import collections
if len(sys.argv) != 3:
    print 'usage: script db bseq'
    sys.exit(1)
db = leveldb.LevelDB(sys.argv[1])
idx =int( sys.argv[2])-1