Skip to content

Instantly share code, notes, and snippets.

@Opiprog
Opiprog / gist:5501267
Created May 2, 2013 09:57
Plot legend with Matplotlib
plot(x,g1, label='major axis')
plot(y,g2, label='minor axis')
legend()
@Opiprog
Opiprog / contact_code1.py
Created May 2, 2013 13:28
Ipython-Matplotlib-Pylab 2D Two-line graph
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import *
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
import sys
from pylab import *
rcParams['legend.loc'] = 'best'
@Opiprog
Opiprog / 3Dpara.py
Created May 3, 2013 15:56
3D Parametric Equation Plot in Ipython-Matplotlib-Sympy
from sympy import symbols, cos, sin
from sympy.plotting import plot3d_parametric_surface
x,y = symbols('x y')
plot3d_parametric_surface(x**2, y**2, x-y, (x, -5, 5), (y, -5, 5))
@Opiprog
Opiprog / cpu_occupy.py
Created May 3, 2013 22:33
Script to occupy CPU at 100% on the Raspberry Pi
# Occupy CPU python code
i=0
while True:
i=i+1
if i==10:
i=0
@Opiprog
Opiprog / Pi_Bat_Timetest.py
Last active March 20, 2016 23:55
Recording Battery Life of RPi
# By J. Vlaskamp and M. Ali
import os
import sys
import time
import datetime
tstamp = time.time()
st = datetime.datetime.fromtimestamp(tstamp).strftime('Test staterd at %Y-%m-%d %H:%M:%S\n')
print st
@Opiprog
Opiprog / gist:5517405
Last active December 16, 2015 23:59
Omxplayer and Repeated Videos on RPi
# To install omxplayer on RPi
# Go to link http://www.gaggl.com/2013/01/installing-omxplayer-on-raspberry-pi/
# or type
sudo apt-get install omxplayer
# Run a repeated video from omxplayer in terminal on RPi
while [ 1 ]; do omxplayer -0 hdmi testvid2.mp4; done
@Opiprog
Opiprog / gist:5518060
Last active December 17, 2015 00:00
Math in Iptyhon
L = 500
Xi = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.75,0.8,0.85,0.9,0.92,0.94,0.96,0.98,0.99]
ai = [1,1.07,1.15,1.242,1.351,1.486,1.661,1.905,2.072,2.292,2.6,3.093,3.396,3.824,4.508,5.937,7.774]
bi = [1,0.936,0.878,0.822,0.769,0.717,0.664,0.608,0.578,0.544,0.507,0.461,0.438,0.412,0.378,0.328,0.287]
li = [0.75,0.748,0.743,0.734,0.721,0.703,0.678,0.644,0.622,0.594,0.559,0.51,0.484,0.452,0.41,0.345,0.288]
X = np.array(Xi)
a = np.array(ai)
b = np.array(bi)
@Opiprog
Opiprog / gist:5607808
Created May 19, 2013 14:26
Managing cells in LaTex tables
\documentclass[10pt,compsoc]{IEEEtran}
\usepackage{fixltx2e}
\begin{center}
\begin {table}
\caption{ABC}
\begin{tabular}{|c|c|c|c|c|}
@Opiprog
Opiprog / gist:5649126
Created May 25, 2013 13:55
Latex Reference Problem
@article{AliMao,
author = "M. Ali and K. Mao",
title = "Modelling of hip resurfacing device contact under central and edge loading conditions",
journal = "Lecture Notes in Engineering and Computer Science: Proceedings of The World Congress on Engineering",
year = "2012",
key = "key",
volume = "Volume 20, Issue 4",
number = "number",
pages = "2054-2059",
month = "July",
@Opiprog
Opiprog / gist:5685296
Last active December 17, 2015 22:49
Useful LaTex codes
%%%%%%% (1) ADDING HQ IMAGES TO LatexPDF %%%%%%
% The best ways I have found are through PDF or EPS formats (i.e. vector formats)
% Avoid bitmaps.
% NEVER WORK IN MS POWERPOINT! Can't export .EPS formats, only horrible bitmaps. Use OPEN OFFICE instead.
\usepackage{epstopdf}
%%%%%%% (2) SUBSCRIPT AND SUPERSCRIPT TOGETHER %%%%%%%