Skip to content

Instantly share code, notes, and snippets.

Tarun Bhardwaj tarunbhardwaj

Block or report user

Report or block tarunbhardwaj

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
@tarunbhardwaj
tarunbhardwaj / fix-virtualenv.sh
Last active Jun 16, 2018
Fix broken python links in venv
View fix-virtualenv.sh
# Fix borken python links in all venv
cd ~/.virtualenvs
for i in `workon`
do
if [ $(find $i/ -type l | tail -n 1 | grep "python3") ]; then
echo "$i python3"
find $i/ -type l -delete
virtualenv $i --python=python3
@tarunbhardwaj
tarunbhardwaj / move-google-datastore.py
Created Apr 24, 2017
Move Google datastore data to different project or to different account
View move-google-datastore.py
# -*- coding: utf-8 -*-
"""
move_google_datastore
Move google datastore data to different project / different account.
:license: MIT
"""
from google.cloud import datastore
from google.cloud.datastore.entity import Entity
View postgresql 9.6 with REPMGR.md
View setup-sftp-chroot.md

Setup SFTP with chroot

  1. Create folder to chroot mkdir /opt/sftp

  2. Change ownership chown root:root /opt/sftp

  3. Change mode chmod go-w /opt/sftp

  4. Change sshd config /etc/ssh/sshd_config

@tarunbhardwaj
tarunbhardwaj / README.md
Last active Dec 24, 2015
Python wsgi script to dispatch request based on request header
View README.md

WSGI Script to dispatch request based on request header

Installation

pip install flask paste

usage

@tarunbhardwaj
tarunbhardwaj / bulk-permission.js
Created Aug 28, 2015
A JS hack to grant permission of PyPi ( https://pypi.python.org/ ) packages in bulk :)
View bulk-permission.js
// For https://pypi.python.org/pypi
// Inject jquery before following script
// My quick jquery injector:
// javascript:var b=document.body;if(b){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='https://code.jquery.com/jquery-1.10.2.min.js');void(b.appendChild(z));}else{}
var links = $("#document-navigation ul a");
var test = links.each(function(index, link){
var package = $(link).html();
View change_db_owner.sh
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
@tarunbhardwaj
tarunbhardwaj / UPS-Respose.xml
Created Dec 11, 2014
The Response from UPS address validation
View UPS-Respose.xml
<AddressValidationResponse>
<Response>
<TransactionReference>
<CustomerContext>unspecified</CustomerContext>
</TransactionReference>
<ResponseStatusCode>1</ResponseStatusCode>
<ResponseStatusDescription>Success</ResponseStatusDescription>
</Response>
<AddressValidationResult>
<Rank>1</Rank>
View designer.html
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@tarunbhardwaj
tarunbhardwaj / Jinja-static-site.py
Last active Dec 9, 2015
Render JInja template as static site using Flask
View Jinja-static-site.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Jinja2 static site renderer using Flask
@author Tarun Bhardwaj
@license FreeBSD Licence
"""
from flask import Flask, abort, render_template
from jinja2 import TemplateNotFound
You can’t perform that action at this time.