Skip to content

Instantly share code, notes, and snippets.

@vik-y
vik-y / gist:f78a90216a1e2394a0a3
Created April 3, 2015 02:02
fix for autoadjusting page in phonegap app
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=medium-dpi, user-scalable=0" />
@vik-y
vik-y / youtube.py
Last active August 29, 2015 14:17
To download a list of files from youtube
'''
Copy the list from youtube and save it in a file urls.txt
Run this script to get all the urls
Put them in a file and run youtube-dl --playlist-start <number> --playlist-end <number> -a "filename.txt"
Download entire playlist
'''
from BeautifulSoup import BeautifulSoup
a = open('urls.txt', 'r')
@vik-y
vik-y / decipher.py
Created March 28, 2015 19:12
Hack this site Programming Challenge 1
f = open('wordlist.txt', 'r')
a = f.readlines()
for i in range(0, len(a)):
a[i] = a[i][:-2]
b = []
for val in a:
@vik-y
vik-y / youtube.sh
Last active August 29, 2015 14:17
Capture ip of people who are browsing youtube
sudo tcpdump -i wlan0 -n src 216.58.220.46 -c 5 > capture.dat #can also use src youtube.com
cat capture.dat
cat capture.dat | awk -F ' ' '{print $5}' | awk -F '.' '{print $1"."$2"."$3"."$4}' | awk -F ':' '{print $1}'
@vik-y
vik-y / rcv.c
Last active August 29, 2015 14:17
Send a file - c socket
//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);
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
-----------
@vik-y
vik-y / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
//tes
@vik-y
vik-y / notify.py
Created March 25, 2015 07:16
Desktop Notifications in Python
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
@vik-y
vik-y / pyrequests.py
Created January 15, 2015 18:33
Python Web Requests
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
@vik-y
vik-y / pyshell.py
Last active August 29, 2015 14:13
Run Shell Scripts from Python like subprocesses
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"