Skip to content

Instantly share code, notes, and snippets.

@csbuja
csbuja / test gist
Created April 27, 2014 14:35
test gist
#include <iostream>
using namespace std;
int main()
{
cout << "test" << endl;
@csbuja
csbuja / gist:e73591ad3eff6f5a11d8
Created June 6, 2014 17:06
oldmanage.py for graphite
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
@csbuja
csbuja / gist:c521684567429f1e96a6
Last active August 29, 2015 14:05
Some thing
var express = require('express');
var request = require('request');
var app = express();
var APICALLNAME = 'set this here ... maybe other names I have no idea, nick'
app.get('/'+APICALLNAME, function(req, res) {
request.get({
url: 'twitter apicall url', json:true}, function(error, response, body){
res.json(response); // assuming you're getting json not other stuff like xml or something
});
});
@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
@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 / 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() {
#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 / 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
@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 / 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]))