Skip to content

Instantly share code, notes, and snippets.

View nemasu's full-sized avatar

nemasu

  • Tokyo
  • 12:25 (UTC +09:00)
View GitHub Profile
@nemasu
nemasu / kvdiff
Last active October 11, 2015 22:03
Bash function that compares files containing key-value pairs.
#$1,2 = files containing x=y style key-values
#sort, awk, grep friendly
#Duplicate keys are not handled
function kvdiff() {
tmpfile=`mktemp`
OLD_IFS=$IFS;
IFS=$'\n'
declare -A left;
declare -A right;
@nemasu
nemasu / xrandr_force.sh
Last active November 8, 2016 04:46
xrandr force custom resolution
#!/bin/bash
#Usage: xrandr_force.sh <width>x<height>
#Eg: ./xrander_force.sh 1920x1080
#Just some random defaults
WIDTH=1300
HEIGHT=750
if [ -n "$1" ]; then
@nemasu
nemasu / findLibrary.sh
Last active November 8, 2016 04:47
Find a library method.
function getExportsFromLib() {
readelf -W -s $1 2> /dev/null |
egrep "FUNC[ ]+GLOBAL[ ]+DEFAULT[ ]+[0-9]+" |
sed '/@@*/d;/[0-9][0-9]* _fini/d;/[0-9][0-9]* _init/d;' |
c++filt |
awk '{print substr($0, index($0,$8));}' |
sort |
uniq;
}
@nemasu
nemasu / StringifyObject.java
Last active December 21, 2016 06:48
Turn Java objects into Strings.
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class StringifyObject {
private HashSet<Integer> objects = new HashSet<>();
@nemasu
nemasu / ffxiv-equip.js
Created October 13, 2017 02:31
FFIXV Lodestone Retainer Inventory Equipment CSV Display
//Open retainers inventory on lodestone, paste and run in browsers console (tested with Chromium).
$(".item-list__name").each(function(index){console.log($(".item-list__name")[index].innerText + "," + $($(".item-list__name")[index]).find(".db-tooltip__item_equipment__level")[0].innerText.replace("Lv. ","") + "," + $($(".item-list__name")[index]).find(".db-tooltip__item__level")[0].innerText.replace("Item Level ","") + "," + $($(".item-list__name")[index]).find(".db-tooltip__item_equipment__class")[0].innerText);});
@nemasu
nemasu / virus_scan.sh
Last active December 27, 2019 07:34
Progress for clamdscan.
#!/usr/bin/bash
function show_progress() {
echo -ne "\r"
echo -n "`echo "scale=5; ($count / $total)*100" | bc`"
}
path="/"
if [ -n "$1" ]; then
@nemasu
nemasu / count_requests.py
Created June 6, 2024 07:42
Python script to count nginx average requests per hour/minute.
import re
import dateutil.parser
import sys
def find(pat, text, match_item):
match = re.findall(pat, text)
if match:
return match
else:
return False