Skip to content

Instantly share code, notes, and snippets.


Cristóvão Duarte Sousa cdsousa

View GitHub Profile
View gamblers_falacy.jl
###### test 1
function gamblers_falacy_1(n)
h,t = 0,0; c=0; r=0
for i=1:n
p = t>h ? :h : (h>t ? :t : nothing)
o = rand((:h,:t))
View OpenCvCapture.jl
module OpenCV
export CvCapture, release, grabFrame, retrieveFrameIplImage, retrieveFrame, namedWindow, showImage, waitKey, destroyAllWindows
import Images
struct CvCapture
function CvCapture(device::Int = 0)
ptr = ccall((:cvCreateCameraCapture, "libopencv_highgui"), Ptr{Cvoid}, (Cint,), device)
View julia_multithreading.cpp
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <deque>
#include <future>
#include <iostream>
#include <mutex>
#include <thread>
#include <vector>
View gist:9c98897595177ed322b24643af4b68ce

Here's the canonical TOML example from the TOML README, and a YAML version of the same. Which looks nicer?

title = "TOML Example"

View CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
add_executable(subclassdispatchtests subclassdispatchtests.cpp)
cdsousa / fsa_literal_macros.jl
Created Aug 27, 2015
Experiments with literal vectors and matrices for FixedSizeArrays.jl
View fsa_literal_macros.jl
using FixedSizeArrays: Mat, FixedVector
immutable Vec{N, T} <: FixedVector{N, T}; _::NTuple{N, T}; end
macro fsa(expr)
if expr.head == :vect
Expr(:call, :Vec, expr.args...)
elseif expr.head == :hcat
Expr(:call, :Mat, [Expr(:tuple, a) for a in expr.args]...)
elseif expr.head == :vcat
if isa(expr.args[1], Expr) && expr.args[1].head == :row
cdsousa / SymPyBotics - Coriolis matrix.ipynb
Last active Aug 29, 2015
SymPyBotics - Coriolis matrix
View SymPyBotics - Coriolis matrix.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
cdsousa / mat_pow_int.jl
Last active Aug 29, 2015
Julia custom element-wise integer power of matrices
View mat_pow_int.jl
import Base.(.^)
function .^{T<:FloatingPoint, N}(A::Array{T, N}, x::Integer)
if abs(x) > 42 # the "Answer to the Ultimate Question of Life, the Universe, and Everything"
elseif x > 1
B = similar(A)
@inbounds for i in 1:length(A)
B[i] = A[i]
for k in 1:x-1 B[i] *= A[i] end
cdsousa / latex.xml
Created Sep 2, 2013
KDE Kate / Kateparts / Kile syntax highlighting XML for LaTeX syntax with added highlighting of Python code within PythonTeX environments.
View latex.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language name="LaTeX" version="1.53" section="Markup" kateversion="2.3" priority="10" extensions="*.tex;*.ltx;*.dtx;*.sty;*.cls;*.bbx;*.cbx;*.lbx;*.tikz" mimetype="text/x-tex" casesensitive="1" author="Jeroen Wijnhout ( Danielsson ( Ludwig ( Braun (" license="LGPL" >
<!-- Normal text -->
<context name="Normal Text" attribute="Normal Text" lineEndContext="#stay">
<RegExpr String="\\begin(?=[^a-zA-Z])" attribute="Structure" context="FindBeginEnvironment" beginRegion="block" />
<RegExpr String="\\end(?=[^a-zA-Z])" attribute="Structure" context="FindEndEnvironment" />
<RegExpr String="\\(cite|citet|citep|parencite|autocite|Autocite|citetitle)\*(?=[^a-zA-Z])" attribute="Structure" context="Label"/>
cdsousa / Fast CSE.ipynb
Last active Dec 19, 2015
SymPy Common Subexpression Elimination (CSE) Implementation Comparison Example
View Fast CSE.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.