Skip to content

Instantly share code, notes, and snippets.

@a3f
a3f / Makefile
Created February 8, 2015 16:01
Simple Makefile template
# hereby released into the public domain (first time; Am I doing this right?)
#.
#├── Makefile
#│
#├── $(SRCDIR)
#│ └── $(SRCS) (source files)
#│
#├── $(OBJDIR)
#│ ├── *.o (automatically generated)
<?php
if(!defined('INITIALIZED'))
exit;
if(!$logged)
if($action == "logout")
$main_content .= '<div class="TableContainer" > <table class="Table1" cellpadding="0" cellspacing="0" > <div class="CaptionContainer" > <div class="CaptionInnerContainer" > <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span> <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span> <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span> <div class="Text" >Logout Successful</div> <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span> <span class="CaptionBorderB
<?php
if(!defined('INITIALIZED'))
exit;
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'logout')
Visitor::logout();
if(isset($_REQUEST['account_login']) && isset($_REQUEST['password_login']))
{
Visitor::setAccount($_REQUEST['account_login']);
Visitor::setPassword($_REQUEST['password_login']);
@a3f
a3f / maze.c
Last active August 29, 2015 14:20
Find all paths from that lead outside the maze starting from a given position
#include <stdio.h>
#include <stdlib.h>
#define I_MAX 11
#define J_MAX 8
enum {FREE = 0, BLOCKED = 1, END = 2, DONE, SOLUTION};
int maze[I_MAX][J_MAX] = {
{1, 0, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 1, 0, 1, 1},
{1, 0, 1, 0, 1, 1, 1, 1},
// engine.h
typedef struct{
unsigned height;
unsigned width;
char *buffer;
}screen_t[1];
screen_t screen_new(unsigned x, unsigned y);
void screen_delete(screen_t screen);
#!/usr/bin/perl
use Inline C => Config => LIBS => '-lm';
use Inline C;
use strict;
use warnings;
my $a = 81;
my $c = root($a);
print $c,"\n";
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
char *title = "Mandelbrot Set";
#define SIZE 600
#define ITERS 25
int main()
{
int x, y, i;
double zx, zy, cx, cy, tmp;
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <complex.h>
#include <math.h>
const char *title = "Mandelbrot Set";
#define SIZE 600
#define ITERS 25
int main(void)
/**
* argv[1]="769" doesn't work (with #define BUF_LEN 8)
* Environment: Windows 10 x86_64 with ../../../src/gcc-4.9.2/configure --host=i686-w64-mingw32
*
* Classical undefined behavior: recv's buffer is shorter than the buffer length supplied
* But not all wrong buffers are equal, when buf_len >= 769, the recv fails immediately,
* with no error code set, which is strange because there has been nothing recieved, so a wrong
* buffer length shouldn't have mattered right?
* If buf_len < 769 the code does what one would assume, blocking wai for a UDP packet
*/
@a3f
a3f / transpose.cc
Last active February 28, 2016 15:11
// http://stackoverflow.com/questions/11413855/why-is-transposing-a-matrix-of-512x512-much-slower-than-transposing-a-matrix-of
#define SAMPLES 100
#ifndef MATSIZE
#define MATSIZE 512
#endif
#include <ctime>
#include <iostream>
int mat[MATSIZE][MATSIZE];