Skip to content

Instantly share code, notes, and snippets.

Vaidik Kapoor vaidik

Block or report user

Report or block vaidik

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
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@vaidik
vaidik / outward_walk.py
Created Aug 21, 2014
Python: Outward Walk
View outward_walk.py
import os
def outward_walk(bottom, func, arg=None):
'''
Walks out of directory to the upper level directories in the path.
Usage is very similar to os.path.walk.
'''
levels = bottom.split('/')
while len(levels) > 1:
@vaidik
vaidik / StackOverflow Question: Aggs on Nested Documents
Last active Aug 29, 2015
Displays how to use aggregations in Elasticsearch on documents with nested types
View StackOverflow Question: Aggs on Nested Documents
# Answer for: http://stackoverflow.com/questions/24631409/average-and-histogram-aggregation-on-nested-fields-in-elasticsearch
curl -XPUT "http://localhost:9200/aggs/test/_mapping" -d'
{
"test": {
"properties": {
"doctxt": {
"type": "string"
},
"nested": {
View vunits.js
/**
* Polyfill for the vw, vh, vm units
* Requires StyleFix from -prefix-free http://leaverou.github.com/prefixfree/
* @author Lea Verou
*/
(function() {
if(!window.StyleFix) {
return;
View gist:6321504
#!/bin/bash
set -e
echo "Plug in your device"
adb wait-for-device
echo "Found device"
#dir=$(mktemp -d -t revision)
dir=$(mktemp -d -t revision.XXXXXX)
cd $dir
adb pull /system/b2g/omni.ja &>/dev/null || echo "Error pulling gecko"
adb pull /system/b2g/webapps/settings.gaiamobile.org/application.zip &> /dev/null || echo "Error pulling gaia file"
@vaidik
vaidik / gist:5905762
Last active Dec 19, 2015
Get element's source only in Selenium or Marionette. Both Selenium and Marionette have APIs to get source of the entire page but not just the source of the `WebElement` or `HTMLElement`. This utility function fills that gap.
View gist:5905762
def element_html(driver, elements):
"""Return source of a particular HTML element on the page.
:param driver: webdriver or marionette object - the object you use
to drive your webdriver or marionette tests.
:param elements: Webdriver.remote.webelement.WebElement object or
marionette.marionette.HTMLElement object or
a list of WebElement or HTMLElement objects
View mcom_failures.py
import json
import requests
import unittest
from time import time
def get_status_code(url):
response = requests.get(url, verify=False, allow_redirects=True)
return response.status_code
View README.markdown

Hyde publisher plugin for publishing content to Github Pages (User Pages).

https://github.com/vaidik/vaidik.github.io/tree/dev/publishers

Usage

  • Make sure that the hyde project lives in your dev branch. master branch, in case of user github pages, is left for serving static files.
  • Create an orphan master branch.
View Package Control.sublime-settings
{
"auto_upgrade_last_run": null,
"installed_packages":
[
"Alignment",
"All Autocomplete",
"Calculate",
"Case Conversion",
"Clipboard Manager",
"Codechef",
View shell_plus_reloader.py
class ReloaderEventHandler(FileSystemEventHandler):
"""
Listen for changes to modules within the Django project
On change, reload the module in the Python Shell
Custom logic required to reload django models.py modules
Due to the singleton AppCache, which caches model references.
For those models files, we must clear and repopulate the AppCache
"""
def __init__(self, *args, **kwargs):
You can’t perform that action at this time.