Skip to content

Instantly share code, notes, and snippets.

View PritishC's full-sized avatar

Pritish Chakraborty PritishC

View GitHub Profile
@PritishC
PritishC / path_graph.py
Last active February 17, 2022 07:56
Path Graph Submodularity
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
# Bidrectional path graph: nodes labelled 0 to 7.
# 0 <-> 1 <-> .... 6 <-> 7
dig = nx.path_graph(8).to_directed()
weights = {}
@PritishC
PritishC / wget-jdk-oracle-install-example.txt
Created October 18, 2017 06:57 — forked from sr75/wget-jdk-oracle-install-example.txt
wget command to install Oracle JAVA JDK from stupid oracle website for centos and ubuntu
http://d.stavrovski.net/blog/post/how-to-install-and-setup-oracle-java-jdk-in-centos-6
# rpm
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm" \
-O jdk-7-linux-x64.rpm
# ubuntu
@PritishC
PritishC / celery_lock.py
Last active October 5, 2017 18:23
Celery Lock Decorator
# -*- coding: utf-8 -*-
from functools import wraps
from django.core.cache import get_cache # deprecated in newer versions of django; use caches array.
def once_only_task(fun):
"""
Decorator function to apply locking to Celery tasks; using a cache.
If a task has already acquired a lock and is executing, then other tasks
def test_all_cssmenu_links():
"""
This test function tests each link in the
drop-down. It does so by sending an HTTP request
to each link and looking for a 200 response code.
"""
with Browser() as driver:
driver.visit(PRODUCTION_URL)
div = driver.find_by_css(
@PritishC
PritishC / variation_data.json
Created February 4, 2015 08:34
Example variation_data
{
"variants": [
{
"attributes": {
"medium": "digital"
},
"code": "1-5-C-FT-58",
"id": 1,
"image_urls": [
{
@PritishC
PritishC / elasticmapping.json
Created January 14, 2015 07:04
Dynamic Mapping
"attributes": {
"properties": {
"Frog (123)": {
"type": "string"
},
"color": {
"type": "string"
},
"medium": {
"type": "string"
@PritishC
PritishC / update.py
Created January 7, 2015 08:36
Button update SaleLine
cls._buttons.update({
'update_product': {
'invisible': Eval('_parent_sale', {}).get('state').in_(
['processing', 'cancel', 'done']
),
'readonly': ~Eval('_parent_sale', {}).get('state').in_(
['draft', 'confirmed', 'quotation']
),
},
})
ERROR: test_0055_guest_checkout (tests.test_templates.TestLNTemplates)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pritishc/RestOfFileSystem/nereid-stuff/lie-nielsen/tests/test_templates.py", line 716, in test_0055_guest_checkout
'endicia_mailclass': mailclass.id,
File "/home/pritishc/.virtualenvs/ln-dev/local/lib/python2.7/site-packages/werkzeug/test.py", line 772, in post
return self.open(*args, **kw)
File "/home/pritishc/.virtualenvs/ln-dev/local/lib/python2.7/site-packages/flask/testing.py", line 108, in open
follow_redirects=follow_redirects)
File "/home/pritishc/.virtualenvs/ln-dev/local/lib/python2.7/site-packages/werkzeug/test.py", line 736, in open
def test_0055_guest_checkout(self):
"""
Test for guest checkout.
"""
with Transaction().start(DB_NAME, USER, CONTEXT):
self.setup_defaults()
self.create_test_products()
app = self.get_app()
product1, = self.ProductTemplate.search([
Traceback (most recent call last):
File "/home/pritishc/RestOfFileSystem/nereid-stuff/nereid-webshop/tests/test_party.py", line 57, in test_0030_test_party_search
results = self.Party.search([('rec_name', 'ilike', '%thomas%')])
File "/home/pritishc/.virtualenvs/webshop/local/lib/python2.7/site-packages/openlabs_nereid_webshop-3.2.1.0-py2.7.egg/trytond/modules/nereid_webshop/party.py", line 166, in search
cls.search_name(search_phrase, limit=limit, fields=["id"])
File "/home/pritishc/.virtualenvs/webshop/local/lib/python2.7/site-packages/pyes-0.99.5-py2.7.egg/pyes/es.py", line 1613, in __next__
self._do_search()
File "/home/pritishc/.virtualenvs/webshop/local/lib/python2.7/site-packages/pyes-0.99.5-py2.7.egg/pyes/es.py", line 1416, in _do_search
self._results = self._search_raw(self.start, self.chuck_size)
File "/home/pritishc/.virtualenvs/webshop/local/lib/python2.7/site-packages/pyes-0.99.5-py2.7.egg/pyes/es.py", line 1659, in _search_raw