Skip to content

Instantly share code, notes, and snippets.

@banterweb
banterweb / link_extractor.py
Created August 7, 2016 04:46 — forked from CodyKochmann/link_extractor.py
Python based link extractor
@banterweb
banterweb / split_all_strings.py
Created August 7, 2016 04:46 — forked from CodyKochmann/split_all_strings.py
splits all strings in a list with the splitter and adds them back (really helpful in certain search algorithms)
def split_all_strings(input_array, splitter):
# splits all strings in a list with the splitter and adds them back
# by: Cody Kochmann
if isinstance(input_array, basestring):
# patch to accept input_array in string form
input_array = [input_array]
result = []
for i in input_array:
for x in i.split(split_char):
result.append(x)
@banterweb
banterweb / curl.coffee
Created August 7, 2016 04:46 — forked from CodyKochmann/curl.coffee
grep (actually curl) equivalent (http requester) for javascript
curl = (theUrl) ->
xmlHttp = null
xmlHttp = new XMLHttpRequest
xmlHttp.open 'GET', theUrl, false
xmlHttp.send null
xmlHttp.responseText
@banterweb
banterweb / manual_adblock.js
Created August 7, 2016 04:46 — forked from CodyKochmann/manual_adblock.js
bookmarklet that covers the screen with a touch interphase that can be used to delete
(function() {
// covers the screen with a touch interphase that can be used to delete
// elements in the way. This is purposed to be a manual type of adblock
// author: Cody Kochmann
var div = document.createElement("div");
div.id = 'page_cleaner544';
div.innerHTML = "<div id='click_remover' style='width:" + window.outerWidth.toString() + "px; height:" + window.outerHeight.toString() + "px; background : rgba(50,50,50,0.1); position:fixed; z-index:2147483646; top:0; left:0;'></div>";
div.innerHTML += "<style>#close_cleaner{position:fixed;height:auto;padding:0.15in 0;width:2in;bottom:0.5in;left:0.5in;background:rgba(250,250,250,0.85);-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;color:rgba(50,50,50,0.65);text-align:center;z-index:2147483647;}</style><p id='close_cleaner'>Done</p>";
document.body.appendChild(div);
var click_remover = document.getElementById('click_remover');
@banterweb
banterweb / app_cpu_throttle.py
Created August 7, 2016 04:46 — forked from CodyKochmann/app_cpu_throttle.py
shell script that uses cpulimit to slow down a selfish app (does require cpulimit to be installed)
#!/usr/bin/env python
# shell script that uses cpulimit to slow down a selfish app
import os, sys, time
if "-stop" in " ".join(sys.argv):
print "stopping all limiters."
os.system('killall cpulimit')
target_app = raw_input("What app would you like to limit?\n")
@banterweb
banterweb / check_if_link.py
Created August 7, 2016 04:46 — forked from CodyKochmann/check_if_link.py
python snippet to check or verify if the input string is a link.
@banterweb
banterweb / chrome_watcher.py
Created August 7, 2016 04:46 — forked from CodyKochmann/chrome_watcher.py
shell script to collect the links visited on Google Chrome on OSX
#!/usr/bin/env python
# shell script to collect the links visited on Google Chrome
# by: Cody Kochmann
import os, time
def current_links():
try:
chrome_link=os.popen("""osascript -e 'tell application "Google Chrome" to return URL of active tab of front window'""").read().split("\n")[0]
return chrome_link
@banterweb
banterweb / disk_usage.py
Created August 7, 2016 04:46 — forked from CodyKochmann/disk_usage.py
shell or python script for getting stats on the primary disk
#!/usr/bin/env python
# shell script for getting stats on the primary disk
# example data available = ['/dev/disk0s2', '328Gi', '315Gi', '13Gi', '97%', '82518570', '3418928', '96%', '/\n']
import os
disk = os.popen("df -h | grep '/dev/disk0s2'").read().split(' ')
for i in list(disk):
if len(i) is 0:
@banterweb
banterweb / myIP.js
Last active August 7, 2016 04:46 — forked from CodyKochmann/myIP.js
returns the users ip address in javascript
function myIP() {
// returns the users ip address
// ref link: http://stackoverflow.com/questions/391979/get-client-ip-using-just-javascript
if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","http://api.hostip.info/get_html.php",false);
xmlhttp.send();
hostipInfo = xmlhttp.responseText.split("\n");
@banterweb
banterweb / all_html_tags.regex.py
Created August 7, 2016 04:45 — forked from CodyKochmann/all_html_tags.regex.py
this is regex for all supported html tags in a page
import re
# this is a static list of all html tags excluding script tags
all_html_tag_regex = r'<\/?(html|title|body|h|p|br|hr|abbr|address|b|bdi|bdo|blockquote|cite|code|del|dfn|em|i|ins|kbd|mark|meter|pre|progress|q|rp|rt|ruby|s|samp|small|strong|sub|sup|time|u|var|wbr|form|input|textarea|button|select|optgroup|option|label|fieldset|legend|datalist|keygen|output|iframe|img|map|area|canvas|figcaption|figure|audio|source|track|video|a|link|nav|ul|ol|li|dl|dt|dd|menu|menuitem|table|caption|th|tr|td|thead|tbody|tfoot|col|colgroup|style|div|span|header|footer|main|section|article|aside|details|dialog|summary|head|meta|base|script|noscript|embed|object|param).{0,}>'
# this one supports removing script tags too!
all_script_and_html_tags_regex = r'(&[a-z]+?\;|<script[\W\D\S\s\w\d]+?<\/script>|<style[\W\D\S\s\w\d]+?<\/style>|<!?[*-\[\]\'\"\/\_\(\)\\\:\%\-a-zA-Z\ \n]+?>)'