Skip to content

Instantly share code, notes, and snippets.

View prashnts's full-sized avatar
🥔
potatoes?

Prashant Sinha prashnts

🥔
potatoes?
View GitHub Profile
@prashnts
prashnts / indian.districts.geocoded.pincode.json
Created December 6, 2014 12:53
Indian District's GeoCoded Pin Code Data
{
"_description: Name of City, or Town": {
"State": "The Indian State under which this City/Town exists.",
"GeoCode": [
"Latitude",
"Longitude"
],
"PinCodes": [
"All",
"The",
blueprint:
name: Ikea Styrbar Remote over Z2M
description: Control your lights with the IKEA STYRBAR remote. You can also set actions for the left and right button.
domain: automation
input:
transition_time:
name: Transition time
description: Transition time for the target lights in seconds
selector:
number:
@prashnts
prashnts / asyncdownload.py
Created February 15, 2017 08:00
Asyncio Python -- Download in parallel
import aiohttp
import asyncio
BATCH_SIZE = 20
POOL_SIZE = 5
async def get_content(client, url):
async with client.get(url) as response:
return await response.text()
@prashnts
prashnts / component.jsx
Created August 26, 2020 05:58
Blueprintjs Pagination component example
import React, { Component } from 'react'
import { Button, Intent } from '@blueprintjs/core'
const CELL_COUNT = 7
const CELL_MID_LEN = ~~(CELL_COUNT / 2)
class Pagination extends Component {
// This component implements pagination buttons such as these:
// ┌───┬───┬───┬───┬───┐
@prashnts
prashnts / pandas_ix.py
Created December 21, 2016 08:47
Perf comparison when using Integer vs. String indexes in a Pandas DF
import pandas as pd
import numpy as np
LIM = 100000
df_i = pd.DataFrame(np.random.randint(0, 100, size=(LIM, 4)), columns=list('ABCD'), index=list(range(0, LIM)))
df_s = pd.DataFrame(np.random.randint(0, 100, size=(LIM, 4)), columns=list('ABCD'), index=list(map(hex, range(0, LIM))))
## used in ipython
>>> %timeit -n 100 df.sort_values('A')
@prashnts
prashnts / app.js
Created October 14, 2016 15:06
Three.js Network animation used on CIC 404 pages, such as: https://ducic.ac.in/does-not-exists
function init() {
var e, t = 100,
n = 50,
r = 50,
i, s;
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight,
1, 1e4);
camera.position.z = 100;
scene = new THREE.Scene;
renderer = new THREE.CanvasRenderer;
@prashnts
prashnts / keybase.md
Created February 5, 2016 06:02
Keybase ID

Keybase proof

I hereby claim:

  • I am prashnts on github.
  • I am prashnts (https://keybase.io/prashnts) on keybase.
  • I have a public key whose fingerprint is 1FE8 3C8F 39BF 06FE 8C06 2E2B 2AD4 EFE5 6AB0 6289

To claim this, I am signing this object:

@prashnts
prashnts / lodash.custom.js
Created January 18, 2016 10:34
An extended custom build of lodash, generated with: # lodash exports=commonjs include=assign,clone,filter,each,map,random,reduce,some
/**
* @license
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash exports="commonjs" include="assign,clone,filter,each,map,random,reduce,some"`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
;(function() {
@prashnts
prashnts / ie8_node_enum.js
Created October 17, 2015 20:57
IE8 Node Enum
var Node = Node || {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3
};
(function() {
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
__slice = [].slice;
deepClone = function(obj) {
var func, isArr;
if (!_.isObject(obj || _.isFunction(obj))) {
return obj;
}
if (_.isDate(obj)) {