Skip to content

Instantly share code, notes, and snippets.

import numpy as np
from scipy.integrate import odeint
import math
import matplotlib.pyplot as plt
def xvyplot(t,sol,e):
plt.plot(sol[:, 0],sol[:, 1] , 'p', label='x(t) vs y(t)')
plt.title("x v y with eccentricity of " + str(e))
plt.legend(loc='best')
plt.xlabel('x')
@csbuja
csbuja / argh_examples.py
Created March 30, 2021 18:32 — forked from safijari/argh_examples.py
Python Libraries Video 1
import argh
def do_the_thing(required_arg, optional_arg=1, other_optional_arg=False):
"""
I am a docstring
"""
print((required_arg, type(required_arg)))
print((optional_arg, type(optional_arg)))
print((other_optional_arg, type(other_optional_arg)))
@csbuja
csbuja / rod.py
Last active February 15, 2019 18:53
rod
import numpy as np
def cutrod(p,n):
if n == 0:
return 0
q = -1*np.inf
for i in range(n):
i_ = i+1
q = np.max([q, p[i_-1] + cutrod( p,n - i_) ])
return q
@csbuja
csbuja / gist:151fa67754df585662fc5a7925a71df5
Last active September 30, 2018 22:23
Numerical Integration of Simple but Difficult Integral
#learned from complex analysis class that the known way of integrating 1/(1+x^2) is by applying the resideue theorem
import scipy.integrate as i
import numpy as np
f = lambda x: 1.0/(1+x**2)
print(str(i.quad(f,0,np.inf)[0]))
@csbuja
csbuja / gist:5b2d05af66aa9e7abda784ebf4a48d54
Created February 25, 2018 07:03
python memory profiling
import numpy as np
from memory_profiler import profile
@profile
def main():
a = np.ones((1000,1000))
a = a +1
print(a)
main()
@csbuja
csbuja / tmux-cheatsheet.markdown
Created April 7, 2016 17:05 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#include <iostream>
#include <fstream>
using namespace std;
template<size_t n, size_t k> struct combo;
template<size_t n>
struct combo<n,0>{
const static auto value =1;
@csbuja
csbuja / ReactExample
Created October 17, 2014 20:26
This is an example of how to build a counter with React.
/** @jsx React.DOM */
var LikeButton = React.createClass({
getInitialState: function() {
return {liked: false};
},
handleClick: function(event) {
this.setState({liked: !this.state.liked});
},
render: function() {
@csbuja
csbuja / gist:7e025c523013800059a8
Last active August 29, 2015 14:06
A flawed delete function in dynatable
$(document).ready(function(){
TableBuilder = function(username, tabledata){
this.username = username;
this.tabledata = tabledata;
}
TableBuilder.prototype.populateTable = function() {
var self = this;
var tableId = 'my-table';
this.dynatable = $('#'+tableId).dynatable({
@csbuja
csbuja / gist:5a6906fa49bfa7ce8a02
Created September 6, 2014 19:44
moveThroughYelp
function moveThroughYelp(data, type){
var setOfInfo = []
for(var i = 0; i< data.businesses.length; ++i){
var info = {}
if (!data.businesses[i].is_closed || (type === 'food' && data.businesses[i].rating<2 ) ) continue;
info.rating = data.businesses[i].rating;
info.rating_img_url_small= data.businesses[i].rating_img_url_small;
info.rating_img_url_large = data.businesses[i].rating_img_url_large;
info.rating_img_url = data.businesses[i].rating_img_url;
info.address = data.businesses[i].location.address + ' ' + data.businesses[i].location.city + ', ' + data.businesses[i].location.state_code + ' ' +data.businesses[i].location.postal_code