Skip to content

Instantly share code, notes, and snippets.

View octagonal's full-sized avatar

Anthony Madhvani octagonal

View GitHub Profile
@octagonal
octagonal / Semantic voting
Created June 24, 2013 13:34
Semantic voting
Sup ilias
From: http://www.reddit.com/r/startups/comments/1gvg7d/show_rstartups_we_were_sick_of_how_stagnant_forum/caodce1:
*Semantic voting*. You should be able to easily select a section/paragraph of a post/comment,
and vote on it specifically. Instead of voting/liking a complete post
(which probably contains things you agree with as well as things you disagree with),
you can select a word/sentence, and express your agreement.
Downvoting a word could be used to point out grammatical errors, which leads to
@octagonal
octagonal / TPB Structuur
Created June 29, 2013 13:46
TPB Structuur
Magnet link:
table#searchResult tbody tr:first-child td:nth-child(4) a [node href attribute]
Name:
table#searchResult tbody tr:first-child td:nth-child(2) a [node text]
thepiratebay.sx/<query>/0/<sorting mode>/<category>
<category>:
201 : films
207 : HD-films
@octagonal
octagonal / curl_imgur.sh
Last active December 21, 2015 07:38
Curl Imgur for valid URLs using random string from /dev/urandom
# Get the string from /dev/urandom (from ~/bin/get_rand)
#!/bin/zsh
# The -c flag for head indicates the amount of bytes I want to see returned.
# In this case this correlates to the amount of characters I want returned.
function random {
export rand=$(
LC_CTYPE=C tr -dc a-zA-Z0-9 < /dev/urandom | head -c 7| xargs
)
}
random
@octagonal
octagonal / gist:6300976
Created August 21, 2013 22:17
No arrow keys
" Disable arrow keys.
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
@octagonal
octagonal / change_in_place.sh
Created August 25, 2013 22:57
Substitute in a file according to a pattern and save it back to that file, while at the same time making a backup called %file%.back
#!/usr/bin/zsh
#You don't need to use / as a delimiter, especially not when it's not convenient.
sudo sed -i.back 's#<img src="#<img src="http://mitpress.mit.edu/sicp/full-text/book/#g' book.html
[
{
"name": "Aphex Twin Discography 320kbps",
"magnet": "magnet:?xt=urn:btih:b35c01a402ed620e3574dd71528b7483a4fcb5f9&dn=Aphex+Twin+Discography+320kbps&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337",
"uploader": {
"name": "nrs321"
},
"date": "01-11 02:31",
"size": "2.14 GiB",
"category": {
@octagonal
octagonal / BashSuperpowers.sh
Last active December 25, 2015 09:09
This bash script will give you superpowers
#!/usr/bin/env bash
function superpower {
echo $(curl -Is http://powerlisting.wikia.com/wiki/Special:Random | grep Location | cut -d / -f 5 | sed "s/_/ /g")
}
count=$1
echo "Your superpowers for today are: " > $HOME/super.txt
for (( c=1; c<=$count; c++ ))
@octagonal
octagonal / sorrymoot.sh
Last active December 27, 2019 21:20
Fast + Simple 4chan Image Downloader
#!/usr/bin/sh
# Every time you use this, Moot sheds a single manly tear. Please use it sparingly if at all.
echo -e "(curl)\t\t Downloading thread"
curl -s http://boards.4chan.org/$1 -o thread.html
echo -e "(grep -Po)\t Finding images "
cat thread.html | grep -Po '(?<=fileThumb" href=")\S+(?=")' > img
echo -e "(sed)\t\t Extracting image links"
@octagonal
octagonal / getarg
Last active August 29, 2015 14:00
Get explanations for command line options for most shell commands
#!/usr/bin/bash
# See what arguments do without having to go through a man page
# This only works on man pages that have an "options summary" section or something similar
# The expected format is thus: {whitespace}{flag,optional multichar flag}{whitespace}{short explanation}
count=1
tmp=$(mktemp)
man $1 > $tmp
@octagonal
octagonal / getspeed
Created June 1, 2014 18:08
Simple webserver speed measuring
#!/usr/bin/bash
# $1 => filename to write to
# $2 => URL to fetch
# $3 => Amount of time in-between measurements
while true; do
echo -n $(date +%H:%M:%S) | tee -a $1; echo -n ";" | tee -a $1;
echo -n $(curl -o /dev/null -s -w "%{time_total}" $2 |sed "s/\./,/") | tee -a $1; echo "" | tee -a $1;
sleep $3;