Skip to content

Instantly share code, notes, and snippets.

View pdvyas's full-sized avatar

Pratik Vyas pdvyas

View GitHub Profile
@pdvyas
pdvyas / bochs-howto-scott.md
Last active September 15, 2022 01:53
bochs-howto

Compile bochs

  • Checkout code
cd ~/temp/bochs-svn/
svn co http://svn.code.sf.net/p/bochs/code/trunk/bochs
cd bochs
"""
Script to test assignment 1. Subject to change.
"""
import json
import unittest
try:
import requests
except Exception as e:
print "Requests library not found. Please install it. \nHint: pip install requests"
@pdvyas
pdvyas / vm.yml
Created February 27, 2016 22:58
VM build server playbook
---
- hosts: all
user: root
become: yes
become_user: root
tasks:
- name: Set hostname
hostname: name={{ hostname }}
- name: install packages
@pdvyas
pdvyas / test.py
Last active January 13, 2016 05:54
import psycopg2
conn = psycopg2.connect("dbname=endless")
conn_new = psycopg2.connect("dbname=endless_new")
cur = conn.cursor()
cur_new = conn_new.cursor()
cur.execute('select id from articles')
article_ids = [id[0] for id in cur.fetchall()]
@pdvyas
pdvyas / Readme.md
Created May 26, 2014 09:11
Sales Invoice REST API example

This example uses curl. You can use any other means of making http requests. Responses are in JSON format.

  • Login to frappe (and store cookies in a jar)
% curl https://demo.frappecloud.com/api/method/login -XPOST \-d "usr=demo%40frappecloud.com&pwd=demo" -c frappe.cookie   
{"message":"Logged In","full_name":"Demo User"}
  • Request for a Sales Invoice by id (output is piped to json pretty printer(optional))
@pdvyas
pdvyas / plot.py
Created August 13, 2012 22:15
Serial value plotting
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import serial
def list_shift(a,x):
del a[0]
a.append(x)
@pdvyas
pdvyas / gist:2198372
Created March 25, 2012 17:12
A trip to Unicode
# -*- coding: utf-8 -*-
a = open('t.txt').read()
# t.txt contains П001
s = [a]
print [d.decode('utf-8') for d in s]
# the line below fails
#print [d.encode('utf-8') for d in s]