Skip to content

Instantly share code, notes, and snippets.

View igauravsehrawat's full-sized avatar

Gaurav igauravsehrawat

View GitHub Profile
const model: EntityState = [
{
"linksTo": [
{
"points": [
{
"y": 375,
"x": 150
},
def foo(i, a=[]):
a.append(a.append(i))
return a
for i in range(3):
b = foo(i)
print(b)
@igauravsehrawat
igauravsehrawat / BotLovin.cs
Created May 5, 2017 10:14 — forked from NickCraver/BotLovin.cs
Some bot/crawler fun on Stack Overflow. 10 hours of fun, to be precise.
private static readonly string[] tenHoursOfFun =
{
"https://www.youtube.com/watch?v=wbby9coDRCk",
"https://www.youtube.com/watch?v=nb2evY0kmpQ",
"https://www.youtube.com/watch?v=eh7lp9umG2I",
"https://www.youtube.com/watch?v=z9Uz1icjwrM",
"https://www.youtube.com/watch?v=Sagg08DrO5U",
"https://www.youtube.com/watch?v=ER97mPHhgtM",
"https://www.youtube.com/watch?v=jI-kpVh6e1U",
"https://www.youtube.com/watch?v=jScuYd3_xdQ",
➜ selenium git:(save_screenshot) ./go clean test
(in /Users/root3d/Documents/github-repos/selenium)
Scanning deps
Writing build/javascript/deps.js
Apr 10, 2017 5:37:09 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNING: Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Fri, 10 Apr 2037 12:07:09 -0000; secure; HttpOnly". Invalid 'expires' attribute: Fri, 10 Apr 2037 12:07:09 -0000
/Users/root3d/Documents/github-repos/selenium/buck-out/crazy-fun/35906a88243594636b9c4f68cf0423dd9aa0808b/buck.pex kill
Using watchman.
[2017-04-10 17:37:49.782][error][command:null][tid:17][com.facebook.buck.apple.AppleToolchainDiscovery] Failed to resolve info about toolchain /Applications/Xcode.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain from plist files [ToolchainInfo.plist, Info.plist]
[-] PARSING BUCK FILES...FINISHED 1.7s [100%]
@igauravsehrawat
igauravsehrawat / parse.py
Created July 21, 2016 08:01 — forked from kssreeram/parse.py
Writing Parsers
import sys
#
# ParserInput
#
# This class represents the input data and the current
# position in the data.
#
# Brief note about 'max_position':
function appendAndSendImageHW() {
var allFiles = document.querySelector('input').files;
for (var i = 0; i < allFiles.length; i++) {
var file = allFiles[i];
var newImg = new Image();
newImg.onload = function() {
console.log(newImg.height, newImg.width);
file["height"] = newImg.height;
file["width"] = newImg.width;
}

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

This is a plain-text version of Bret Victor’s reading list. It was requested by hf on Hacker News.


Highly recommended things!

This is my five-star list. These are my favorite things in all the world.

A few of these works have had an extraordinary effect on my life or way of thinking. They get a sixth star. ★

from pyparsing import *
# By default, PyParsing treats \n as whitespace and ignores it
# In our grammer, \n is significant, so tell PyParsing not to ignore it
ParserElement.setDefaultWhitespaceChars(" \t")
def parse(input_string):
def convert_prop_to_dict(tokens):
"""Convert a list of field property tokens to a dict"""
prop_dict = {}
#
# Write partition to return a new array with
# all values less then `v` to the left
# and all values greater then `v` to the right
#
someList = [4, 5,1, 3, 0, 9, 8, 12]
def partition(L, v):
P = L
# your code here