r/ScriptSwap • • Feb 26 '16

[NSFW]Python script to search porn sites from the command line. NSFW

35 Upvotes

Version 1

import sys
import webbrowser

urls = ['http://www.pornhub.com/video/search?search=','http://spankbang.com/s/',
'http://xhamster.com/search.php?from=&q=','http://www.fuq.com/search/?q=']
for i in urls:
    search_term = sys.argv[1]
    search_term = search_term.replace(' ','+')
    search_url = i + search_term
    webbrowser.open(search_url, new=2, autoraise=True)

Usage: python porn_search.py "your search term"

This will search pornhub, xhamster, spankbang and fuq.

Edit: If you want to submit a patch or get a more up to date version here is my github

Edit_2: My github was marked as spam so it will be unavailable for a short while. It's back on github

Edit_3: I also put it up on bitbucket

Edit:_4: I'm getting a weird amount of traffic from a Russian search engine (Like 1/10 of all views) not important but somewhat interesting.


r/ScriptSwap • • Jan 09 '14

[bash] My script for pulling external IP addres and emailing it to myself

27 Upvotes
#!/bin/bash

curl -s ifconfig.me > ~/.ip_new
wait
cmp -s .ip_new .ip_old > /dev/null
if [ $? -eq 1 ]; then
    cp .ip_new .ip_old
    cat ~/.ip_new | mailx -s "subject" [email protected]
fi

I wanted to be able to ssh into my PC wherever I am and since I have a dynamic IP address, I came up with this script. I have put it into my crontab and have it running every hour.

Link to the github repository


r/ScriptSwap • • Mar 02 '12

Just in case you did not know...

25 Upvotes

CommandLineFu

This place is awesome. If you are looking for something and cannot find it on this subreddit, check out CommandLineFu.


r/ScriptSwap • • Sep 18 '13

Script to create barcodes for LTO tape labels (Copied and pasted from my internal wiki)

24 Upvotes

Tape Barcodes

The tape cartridges used by the tape library are all labeled with barcodes and a human readable tag.

These are created using the barcode command and the following script:

for ((i=1;i<31;i++));do printf "SIM%03dL3\n" $i; done | barcode -t 2x15+20+30-20-28 -u mm -o label.ps -e code39 -p 8.5x11in -m 20,3 -c

Adjusting ā€œiā€ e.g.

 ((i=30;i<61;i++)) 

and such will create the rest of the labels-or multiple pages can also be created at once

 ((i=1;i<121;i++))

Changing the printf input will change the value for the barcode-whatever you want labeled.

barcode flags are fairly straightforward, for more info see the man page.1

The label.ps file should be printed to a laser printer and printed onto label stock2 then trimmed to fit the back of the cartridge before sticking it on3.

  1. http://linux.die.net/man/1/barcode

  2. Avery Product Number: 8066 or equivalent

  3. With the aforementioned label stock you just need to trim a little bit of white space from each end before applying-the paper cutter works well for trimming the whole sheet quickly.


r/ScriptSwap • • May 27 '14

[powershell] Prank script that randomly opens/closes the CD tray

22 Upvotes

This script enters an infinite loop, where it gets a random number from 0-9. If that number happens to be 5, the script will open/close the CD Tray on whichever machine it is running against. You can set this up to run on a friend/colleague's machine with a scheduled task that runs on startup (I made a task with the name JavaUpdater so it was less obvious). Have fun!

http://pastebin.com/cfPxgTiD


r/ScriptSwap • • May 01 '14

Looking for short Civil War script

22 Upvotes

I'm looking for a great civil war script. Short film, about 5-10 mins. in length. I am by no means a script writer, I'm a producer and cinematographer, so I can't come up with ideas. I just have visions in my head of what I want shots to look like and I'm struggling here.

In return, I can give you a script I have about a priest teaching his parish the true meaning of faith on Sunday morning. Thanks.


r/ScriptSwap • • Mar 13 '15

ITT, .bashrc and .zshrc files

21 Upvotes

ITT, we post our .bashrc and .zshrc files. Post your aliases, prompts, and functions.

Try and put 'em on Gist, Pastebin, or just paste it here.

Here's mine: https://gist.github.com/anonymous/d06f13cd913ee07d2bee


r/ScriptSwap • • Jan 20 '16

[Bash] Instantly create Github pages URL for your Resume.

20 Upvotes

r/ScriptSwap • • Jan 17 '15

[Powershell] SO's phone proximity alert.

20 Upvotes

Granted that you have IP adresses leased to the same MAC every time, this should work splendidly for any person, not only your SO.

Write-Host ("Looking for IP...")
do {
	$testing = test-Connection -quiet 192.168.0.5
	start-sleep -Milliseconds 2000
	Write-Host ("Not home yet...")
} until ($testing -eq "True") 

Write-Host ("HOME!!!")
Read-Host "PRESS ENTER"    

This has been a life saver for me so I know when to look busy.

(Wlan coverage to parking lot)


r/ScriptSwap • • Oct 28 '13

[Python] Script to mass edit all comments on a reddit account

20 Upvotes

In response to this post asking for a script to edit all comments on a reddit account, I made this script. First you need Python (I'm using 2.7.5), then get PRAW, and run this (editing where needed):

import praw
r = praw.Reddit(user_agent="Mass comment editing script by /u/suudo")
r.login("username", "password")
for a in r.user.get_comments(limit=1000):
    a.edit("Replacement text here!")

If you're running it in an interpreter you'll need to press enter twice to run the loop.

MIT license.

I have 891 comments and it takes around 18 seconds to go through the generator printing the body of each comment (because praw conforms to reddit's API restrictions, waiting two seconds between each request of 100 items). .edit is another API call, so that's another two seconds. If you have 1000 comments, expect this script to take about 40 seconds to run.

If you're curious about how many comments you have (reddit doesn't tell you) use this (after r.login):

sum(1 for _ in r.user.get_comments(limit=1000))

I'm making this post because I couldn't find another post on reddit specifically telling how to mass-edit comments.

update: Turns out that reddit only returns 1000 comments for the above function. I've updated the script to match this to avoid confusion. You can't scroll back past 1000 comments anyway; all reddit listings are limited to 1000 items. So people can't actually search for or find comments older than that.


r/ScriptSwap • • Feb 04 '13

[Python] Reddit lightweight post archiver

20 Upvotes

A python script that requires praw and snudown (pip can install both) that will archive an entire reddit thread for you in a lightweight html.

Github Link

Why is this better than some obvious alternatives?

Browser's save page as functions usually include lots of javascript bloat, and even perhaps modules that still access the internet (privacy concerns). Even other tools (e.g., Firefox's scrapbook plugin) that cut down on javascript bloat require comments to be visible to be archived, and long comment threads, or even posts that have thousands of comments will leave you missing a bunch of data.

Even reddit's natural html constitutes a bloat factor of around 3x when compared to html archived with this tool. Archiving and managing hundreds of saved pages is also made pretty easy with this tool, as you can have them all trivially use the same css file (and therefore edit the css style of all of them with one edit).

I posted this to /r/commandline but it got a few downvotes really quickly and not much exposure (Here)

TL;DR: This tool will save a reddit post thread in as lightweight and thorough way as possible.

Any place else I could post this for more exposure?


r/ScriptSwap • • Jun 19 '22

Would anyone like to take over this sub?

19 Upvotes

It needs some more care and attention to build it up and establish regular content than I can make available. Happy to hand it over to anyone who'd like to take it on.


r/ScriptSwap • • Jul 05 '14

[Python] Download every xkcd, and update collection.

19 Upvotes

This script is a python web scraper of romance, sarcasm, math, and language! Xkcd by Randall Munroe is awesome. It downloads every xkcd comic. After it is run once, it will download new comics. It also maintains a text file (xkcd.txt) which contains the comics number, name, mouseover text, transcript, and image link. To use it properly, run it into its own directory (mkdir xkcd, cd xkcd).

Licensed under GNU GPL, feel free to use, distribute, and modify. BEGIN CODE

#xkcdget v1.0
#A python web scraper of romance, sarcasm, math, and language.
#by: MrCatEats
#Please report bugs and errors as a comment to (http://redd.it/29xhw0)
#Feel free to use, modify, distribute
#This downloads all of the XKCDs
#It does not break on comic #859: (
#If you run it after you downloaded the XKCDs, it will get whichever ones are new.
#Make sure to run it in its own folder. CD into the folder then run it
#Files used: one image file for each comic, 'xkcd.txt' containing info about the comics
#Note: some comics are more than simply images, they may be animated or have scripts, they might not display properly

#BEGIN DEPENDENCIES
import re #regex to parse pages
import urllib2 #open xkcd website
import os #work with files
import htmllib #handle escaped html characters
import time #Delay for xkcd server
#END   DEPENDENCIES
#Most python installations should have the above modules by default.

