Skip to content

Instantly share code, notes, and snippets.

View nrchandan's full-sized avatar

Chandan Kumar nrchandan

  • ThoughtWorks India Pvt. Ltd.
  • Hyderabad, India
View GitHub Profile
import pyspark
class Point(object):
'''this class being used as container'''
pass
def to_point_obj(point_as_dict):
'''convert a dict representation of a point to Point object'''
p = Point()
p.x = point_as_dict['x']
chandank@PRINHYLTPHP0314:~/workspace/pandas-cookbook/cookbook$ sudo pip install -U rpy2
[sudo] password for chandank:
Downloading/unpacking rpy2
Downloading rpy2-2.3.10.tar.gz (187kB): 187kB downloaded
Running setup.py (path:/tmp/pip_build_root/rpy2/setup.py) egg_info for package rpy2
sh: 1: R: not found
Error: Tried to guess R's HOME but no R command in the PATH.
Complete output from command python setup.py egg_info:
running egg_info
#!/usr/bin/python2
"""
This script automates the task of connecting to a running App Engine server,
whether it's a local dev_appserver or a live app.
If PyQt4 is installed, it will ask for credentials inside a dialog box
instead of prompting in the terminal. This is good for shells that do
not support getpass (iPython).
It will automatically add an import path for a local virtualenv in the app
@nrchandan
nrchandan / fact.py
Created October 8, 2014 09:03
Doctest for factorial function.
def fact(n):
"""
Computes factorial.
>>> fact(1)
1
>>> fact(5)
120
>>> fact(-1) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
@nrchandan
nrchandan / issue.js
Created October 28, 2014 10:42
Angular $location issue
$http.post('/campaignauth', payload).success(function(data) {
console.log(data);
if (data.response.status == 'error') {
//display alert to user
} else {
// $cookieStore.put("AMBC_SSID", data.response.token);
// The below code is intentionally set to run after a
// small delay due to cookie not being set by the time
// the location path changes. Better way to fix this
// is to set the cookie manually, as shown above, but
contract OrganisationInterface
{
function setDataStore(address _tokenLedger, address _eternalStorage);
function addProposal(bytes32 _name);
function proposalsCount() constant returns (uint256);
function getProposal(uint256 _id) constant returns (bytes32 _name, uint256 _eth);
import "OrganisationInterface.sol";
import "TokenLedger.sol";
import "EternalStorage.sol";
import "SecurityLibrary.sol";
contract Parent {
event OrganisationCreated(address organisation, uint now);
event OrganisationUpgraded(address organisation, uint now);
import "ITokenLedger.sol";
import "ProposalsLibrary.sol";
import "SecurityLibrary.sol";
import "DataVerifiable.sol";
contract Organisation is DataVerifiable
{
ITokenLedger public tokenLedger;
using ProposalsLibrary for address;
using SecurityLibrary for address;
def largest_num(nums):
"""
Form the largest number by joining the given list of numbers.
>>> largest_num([0])
0
>>> largest_num([1, 2, 0])
210
>>> largest_num([1, 10, 100])
110100
var options = {
nodes: {
shape: "dot",
scaling: {
customScalingFunction: function(min, max, total, value) {
return value / total;
},
min: 5,
max: 150
}