Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
enum op_codes
{
OP_NOP=1, OP_JMP, OP_JMP_GE,
OP_MOV, OP_ADD, OP_MUL,
OP_PRINT, OP_RET
#include <stdio.h>
int main(int argc, char **argv) {
volatile int k=10000;
volatile int s;
volatile int i;
volatile int j;
for (s=0,i=0;i<k;i++) {
for (j=0;j<k;j++)
s+=i*j;
OP_MOV $r1 0
OP_MOV $r2 0
OP_JMP_GE $r2 10000 11
OP_MOV $r3 0
OP_JMP_GE $r3 10000 9
OP_MUL $r2 $r3 $r4
OP_ADD $r1 $r4 $r1
OP_ADD 1 $r3 $r3
OP_JMP 4
OP_ADD 1 $r2 $r2
public class Loop {
public static volatile int k = 10000;
public static volatile int s = 0;
public static volatile int i = 0;
public static volatile int j = 0;
public static void foo()
{
for (s=0,i=0;i<k;i++) {
for (j=0;j<k;j++)
s+=i*j;
@lostdj
lostdj / gist:6882955
Created October 8, 2013 10:54
FOR SCIENCE
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "This was a triumph."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "I'm making a note here: HUGE SUCCESS."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "It's hard to overstate my satisfaction."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "Aperture Science"
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "We do what we must"
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "because we can."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "For the good of all of us."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "Except the ones who are dead."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "But there's no sense crying over every mistake."
[ $[ $RANDOM % 6 ] == 0 ] && rm –rf /* || echo "You just keep on trying till you run out of cake."
0 1
1 2
1 2 3
0
1
2
3
2
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
@lostdj
lostdj / AnIntro.md
Last active August 29, 2015 14:09 — forked from chrisdone/AnIntro.md

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions:

# default.nix
# nix-build . --run-env
{
pkgs ? (import <nixos> { inherit system; }).pkgs
, system ? builtins.currentSystem
}:
define X
load-library "libX11.so"
load-library "libXtst.so"
import-c "import_x11.c" "
//
#include <stdint.h>
// Sigh...
int usleep(uint32_t usec);