Skip to content

Instantly share code, notes, and snippets.

View rounakdatta's full-sized avatar

Rounak Datta rounakdatta

View GitHub Profile
@rounakdatta
rounakdatta / reddit.py
Last active March 4, 2018 17:15
subreddit content scraper
import requests
import string
link = 'https://www.reddit.com/r/DarkHumor/.json'
subreddit = requests.get(link, headers = {'User-agent': 'nexttechbot'})
posts = subreddit.text.split()
post_list = []
@rounakdatta
rounakdatta / pdf-merger.py
Created May 27, 2018 07:17
Quickly merge PDF files
from PyPDF2 import PdfFileMerger
pdfs = ['one.pdf', 'two.pdf']
merger = PdfFileMerger()
for pdf in pdfs:
merger.append(open(pdf, 'rb'))
with open('final.pdf', 'wb') as fout:
merger.write(fout)
@rounakdatta
rounakdatta / shortcutter.sh
Created May 29, 2018 08:50
Make a quick shortcut on Ubuntu launcher
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/opt/Postman/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
EOL
@rounakdatta
rounakdatta / targzinstaller.sh
Created May 29, 2018 08:52
Install tar.gz files
sudo tar -xzf postman.tar.gz -C /opt
rm postman.tar.gz
sudo ln -s /opt/Postman/Postman /usr/bin/postman
@rounakdatta
rounakdatta / bulk-renamer.py
Created May 30, 2018 04:43
Rename multiple files in order in a second
import os
counter = 1
for file in os.listdir("."):
if file.endswith(".pdf"):
os.rename(file, "resume" + str(counter) + ".pdf")
counter += 1
@rounakdatta
rounakdatta / escrow.sol
Created May 31, 2018 04:17
Simple enough escrow contract
contract Escrow{
mapping (address => uint) public balances;
address public seller;
address public buyer;
address public escrow;
bool sellerApprove;
bool buyerApprove;
@rounakdatta
rounakdatta / app.js
Created June 2, 2018 17:39
Dead simple Node.js code for serving HTML pages
const http = require('http');
const fs = require('fs');
const express = require('express')
const path = require('path');
const app = express();
app.use(express.static(path.resolve(`${__dirname}/web/public`)));
console.log(`${__dirname}/web`);
app.use('*', (req, res, next) => {
@rounakdatta
rounakdatta / codeninja.py
Created June 25, 2018 08:35
Get videos recorded on CodeNinja using Selenium
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
usr = ""
pwd = ""
driver.get("http://www.facebook.org")
assert "Facebook" in driver.title
var floating_header = function() {
this.header = document.createElement('table');
this.header_height = 0;
this.getkeys = function(obj) {
var keys = new Array();
for ( var key in obj ) {
keys.push(key);
}
@rounakdatta
rounakdatta / app.js
Last active December 20, 2018 07:38
Node.js app with Firebase-backed email-password authentication
'use strict';
const http = require('http')
const fs = require('fs');
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const request = require('request');
const cookieParser = require('cookie-parser');