Skip to content

Instantly share code, notes, and snippets.

View nitrix's full-sized avatar

Alex Belanger nitrix

View GitHub Profile
<?php
$image = file_get_contents('http://example.com/image.jpg');
$fp = fopen('image.jpg', 'w');
fputs($fp, $image);
fclose($fp);
?>
<?php
$question = 'Why isn\'t anybody asking questions!?';
$causes = array('it\'s late', 'we talk too much and scare them', 'somebody just asked one', '42');
if ($this->destination == 'Jmz') {
echo 'A mystic error occurred! Please try-again!'."\n";
exit();
}
$n = rand(0, count($causes)-1);
unsigned int z = 1023;
unsigned int x = 1024;
unsigned int test,i;
/* test A */
double a = get_time();
for(i=0; i<1000000000; i++) {
test = 99999;
test &= z;
}
@nitrix
nitrix / gahello.php
Last active November 23, 2021 12:21
Hello World! Testing Genetic Algorithms in PHP
<?php
$POPULATION = array(); //population of individuals
$POPULATION_SIZE = 100;
$DNA_SIZE = 12;
$GEN_COUNT = 1;
$TEST_COUNT = 0;
genInitPopulation();
while (true) {
naturalSelection();
@nitrix
nitrix / example.php
Created October 29, 2012 04:48
Google two-way authentification in PHP
<?php
include('g2w.php');
$initkey = 'PEHMPSDNLXIOG65R'; // set the inital key or use generate_secret_key() for a new one
$timestamp = G2W::get_timestamp();
$secretkey = G2W::base32_decode($initkey); // decode it into binary
$otp = G2W::oath_hotp($secretkey, $timestamp); // get current token
echo 'Init key: '.$initkey."\n";
@nitrix
nitrix / dyntable.php
Created November 28, 2012 21:54
Dynamic table generator for Zack
Temporary
@nitrix
nitrix / dyntablegen.php
Created November 28, 2012 22:43
Dynamic table generator for Zack
<?php
//============= PARAMS ==============
$teacher = 'EMP000061'; //test teacher, can also be empty
$teacher = '';
$student = 'STU000545'; //test student, CANNOT be empty
//============= SQL QUERY ================
$query = '
SELECT
ra.assessment,
switch (test_no) {
case 1: return gr;
case 2: return gr | eq;
case 3: return less;
case 4: return less | eq;
case 5: return eq;
case 6: return !eq;
}
<?php
function prettyPrintSQLResult($result) {
$i=0;
echo '<table border="1">';
while ($data = $result->fetch_assoc()) {
if (!$i) {
//first entry
$columns = array_keys($data);
echo '<tr>';
foreach($columns as $c) {
urxvt*font: xft:terminus:pixelsize=8
urxvt*boldFont: xft:terminus:pixelsize=8
urxvt*termName: rxvt
urxvt*background: #212629
urxvt*foreground: #737c80
urxvt*scrollBar: false
urxvt*matcher.button: 1
urxvt*cursorBlink: true
urxvt*cursorColor: #c1c8c9
urxvt*colorBD: #9a7b88