Skip to content

Instantly share code, notes, and snippets.

Viren Rajput bkvirendra

Block or report user

Report or block bkvirendra

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bkvirendra
bkvirendra / generate_apps.py
Last active Mar 22, 2018
Generate django `apps.py` for all apps (in a project which didn't have it before)
View generate_apps.py
import os
# this is only used if all your django apps are located in a sub directory
base_dir = 'apps/'
all_files = [base_dir + item for item in os.listdir(base_dir)]
app_dirs = [item for item in all_files if os.path.isdir(item)]
print(app_dirs)
@bkvirendra
bkvirendra / booking.py
Last active Feb 15, 2017
booking.com request
View booking.py
import requests
url = "https://www.booking.com/fragment.en-gb.json"
querystring = {"label":"gen173nr-1FCAsoUEITYXBhcnRtZW50LWVkaW5idXJnaEgzYgVub3JlZmhQiAEBmAEuwgEDYWJuyAEM2AEB6AEB-AELqAIE;sid=492fbc101c48a00638737132bfafa6f3"}
payload = "name=searchresults.restricted_availability&checkin=2017-03-21&checkout=2017-03-24&simpleav=1&src=srflex&search_config=%7B%22b_adults_total%22%3A2%2C%22b_nr_rooms_needed%22%3A1%2C%22b_children_total%22%3A0%2C%22b_is_group_search%22%3A0%2C%22b_pets_total%22%3A0%2C%22b_rooms%22%3A%5B%7B%22b_adults%22%3A2%2C%22b_room_order%22%3A1%7D%5D%7D&hids=%5B%221395666%22%5D"
headers = {
'cookie': "cws=true; _gat=1; zz_cook_tms_seg1=2; has_preloaded=1; zz_cook_tms_ed=1; zz_cook_tms_seg3=5; __qca=P0-1520944886-1487187098481; vpmss=1; zz_cook_tms_hlist=1395666; _tq_id.TV-634572-1.3b4c=5bf4a2d99216597d.1487187099.0.1487187430..; BJS=-; _ga=GA1.2.1446933302.1487187035; lastSeen=0; bkng=11UmFuZG9tSVYkc2RlIyh9YfDNyGw8J7nziSz%2Fat4kbjEhEP2TcjD8BVRhU29TkUSjNonsJ8%2FR9IhFXlvoEcApjaF1qV8aPP2FAi
@bkvirendra
bkvirendra / javascript
Last active Dec 20, 2015
JSON Dict for ISO 3166-1 alpha-2 for all countries
View javascript
[{"code":"AF","name":"Afghanistan"},{"code":"AX","name":"Aland Islands"},{"code":"AL","name":"Albania"},{"code":"DZ","name":"Algeria"},{"code":"AS","name":"American Samoa"},{"code":"AD","name":"Andorra"},{"code":"AO","name":"Angola"},{"code":"AI","name":"Anguilla"},{"code":"AQ","name":"Antarctica"},{"code":"AG","name":"Antigua and Barbuda"},{"code":"AR","name":"Argentina"},{"code":"AM","name":"Armenia"},{"code":"AW","name":"Aruba"},{"code":"AU","name":"Australia"},{"code":"AT","name":"Austria"},{"code":"AZ","name":"Azerbaijan"},{"code":"BS","name":"Bahamas"},{"code":"BH","name":"Bahrain"},{"code":"BD","name":"Bangladesh"},{"code":"BB","name":"Barbados"},{"code":"BY","name":"Belarus"},{"code":"BE","name":"Belgium"},{"code":"BZ","name":"Belize"},{"code":"BJ","name":"Benin"},{"code":"BM","name":"Bermuda"},{"code":"BT","name":"Bhutan"},{"code":"BO","name":"Bolivia, Plurinational State of"},{"code":"BQ","name":"Bonaire, Sint Eustatius and Saba"},{"code":"BA","name":"Bosnia and Herzegovina"},{"code":"BW","name":"Bo
View bootstrap.flatten.css
/* Flatten das boostrap */
.hero-unit, .well, .navbar-inner, .popover, .btn, .tooltip, input, select, textarea, pre, .progress, .modal, .add-on, .alert, .table-bordered, .nav>.active>a, .dropdown-menu, .tooltip-inner, .badge, .label, .img-polaroid {
-moz-box-shadow: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
-webkit-border-radius: 0px !important;
-moz-border-radius: 0px !important;
border-radius: 0px !important;
border-collapse: collapse !important;
background-image: none !important;
@bkvirendra
bkvirendra / gist:5840317
Created Jun 22, 2013
Installing wi-fi drivers on Ubuntu 12.04 for Ra-link corp
View gist:5840317
First check your wifi hardware
$ lspci | grep Network
Download the driver source http://www.ralinktech.com/en/04_support/support.php
Extract the tar file to your home directory, `cd` to the extracted directory
$ nano os/linux/config.mk
View db_backup.sh
# take a backup of Database using pg_dump
# replace the postgres with Database username and the dbname with the Database name
# save it to a tar file
pg_dump --username=postgres -h localhost -F tar dbname > $(date "+%Y%m%d.tar")
# upload the DB backup to Dropbox
python uploader.py
@bkvirendra
bkvirendra / url_shortner.php
Created Jun 26, 2012
url Shortner function
View url_shortner.php
<?php
// By Virendra Rajput
// June 27, 2012
function shortner($url) {
$longUrl = $url; // url to be shortned
$apiKey = ''; // Get API key from : http://code.google.com/apis/console/
View autocomplete_suggestions.php
<?php
if (isset($_REQUEST["q"])) {
$query = $_REQUEST["q"];
$q = "'http://google.com/complete/search?output=toolbar&q=$query'"; // Building the query
// yql request
$query = "select * from xml where url=$q";
@bkvirendra
bkvirendra / ruby_sinatra.rb
Created Jun 3, 2012
Ruby webservice using Sinatra
View ruby_sinatra.rb
require 'sinatra.rb'
before do
headers "Access-Control-Allow-Origin" => "*"
end
get '/ping' do
'OK'
end
@bkvirendra
bkvirendra / gist:2823301
Created May 29, 2012
Code for Invite friends
View gist:2823301
javascript:var x=document.getElementsByTagName("input");for(var i=0;i<x.length;i++) {if (x[i].type == 'checkbox') {x[i].click();}}; alert('Done, all your friends have been selected');
You can’t perform that action at this time.