Skip to content

Instantly share code, notes, and snippets.

View mncaudill's full-sized avatar

Nolan Caudill mncaudill

View GitHub Profile
@mncaudill
mncaudill / php-quine.php
Created December 21, 2010 05:19
This is a PHP quine. When run, this program will print out an exact version of itself.
<?php
$data = array(
36,110,108,32,61,32,99,104,114,40,49,48,41,59,10,112,114,105,110,116,32,34,60,63,112,104,112,36,110,108,36,110,108,92,36,100,97,116,97,32,61,32,97,114,114,97,121,40,36,110,108,34,59,10,10,102,111,114,101,97,99,104,40,36,100,97,116,97,32,97,115,32,36,100,41,32,123,10,32,32,32,112,114,105,110,116,32,34,36,100,44,34,59,32,32,10,125,10,10,112,114,105,110,116,32,34,36,110,108,41,59,36,110,108,36,110,108,34,59,10,10,102,111,114,101,97,99,104,40,36,100,97,116,97,32,97,115,32,36,100,41,32,123,10,32,32,32,32,112,114,105,110,116,32,115,112,114,105,110,116,102,40,34,37,99,34,44,32,36,100,41,59,10,125,10,
);
$nl = chr(10);
print "<?php$nl$nl\$data = array($nl";
foreach($data as $d) {
@mncaudill
mncaudill / php-js-php-quine.php
Created December 21, 2010 07:14
Another quine. This one is a PHP program that prints a JavaScript program (I ran mine with node) that when the JS program is ran, it prints out the original PHP program.
<?php
$php="112,114,105,110,116,32,34,112,104,112,61,91,36,112,104,112,93,59,115,116,114,105,110,103,61,39,39,59,99,111,110,115,111,108,101,46,108,111,103,40,39,60,63,112,104,112,39,41,59,99,111,110,115,111,108,101,46,108,111,103,40,39,39,41,59,102,111,114,40,105,61,48,59,105,60,112,104,112,46,108,101,110,103,116,104,59,105,43,43,41,123,115,116,114,105,110,103,43,61,112,104,112,91,105,93,43,39,44,39,59,125,99,111,110,115,111,108,101,46,108,111,103,40,39,92,36,112,104,112,61,92,34,39,43,115,116,114,105,110,103,43,39,92,34,59,39,41,59,99,111,110,115,111,108,101,46,108,111,103,40,39,39,41,59,115,116,114,105,110,103,61,39,39,59,102,111,114,40,105,61,48,59,105,60,112,104,112,46,108,101,110,103,116,104,59,105,43,43,41,123,115,116,114,105,110,103,43,61,83,116,114,105,110,103,46,102,114,111,109,67,104,97,114,67,111,100,101,40,112,104,112,91,105,93,41,59,125,99,111,110,115,111,108,101,46,108,111,103,40,115,116,114,105,110,103,41,59,34,59,";
print "php=[$php];string='';console.log('<?php');console.log('');for(i=0;i<p
@mncaudill
mncaudill / build.sh
Created December 21, 2010 09:03
BigQuine: PHP->C->Python->JS->original PHP program
#!/bin/bash
php php-c-python-js-php-quine.php > quine.c
gcc -Wall -o quinec quine.c
./quinec > quine.py
python quine.py > quine.js
node quine.js > quine.php
diff php-c-python-js-php-quine.php quine.php
@mncaudill
mncaudill / jslint.js
Created January 8, 2011 22:05
This is the Rhino-ready version of jslint. This file has almost disappeared from the Internet so I'm putting it here for posterity.
// (C)2002 Douglas Crockford
// www.JSLint.com
// Rhino Edition
"use strict";var JSLINT=(function(){var adsafe_id,adsafe_may,adsafe_went,anonname,approved,atrule={media:true,'font-face':true,page:true},bang={'<':true,'<=':true,'==':true,'===':true,'!==':true,'!=':true,'>':true,'>=':true,'+':true,'-':true,'*':true,'/':true,'%':true},banned={'arguments':true,callee:true,caller:true,constructor:true,'eval':true,prototype:true,unwatch:true,valueOf:true,watch:true},boolOptions={adsafe:true,bitwise:true,browser:true,cap:true,css:true,debug:true,eqeqeq:true,evil:true,forin:true,fragment:true,immed:true,laxbreak:true,newcap:true,nomen:true,on:true,onevar:true,passfail:true,plusplus:true,regexp:true,rhino:true,undef:true,safe:true,sidebar:true,strict:true,sub:true,white:true,widget:true},browser={addEventListener:false,alert:false,blur:false,clearInterval:false,clearTimeout:false,close:false,closed:false,confirm:false,console:false,Debug:false,defaultStatus:false,document:false,event:false,focus:false,frames:false,get
@mncaudill
mncaudill / similar.php
Created October 31, 2011 05:33
PHP version of simple image similarity algorithm
<?php
# Algorithm found here: http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
$filename = 'image.jpg';
list($width, $height) = getimagesize($filename);
$img = imagecreatefromjpeg($filename);
$new_img = imagecreatetruecolor(8, 8);
@mncaudill
mncaudill / gist:1380033
Created November 20, 2011 09:02
ArchLinux + Gnome -- don't suspend laptop when closed
ACPI can run, but gnome also has a hook into what happens when ACPI events happen. I spent waaay too much time fighting with this...
gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action nothing
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action nothing
Or run dconf-editor and navigate through the trees.
### Keybase proof
I hereby claim:
* I am mncaudill on github.
* I am nolancaudill (https://keybase.io/nolancaudill) on keybase.
* I have a public key whose fingerprint is 9D0C CFF7 8DCA 368E 45A7 518E 9049 BD66 4E14 B04C
To claim this, I am signing this object: