This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HOST='' | |
USER='' | |
PASSWD='' | |
ftp -n $HOST <<END_SCRIPT | |
user $USER $PASSWD | |
binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
files = os.listdir(os.getcwd()) | |
for f in files: | |
x = f.split('.') | |
r = x[0] + '.extension' #The extension which you want to give to the file | |
os.renames(f, r) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
until <Shell Command to be Executed>; do | |
echo "Server 'myserver' crashed with exit code $?. Respawning.." >&2 | |
sleep 1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MySQLdb | |
db = MySQLdb.connect( | |
host = 'localhost', | |
user = 'root', | |
passwd = '', | |
db = '', | |
unix_socket = '/opt/lampp/var/mysql/mysql.sock' #This is needed if you are using mysql of xampp installation, else you can remove this | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
def runCommand(comm): | |
''' | |
Using the subprocess library this runs the command passed | |
''' | |
proc = subprocess.Popen(comm.split(), stdout=subprocess.PIPE) | |
outputstr = '' | |
for line in proc.stdout.readlines(): | |
outputstr+=line.rstrip()+"\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
#We often have to automate some task, using requests library can be pretty easy as we | |
#Dont have to bother about the headers which we send along with our call and lets us do things fast. | |
''' | |
Functions to send Simple get and post request along with payload | |
payload is a dictionary | |
cookie is also a dictionary of key value pair |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pynotify | |
def desktop_notify(title, message): | |
pynotify.init("Test") | |
notice = pynotify.Notification(title, message) | |
notice.show() | |
#Works like a charm on both windows and linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console | |
//tes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
youtube-dl hacks | |
Use: | |
youtube-dl -c <link> //To resume download of a stopped file | |
youtube-dl -F <link> //Download after selecting the format of the file which you want to download | |
Example | |
----------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Works perfectly with the send written above | |
char recvBuff[10]; | |
int bytesReceived = recv(new_fd, recvBuff, 10, 0); | |
while(bytesReceived != 0) | |
{ | |
// you should add error checking here | |
fwrite(recvBuff, bytesReceived, 1, outputFile); |
OlderNewer