Skip to content

Instantly share code, notes, and snippets.

View igauravsehrawat's full-sized avatar
💭
I may be slow to respond.

Gaurav igauravsehrawat

💭
I may be slow to respond.
View GitHub Profile
@igauravsehrawat
igauravsehrawat / gist:fea8394737fc9fff6422
Last active August 29, 2015 14:21
how can i map to orignal points ?
# Enter your code here. Read input from STDIN. Print output to STDOUT
from math import hypot, atan2, pi
def polar(x, y):
k = 180.0 * atan2(y, x) / pi
if k<0: k+=360
return k,hypot(x, y)
n = int(raw_input())
ans1 = []
ans = []
@igauravsehrawat
igauravsehrawat / _.md
Last active August 29, 2015 14:17 — forked from klange/_.md

Since this is on Hacker News...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later).
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • They're all while loops because shut up, you're overthinking a joke.
action_var = ""
a_hash = {"condition":a_condition,
"action":a_hash}
a_condition ={"param":"abc",
"operator":">",
"value":"cde"}
a_action = {"param":action_var,
"operation":"=",
"value":"action taken"
}
@igauravsehrawat
igauravsehrawat / gist:0496b2b5e037aefefc5d
Last active August 29, 2015 14:13
int is not callable
def main():
testcases = int(raw_input())
while(testcases):
testcases = testcases - 1
BW = raw_input().split(' ')
#assigning values
b, w = int(BW[0]), int(BW[1])
XYZ = raw_input().split(' ')
x, y, z = int(XYZ[0]), int(XYZ[1]), int(XYZ[2])
mod = (x-y) if ((x-y) > 0) else (y-x)
if(!String.justlinkify) {
String.prototype.justlinkify = function() {
// http://, https://, ftp://
var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim;
// www. sans http:// or https://
var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
// Email addresses
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
#!/bin/bash
read input
if ("$input" == "Y" )|| ("$input"== "y") ; then
echo "YES"
exit 1
elif ("$input" == "N")|| ("$input" == "n") ; then
echo "NO"
exit 1
@igauravsehrawat
igauravsehrawat / gist:efdf454dd9d11e22b2b4
Last active August 29, 2015 14:07
should work ? has scrapy changed something
# -*- coding: utf-8 -*-
from scrapy import log
from scrapy.log import ScrapyFileLogObserver
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from scrapy.http import Request
import urlparse
Downloading/unpacking leagueoflegends
Downloading leagueoflegends-0.12.tar.gz
Running setup.py (path:/tmp/pip_build_root/leagueoflegends/setup.py) egg_info for package leagueoflegends
Installing collected packages: leagueoflegends
Running setup.py install for leagueoflegends
Successfully installed leagueoflegends
Cleaning up...