Skip to content

Instantly share code, notes, and snippets.

@vik-y
vik-y / nat.sh
Created July 21, 2015 06:30
A code for forwarding
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE #Forward on this interface
iptables -A FORWARD -i wlan0 -j ACCEPT #Tells to accept all connections coming on wlan0
# Works completely fine - Need to test it on OpenVPN
# Here the interface which has internet is eth0
# Need to understand POSTROUTING nad MASQUERADE
from socket import *
s=socket(AF_INET, SOCK_DGRAM)
s.bind(('',12345))
m=s.recvfrom(1024)
print m[0]
@vik-y
vik-y / delete_all_tweets.py
Last active September 22, 2023 21:04 — forked from davej/delete_all_tweets.py
This script will delete all of the tweets in a specified account.
# -*- coding: utf-8 -*-
"""
This script is forked originally from Dave Jeffery. The original implementation
was very slow and deleted around 2 tweets per second. Making it multithreaded I
am able to delete 30-50 tweets per second.
@author: vik-y
----------------------------------------------------------------------------
This script will delete all of the tweets in the specified account.
@vik-y
vik-y / interfaces
Created September 6, 2015 05:00
Raspberry pi wifi connection
#
# /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
#allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
@vik-y
vik-y / pc-lock.c
Created September 26, 2015 13:09
Producer Consumer Problem Implementation using lock and turn variables
/*
* pc-lock.c
*
* Created on: Sep 24, 2015
* Author: Vikas Yadav (IMT2013060)
* Producer Consumer Problem using lock variables
*
* NOTE:
*
* This solution works most of the time properly.
@vik-y
vik-y / class_related.rb
Last active October 31, 2015 07:22
Some important things about ruby
@vik-y
vik-y / readme.txt
Last active May 19, 2017 17:41
Web Development - Things you need to know
Some info and links to help people understand what exactly is web development, what are its key elements and all
you need to know to get started
First of all what is a Server?
http://whatis.techtarget.com/definition/server
What is a Client-Server architecture?
- It is one of the most prominent architectures used to design any software which interacts with web. Be it a website,
a chat service or anything.
https://en.wikipedia.org/wiki/Client%E2%80%93server_model
@vik-y
vik-y / update-ruby.sh
Created November 21, 2015 11:05 — forked from scmx/upgrade-install-ruby-2-1-2-ubuntu-12-04.md
Upgrade/Install ruby 2.1.2 #ubuntu #12.04 #14.04
# Reference http://stackoverflow.com/a/18490935/2037928
# Login as root
# Install needed packages
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
# Download appropriate ruby version https://www.ruby-lang.org/en/downloads/
@vik-y
vik-y / backup.sh
Created December 11, 2015 03:58
A script to backup all mysql databases
#!/bin/sh
# System + MySQL backup script
# Copyright (c) 2008 Marchost
# This script is licensed under GNU GPL version 2.0 or above
# ---------------------------------------------------------------------
# Taken from : https://www.howtoforge.com/shell-script-to-back-up-all-mysql-databases-each-table-in-an-individual-file-and-upload-to-remote-ftp
#########################
######TO BE MODIFIED#####
@vik-y
vik-y / jsonpy.py
Created December 12, 2015 09:23
Generate and read json using python
# Generating json
import json
from pprint import pprint
data = {}
data['key'] = ['value']
data['1']='bak'
json_data = json.dumps(data)
# Output: '{"1": "bak", "key": ["value"]}'