#BEGIN SETTINGS
DELAY = .5 #delay between requests to xkcd in seconds
TIMEOUT = 100 #timeout for requests to xkcd in seconds
agent = {'User-Agent' : 'xkcdget by MrCatEats v1.0 (http://redd.it/29xhw0)'} #This identifies to xkcd server that this is a bot
#END   SETTINGS

def uscape(s): #This function unescapes escaped html from strings of html
	p = htmllib.HTMLParser(None)
	p.save_bgn()
	p.feed(s)
	return p.save_end()

if os.path.isfile('xkcd.txt') == False: #xkcd.txt contains number, title, and mouseovers for all comics
	data = open('xkcd.txt','w') #If the file is not already there then make it
	data.writelines(['#xkcd comic info file: Contains info about each comic\n','#Info is in order: number, title, mouseover, transcript, Link\n','#Do not modify this file\n','#-------------------------------\n','\n','0'])
	data.close()

data = open('xkcd.txt','r') #Now that we have the file. Put it onto a list
file_list = data.readlines()
data.close()
numhave = int(file_list[-1]) #This gets amount of comics we already have

print 'Currently have ' + str(numhave) + ' comics.'
print 'Start connection'

def parse(s): #Parse Xkcd pages for relevant info
	img = re.findall(r'<img\ssrc="http://imgs.xkcd.com/comics/.+',s)
	num = re.search(r'Permanent link to this comic: http://xkcd.com/[0-9]+',s)
	num = num.group()
	num = re.findall(r'\d+',num)[0]
	if len(img) == 0: #Error handling for irregular comics like xkcd1350
		return [num,None]
	href = re.findall(r'<div\s*id\s*=\s*"comic"\s*>\W*<a\s*href\s*=\s*"[^"]+',s)
	if len(href) == 0:
		href = None
	else:
		href = re.findall(r'href=".+',href[0])[0][6:]
	img = img[0]
	#The transcript is text captions for the comics. They do not appear on the page
	#as they have in a <div style="display:\snone">, however they are transmitted in the html.
	trans = re.findall(r'<div\sid\s*=\s*"transcript"[^>]+>[^<]+',s)
	if len(trans) == 0:
		trans = ''
	else:
		trans = uscape(re.findall(r'>[^<]+',trans[0])[0][1:])
	title = re.findall('alt\s*=\s*"[^"]+',img)
	if len(title) == 0:
		title = ''
	else:
		title = uscape(re.findall(r'".+',title[0])[0][1:])
	mouse = re.findall('title\s*=\s*"[^"]+',img)
	if len(mouse) == 0:
		mouse = ''
	else:
		mouse = uscape(re.findall(r'".+',mouse[0])[0][1:])
	src = re.findall('src\s*=\s*"[^"]+',img)[0]
	src = re.findall('".+',src)[0][1:]
	return[num,title,mouse,src,trans,href]
try:#If there is no internet connection to xkcd, it will exit.
	page = urllib2.Request('http://www.xkcd.com/', None, agent) #Request the xkcd front page
	page = urllib2.urlopen(page,None, TIMEOUT).read() #In order to get the amount of comics that exist
except:
	print '/// xkcdget error. xkcd website is not available at this time ///'
	exit()
pageinfo = parse(page) 
numare = int(pageinfo[0])
print 'There are currently ' + str(numare) + ' comics on xkcd.'
print 'Getting comics...'
comics = range(numhave+1,numare+1)
for amt in comics:#Finally Grab comics
	time.sleep(DELAY) #Delay to be nice to xkcd servers
	try: #Comic 404 is not found (xkcd.com/404)	
		req = urllib2.Request('http://www.xkcd.com/'+str(amt), None, agent)
		req = urllib2.urlopen(req,None, TIMEOUT).read()
		pageinfo = parse(req)
	except urllib2.HTTPError:
		pageinfo = None
	if pageinfo == None: #This will happen if there was a 404 error.
		print str(amt)+ ') /// xkcdget error. This comic is not available ///'
		file_list.append(str(amt) + '\n')
		file_list.append('/// xkcdget error.  This comic was not available, it has been skipped ///' + '\n')
		file_list.append('\n')#End 404 Error
	elif pageinfo[1] == None: #This will happen if there is an error as mentioned above
		print str(amt)+') /// xkcdget error. this is an irregular comic, it will be skipped ///\n'
		file_list.append(pageinfo[0]+'\n')
		file_list.append('/// xkcdget error. this is an irregular comic, it has been skipped ///'+'\n')
		file_list.append('\n')#End error handling
	else:
		print str(amt)+') '+pageinfo[1] #Place info about the comic
		file_list.append(pageinfo[0]+'\n') #In the xkcd.txt file
		file_list.append(pageinfo[1]+'\n')
		file_list.append(pageinfo[2]+'\n')
		file_list.append(pageinfo[4]+'\n')
		if pageinfo[5] == None:
			file_list.append('No Link' + '\n')
		else:
			file_list.append(pageinfo[5] + '\n')
		file_list.append('\n') # End placing info in the comic
		time.sleep(DELAY)
		picture = urllib2.Request(pageinfo[3],None, agent)#Download the picture
		output = open(str(amt)+pageinfo[3][-4:],'w')
		gotit = False
		while gotit == False:
			try:
				output.write(urllib2.urlopen(picture,None, TIMEOUT).read())
				gotit = True
			except:
				print '/// xkcdget error. Xkcd timed out; trying again ///'
		output.close()
#The amount of comics that we have is kept track of in the last line of xkcd.txt file
file_list = file_list[0:-1] # Get rid of ending amount number
file_list.append(str(numare)) # Push on new one
data = open('xkcd.txt','w')
data.writelines(file_list)
data.close()
#Protip: Run this program as a cron job (unix,bsd,gnulinux,mac) or using the task scheduler (windows) to get new comics automatically

r/ScriptSwap • • Aug 23 '12

[Bash] Download images from subreddit

19 Upvotes

Usage: In case you named this bash file as rdt and you want to download e.g. subreddit GirlswithGlasses, then:

/bin/bash rdt GirlswithGlasses

Or you can make it executable and run it as ./rdt, you know this guys.

On line 17 you can can change allowed file types, gif is pretty obvious if you want to download some gif subreddit

#!/bin/bash

#cfg
output="down"
useragent="Love by u/gadelat"

