Skip to content

Instantly share code, notes, and snippets.

View bollu's full-sized avatar

Siddharth bollu

View GitHub Profile
mm@cereal:~/dytest$ rustc -C prefer-dynamic --crate-type=dylib fooz.rs
mm@cereal:~/dytest$ cat fooz.rs
#[no_mangle]
pub extern "C" fn foo(x: int) {
println!("Cowabunga, {}", x);
}
mm@cereal:~/dytest$ cat test.py
import ctypes
fooz = ctypes.CDLL("/home/mm/dytest/libfooz-afaf02c9-0.0.so")
#[link(name="python2.7")]
extern {
fn Py_SetProgramName(name: *u8);
fn Py_Initialize();
fn PyRun_SimpleString(command: *u8);
fn Py_Finalize();
}
fn main() {
let args = std::os::args();
@bollu
bollu / run,sh
Created June 14, 2014 09:52
Running rust-bindgen on Arch with clang3.4 has.. problems. This fixes them
LD_PRELOAD=/usr/lib/libclang.so ./bindgen -I /usr/lib/clang/3.4.1/include/
#the LD_PRELOAD helps it pickup the right clang version
#the -I gives it clang's include files
@bollu
bollu / pie-with-legend.js
Created July 13, 2014 09:31
Abstraction over HighCharts
function draw_pie_chart(container_selector, name, title, data) {
// Build the chart
$(container_selector).highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
@bollu
bollu / density-of-rationals
Last active August 29, 2015 14:11
Density Of rationals
* Density of Real Numbers in R
∀a,b ∈ R, such that a < b, ∃t ∈ R such that a < t < b
** Proof
∀a, b, ∈ R, such that a < b
let t = (a + b)/2 ∈ R since a, b ∈ R
let δ = (b - a)/2 ∈ R
@bollu
bollu / vispy-code-complexity.txt
Last active August 29, 2015 14:26
measure vispy's code complexity using radon
~/p/vispy   colorbar-vispy-plot *$  radon cc vispy -nc -a Sun Aug 2 00:36:08 IST 2015
vispy/scene/canvas.py
M 321:4 SceneCanvas._process_mouse_event - C
M 392:4 SceneCanvas._visual_bounds_at - C
vispy/scene/visuals.py
F 133:0 generate_docstring - C
vispy/scene/cameras/base_camera.py
M 227:4 BaseCamera.set_range - C
vispy/scene/cameras/panzoom.py
M 191:4 PanZoomCamera.viewbox_mouse_event - C
@bollu
bollu / sandhi-installer.sh
Last active September 21, 2015 17:01
Install script for sandhi
#!/usr/bin/env bash
# automatically abort if any command fails
set -e
echo "This script assumes superuser privileges. You might have to run this script with sudo"
echo "Installing dependencies required by sandhi..."
apt-get update
apt-get -y install git git-core autoconf automake make libtool g++ python-dev swig \
@bollu
bollu / vimrc
Created October 20, 2015 16:06
call plug#begin('~/.vim/plugged')
"Core
Plug 'terryma/vim-expand-region'
Plug 'Valloric/YouCompleteMe'
Plug 'kien/ctrlp.vim'
Plug 'majutsushi/tagbar'
Plug 'ervandew/supertab'
@bollu
bollu / proxy_switch.sh
Created December 13, 2015 10:04 — forked from jameswomack/proxy_switch.sh
Bash/ZSH for changing git/npm/global proxy info based on current Wifi SSID on Mac
alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
CURRENT_WIFI_SSID=$(eval airport -I | grep '^[[:space:]]*SSID' | sed -e 's/^.*SSID: //g')
proxy() {
export addy='http://www-west.sony.com:80'
git config --global http.proxy $addy
git config --global https.proxy $addy
npm config set http-proxy $addy
npm config set https-proxy $addy
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
data Free f a = Pure a | Branch (f (Free f a))
deriving instance (Show a, Show (f (Free f a))) => Show (Free f a)