Skip to content

Instantly share code, notes, and snippets.

View sashabaranov's full-sized avatar

Alexander Baranov sashabaranov

View GitHub Profile

Poor Man's Colormap

Colormap is a way to convert some value with given range to RGB color.

There are multiple colormaps available in matplotlib package.

If you don't want to bring matplotlib's numerous dependencies with you, here is a simple solution, based on matplotlib data:

import sys
import json
print sys.argv
from DIRAC.Core.Base import Script
Script.parseCommandLine( ignoreErrors = True )
from LHCbDIRAC.BookkeepingSystem.Client.BookkeepingClient import BookkeepingClient
bk = BookkeepingClient()
#print bk.setRunAndProcessingPassDataQuality(158013 ,'/Real Data','OK')
@sashabaranov
sashabaranov / gist:d40f2cfa2e961943608b
Last active August 29, 2015 14:09
Python url wrapper
import os
class u(str):
"""
Class to deal with urls concat.
"""
def __init__(self, url):
self.url = str(url)
def __add__(self, other):
#include <stdio.h>
#define BUF_SIZE 256
int main()
{
char A[BUF_SIZE], B[BUF_SIZE], C[BUF_SIZE];
scanf("%s %s %s", &A, &B , &C);
@sashabaranov
sashabaranov / pi.py
Created September 23, 2012 07:40
Pythonic parallel π calculation
import sys
from multiprocessing import Pool
from random import random
def calculate_pi(iters):
""" Worker function """
points = 0 # points inside circle
TBranch *BDTBranch = new TBranch();
BDTBranch = theTree->Branch("BDT_MVA", &BDT_MVA, "BDT_MVA/F");
theTree->SetBranchAddress("Bctau",&TBctau);
theTree->SetBranchAddress("BmipCHI2PV",&TBmipCHI2PV);
theTree->SetBranchAddress("Mu1ipChi2BPV",&TMu1ipChi2BPV);
theTree->SetBranchAddress("Mu2ipChi2BPV",&TMu2ipChi2BPV);
theTree->SetBranchAddress("PipipChi2BPV",&TPipipChi2BPV);
theTree->SetBranchAddress("PimipChi2BPV",&TPimipChi2BPV);
theTree->SetBranchAddress("Bvchi2",&TBvchi2);