subreddit=$1
url="https://pay.reddit.com/r/$subreddit/.json"
content=`wget -U "$useragent" --no-check-certificate -q -O - $url`
mkdir -p $output
while : ; do
	urls=$(echo -e "$content"|grep -Po '"url":.*?[^\\]",'|cut -f 4 -d '"')
	names=$(echo -e "$content"|grep -Po '"title":.*?[^\\]",'|cut -f 4 -d '"')
	ids=$(echo -e "$content"|grep -Po '"id":.*?[^\\]",'|cut -f 4 -d '"')
	a=1
	for url in $(echo -e "$urls"); do
		if [ -n  "`echo "$url"|egrep \".gif|.jpg\"`" ]; then
			#echo -n "$url: "
			name=`echo -e "$names"|sed -n "$a"p`
			id=`echo -e "$ids"|sed -n "$a"p`
			echo $name
			newname="$name"_"$subreddit"_$id.${url##*.}
			wget -U "$useragent" --no-check-certificate -nv -nc -P down -O "$output/$newname" $url
		fi
		a=$(($a+1))
	done
	after=$(echo -e "$content"|grep -Po '"after":.*?[^\\]",'|cut -f 4 -d '"'|tail -n 1)
	if [ -z $after ]; then
		break
	fi
	url="https://www.reddit.com/r/$subreddit/.json?count=200&after=$after"
	content=`wget -U "$useragent" --no-check-certificate -q -O - $url`
	#echo -e "$urls"
done

r/ScriptSwap • • Dec 11 '12

Set of scripts I've written to quickly deploy a new Linux enviroment to my liking. (Work in progress)

18 Upvotes

https://github.com/Prothon/Deployment_Scripts_NG

Currently it's just me porting over my old scripts (which are under the same github account) to this new Whiptail enviroment. When I have more time I'll add in functionality and fix some of my more broken subscripts.


r/ScriptSwap • • Feb 18 '19

Hey everyone! I was a former union Script Supervisor before kids for several years. Worked on Its Always Sunny 1st year. I’m looking to get into script editing and reading. Let me know if you have something for me to give feedback on.

17 Upvotes

r/ScriptSwap • • Jun 22 '16

Set of scripts to monitor network bandwidth usage

17 Upvotes

I wrote these scripts to track my bandwidth usage. Thought someone else might find them useful too. Though they're currently written for my specific use case in mind, If anyone else wants to use them, I'd make the required changes!

https://github.com/dufferzafar/netuse


r/ScriptSwap • • Mar 05 '12

Download all flash videos in cache (Linux)

17 Upvotes

r/ScriptSwap • • Feb 16 '21

Offensive Wifi Toolkit (OWT) bash script for basic wifi hacks with U.I

16 Upvotes

Made this script for basic wifi hacking. I'm calling it Offensive Wifi Toolkit or OWT for short. This script comes with U.I. where you can select multiple options and choose what kind of attack you want to do. You can scan and select a network to attack and then choose attack mode. This information is much more detailed on the repository page (link below). I'm looking for people to try the script out and report bugs to the issues section of the github. Stars are always appreciated <3

https://github.com/clu3bot/OWT


r/ScriptSwap • • Nov 09 '13

[bash] parsing firefox places.sqlite for fun and profit

15 Upvotes

Some background:
I have a 13 year-old daughter who spends an inordinate amount of time on the computer, sometimes to the detriment of her homework.

I've made it known that I will watch her computer usage, but until now, hadn't really done much to do so.

Her computer runs ubuntu (which she loves!) and that means I get to remote-admin the box, which makes doing a lot of this really easy.

SO, in an effort to help keep her surfing habits slightly clean, I installed the MVPS hosts file (http://winhelp2002.mvps.org/hosts.htm) which redirects a lot of bad domains to '127.0.0.1'

And then I got to thinking, "hey, what if I set up lighttpd locally to serve empty text and 1px images depending on the ad/malware redirect?

so I added this to the config file:

url.rewrite-once = (
"/(.*gif)" => "/1pixel.gif",
"/(.*jpg)" => "/1pixel.jpg",
"/(.*png)" => "/1pixel.png",
"/(.*php)" => "/index.html",
"/(.*cgi)" => "/index.html",
"/(.*asp)" => "/index.html",
"/(.*js)" => "/null.js",
"/(.*)" => "/index.html",
)

And that worked like a charm. Next, I set the access-log to write to my main syslog server. And now I can see what sites she's browsing (that hit the MVPS redirects) which... is cool and all. But I wanted more.

So, next I set up webalizer and used it, with a little tweaking, to analyze the logs:
cut -d: -f 4- /var/log/thechild/messages | webalizer -c /etc/webalizer/webalizer.conf -Q -;

And that was cool, too. Everything important is actually the "referrer" in this context, which is fine.

But... I wasn't getting all of the data I wanted...

So, I decided to go right to the source: Mozilla Firefox and places.sqlite

And that's where this script comes in: it's set to run on normal shutdown, and it parses the sql file for the day's links and sends them via syslog to the master, which then gets parsed via webalizer!

So, now I have a complete look at what the girlchild is doing, and when she's doing it. And when she's avoiding homework. :-)

So, here's the code. Pretty self-explanatory, I hope!


#!/bin/bash
PROG="${0##*/}"

LOGHOST=192.168.1.3
SYSLOGTAG=lighttpd
SQLFILE=places.sqlite

######################################
# Daemons and typoes below
#
if [ -z "$(which sqlite3)" -o -z "$(which logger)" ];
then
      echo "${PROG} requires:"
      echo "sqlite3 : $(which sqlite3)"
      echo "logger  : $(which logger)"
      exit 1
elif [ ! -r ${SQLFILE} ];
then
      echo "Can't read sqlite db: ${SQLFILE}"
      exit 1
fi

YESTERSQL="SELECT cast(round((((julianday('now','start of day') - 2440587.5 ) * 86400 )) * 1000000 ) as integer);"

YESTERDAY=$( echo "${YESTERSQL}" | sqlite3 -noheader -init -/dev/null )
TONIGHT=$((YESTERDAY + 86399999999))

MOZSQL="SELECT datetime(moz_places.last_visit_date/1000000,'unixepoch','localtime'),moz_places.url FROM moz_places WHERE moz_places.last_visit_date > ${YESTERDAY} AND moz_places.last_visit_date < ${TONIGHT} ORDER BY moz_places.last_visit_date;"

# Arrays start at zero, so pad:
MONTHS=( "NUL" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" )

for LINE in $(echo ${MOZSQL} | sqlite3 -noheader -init - ${SQLFILE} | sed 's/ /:/;' )
do
      DATETIME=${LINE%%|*}
      URL=${LINE##*|}
      DATE=${DATETIME%%:*}
      TIME=${DATETIME#*:}
      DAY=${DATE##*-}
      YEAR=${DATE%%-*}
      MONTH=${DATE%-*}
      MONTH=${MONTH#*-}

      TIMESTAMP="[${DAY}/${MONTHS[$MONTH]}/${YEAR}:${TIME} -0900]"

      logger -u /tmp/ignore -n ${LOGHOST} -t ${SYSLOGTAG} --udp \
      "127.0.0.1 click.local - ${TIMESTAMP} \"GET URL HTTP/1.0\" 200 0 \"${URL}\" \"Mozilla/5.0 (X11) Local Browser\""
done

r/ScriptSwap • • Jul 18 '13

[Python] A script for generating rtmpdump parameters for playing justin.tv/twitch.tv streams in VLC (or other media player that can play from stdin)

15 Upvotes

The script:

#!/usr/bin/env python2
 
# rtmpdump parameter generator for justin.tv/twitch.tv streams v4
# * Usage: jtvrtmp.py channelname [quality]
#   where channelname is the channel name ([twitch/justin].tv/channelname)
#   and quality is an optional parameter with a valid quality setting 
#   (360p, 480p, 720p, etc) If quality isn't present, it selects 360p.
# * if quality is live, it picks the quality setting with a +, which 
#   is a restream of the video being sent to jtv, no transcoding involved.
#
# Changelog:
# v4: Add shebang line
# v3: Removed unicode copyright symbol
# v2: Added exception catching for when a stream is offline or the specified
#     quality setting is unavailable.
# v1: Initial release
#
# Copyright 2013 Steven Smith (blha303). All Rights Reserved.
# New BSD license
# http://www.opensource.org/licenses/BSD-3-Clause
 
from urllib2 import urlopen
import json
from sys import argv, exit
 
def getswfaddr(channelname):
  return urlopen("http://www.justin.tv/widgets/live_embed_player.swf?channel=" + channelname).geturl().split("&userAgent")[0]
 
def getstreaminfo(channelname):
  data = json.loads(urlopen("http://usher.justin.tv/find/%s.json?type=any" % channelname.lower()).read())
  newd = {}
  for i in data:
    newd[i['display']] = i
  return newd
 
def buildcmdline(channelname, data, quality="360p"):
  if quality == "live":
    for i in data:
      if "+" in i:
        quality = i
  try:
    data = data[quality]
  except KeyError:
    return '; echo "-------------"; echo "Couldn\'t find stream info for %s, maybe the stream is offline?"; echo "-------------" #' % quality
  if not "live-cdn" in data["connect"] and not "justintvlivefs" in data["connect"]:
    justinlegacyparams = '-j "%s" ' % data["token"].replace('"', r'\"')
  else:
    justinlegacyparams = ""
  out = '-r "%s/%s" %s--swfVfy "%s" -v -o -' % (data["connect"], data["play"], justinlegacyparams, getswfaddr(channelname))
  return out
 
def main():
  if len(argv) < 2:
    print "Usage: %s channelname [quality]"
    exit(2)
  if len(argv) > 2:
    quality = argv[2]
  else:
    quality = "360p"
  channelname = argv[1]
  data = getstreaminfo(channelname)
  print buildcmdline(channelname, data, quality=quality)
 
if __name__ == "__main__":
  main()

Github gist, for forking: https://gist.github.com/blha303/6031124

The story:

I wanted to watch twitch.tv streams in VLC. I googled for this, and found this page: http://bogy.mine.nu/sc2/stream2vlc.php , a PHP script which parses justin.tv/twitch.tv's JSON api for the specified channel name to get streaming URLs. I emailed the author asking if they could share the source for this script; he kindly obliged, asking that I not distribute it. Using his work as a reference, I made this script. It generates parameters for rtmpdump (available in linux package repositories as well), which can be either entered manually (by calling python jtvrtmp.py channelname and copying the result over) or automatically (I use: echo "rtmpdump $(python stream2vlc.py channelname) | vlc -" | sh in bash - for some reason, just calling rtmpdump $(python stream2vlc.py channelname) | vlc - doesn't work.)

If you're looking for something that can load more than justin.tv streams, /u/vishenz suggested this https://github.com/chrippa/livestreamer

edit: updated to same version as gist. all future updates will be at the above linked gist page.


r/ScriptSwap • • Jul 24 '12

How to batch identify similar images in Linux

15 Upvotes

http://fuzz-box.blogspot.com/2012/07/how-to-batch-identify-similar-images-in.html

A Linux bash script to identify similar images, utilizing the imagemagick multi purpose image tool suite. The script scans for image files and compares all possible pairs within a set, calculating the Root Mean Square Error of image pixel values. Outputs a 3 column list: RMSE / source image / target image, sorted by RMSE. Similar images appear on the top of the list. You can redirect the output of the script to a text file for further processing, e.g. batch delete, import into libre office, etc.


r/ScriptSwap • • Feb 16 '21

Script that automatically creates the file to be edited and its directories if they dont exist, and authenticates if user doesnt have the privileges to edit file

14 Upvotes

There are two scripts, dirtouch can be used independently.

These are my first bash scripts, feel free to point out my bad practices, etc.

https://github.com/TheKnightWhoSaidNI/somelittlescripts


r/ScriptSwap • • Sep 20 '16

[sh] SSD wear level monitoring

14 Upvotes

Small script which can be used to display SSD wear level as percents and which estimate SSD days left, can be usefull if you want to know when it is time to change your SSD, it make use of ext4 "lifetime_write_kbytes" which indicate the number of kbytes written to the file system since it was created, obviously this only work with the ext4 filesystem (maybe other filesystems support something similar, i don't know) and the script is for one partition only, feel free to enhance it as you need.

#!/bin/sh
# BSD 3-Clause license
# grz-

# lifetime_write_kbytes path (replace sda1 by the partition you are using on your SSD)
sys_fs_fs_device_path="/sys/fs/ext4/sda1/lifetime_write_kbytes"
# when the ssd started to be used
ssd_date='09/17/2016'
# max ssd endurance (tb, get it from benchmarks/reviews of your SSD)
ssd_tb_endurance=30

ssd_date_as_timestamp=`date -d $ssd_date +%s`
now_timestamp=`date +%s`
ssd_days_elapsed="$((($now_timestamp - $ssd_date_as_timestamp)/(60*60*24)))"

lifetime_write=`cat $sys_fs_fs_device_path`

echo "\033[36mSSD wear levels:"
echo "\033[37m specified endurance: \033[32m${ssd_tb_endurance}tb"
echo "\033[37m ssd lifetime write: \033[32m\n\t$(echo "($lifetime_write/1024)" | bc)Mb\n\t$(echo "($lifetime_write/1048576)" | bc)Gb\n\t$(echo "($lifetime_write/1073741824)" | bc)Tb\n"
echo "\033[37m ~ssd wear: \033[32m$(echo "scale=2; (($lifetime_write / 1073741824) / $ssd_tb_endurance) * 100" | bc)%"

days_left=$(echo "($ssd_tb_endurance * 1073741824) / ($lifetime_write / $ssd_days_elapsed)" | bc)

echo "\033[37m ~ssd days left: \033[32m$days_left days"

r/ScriptSwap • • Jul 12 '14

[BATCH] Windows Technician USB Tools

14 Upvotes

[IT Toolkit] Windows ONLY (Win XP,Vista,7,8,8.1)

Description: So I'm a self-employed IT Consultant. I recently got fed-up with having to manually repeat my usual tasks on each computer I touch. So I borrowed some ideas from you guys and from other sites and compiled my own USB toolkit. I take credit only for the parts of code I wrote and release to you guys to do what you wish.

Notes: I was too lazy to remove all of my company branding and logos. I suggest you guys all look at the source and get familiar with how it all works and it should be easy enough to replace anything that is specific to my company. The whole thing is very customizable, everything is open and editable if you have Notepad++.

The toolkit is nothing more than a library of scripts and executables which can be launched from the folders directly. Or I have included an old program called "Nu2Menu" which is from my WinXP days as an employed IT Guy for another company. It hasn't been updated in a very long time, however it is tested and working up through Windows 8.1. Basically it creates a faux start menu which creates a directory structure for easier access to the tools in the folders.

Installation: Simply copy all files and folders to the root of a USB drive for best results. To execute, run the "Autorunme.bat" or it should auto-run if the autorun.inf stays intact.

(Dropbox sucks, so let me know when they kill this link and I will try to post on a mirror. If anyone else beats me to the task we can all thank them for their efforts together.)

EDIT: https://dl.dropboxusercontent.com/u/91121274/Toolkit.7z (updated and working 7/12/14 @ 10:07 PST)