Skip to content

Instantly share code, notes, and snippets.

View shobhit's full-sized avatar

Shobhit shobhit

View GitHub Profile
const getCssSelectorShort = (el) => {
let path = [], parent;
while (parent = el.parentNode) {
let tag = el.tagName, siblings;
path.unshift(
el.id ? `#${el.id}` : (
siblings = parent.children,
[].filter.call(siblings, sibling => sibling.tagName === tag).length === 1 ? tag :
`${tag}:nth-child(${1+[].indexOf.call(siblings, el)})`
)
const getCssSelector = (el) => {
let path = [], parent;
while (parent = el.parentNode) {
path.unshift(`${el.tagName}:nth-child(${[].indexOf.call(parent.children, el)+1})`);
el = parent;
}
return `${path.join(' > ')}`.toLowerCase();
};
@shobhit
shobhit / index.html
Created February 15, 2021 04:50 — forked from biovisualize/index.html
Download SVG with preview
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<title>Download SVG</title>
<style type="text/css">
a{
cursor: pointer;
text-decoration: underline;
color: black;
@shobhit
shobhit / ChangeMacAddress.sh
Last active February 8, 2021 04:31
Change Mac Address Script
#!/bin/bash
echo "Hi! lets change our mac address."
echo "Step 1: hold down option key, click wifi logo. Note the mac address"
echo "Step 2: click 'disconnect from network' "
echo "Step 3: note which ethernet adapter lines up with the mac address you just saw"
read -p 'Step 4: Which device lined up would you like to change? (hit return for en0) ' ether_adapter
if [ -z $ether_adapter ]
then
{
"basics": {
"name": "Shobhit Jain",
"label": "Full Stack Developer",
"email": "shobhitjain26@gmail.com",
"phone": "+91-8880145930",
"summary": "Started career from a small startup called mygola.com which got acquired by makemytrip.com. From chrome-extension to large scale apps i have worked on lots of technologies and interesting projects. I love to get challenged by difficult problems and try to get innovative solutions",
"location": {
"address": "B508, Manar Elegance",
"postalCode": "560102",
@shobhit
shobhit / dijkstra.py
Created February 24, 2017 17:22 — forked from mdsrosa/dijkstra.py
Modified Python implementation of Dijkstra's Algorithm (https://gist.github.com/econchick/4666413)
from collections import defaultdict, deque
class Graph(object):
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
@shobhit
shobhit / keybase.md
Last active September 1, 2016 04:26
keybase.md

Keybase proof

I hereby claim:

  • I am shobhit on github.
  • I am shobhit (https://keybase.io/shobhit) on keybase.
  • I have a public key ASCKYhA9dZyuhgAfNe63VAjf3JTiYsJ3CIC69soXskP3Jgo

To claim this, I am signing this object:

@shobhit
shobhit / Anim leave right
Last active August 29, 2015 14:22
Android anim leave right
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:duration="350"/>
</set>
@shobhit
shobhit / 0_reuse_code.js
Last active August 29, 2015 14:22
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
@shobhit
shobhit / jsonPy
Created December 2, 2012 06:07
Read JSON from HTTP Json URL
# Load Json into a Python object
import urllib2
import json
req = urllib2.Request("http://localhost/sensors/temperature.json")
opener = urllib2.build_opener()
f = opener.open(req)
json = json.loads(f.read())
print json
print json['unit']