Skip to content

Instantly share code, notes, and snippets.

View odarbelaeze's full-sized avatar
:shipit:
Studying

Oscar Arbeláez-Echeverri odarbelaeze

:shipit:
Studying
  • NextRoll
  • Dublin, Ireland
View GitHub Profile
@odarbelaeze
odarbelaeze / DEQueue.cpp
Last active October 11, 2020 17:52
A DEQeue implementation in C++.
#include <exception>
#include <functional>
#include <iostream>
#include <stdexcept>
#include <string>
template<typename T>
class DEQeue
{
public:
@odarbelaeze
odarbelaeze / QeueArray.cpp
Last active October 11, 2020 17:52
A FIFO Stack implementation using a simple array.
#include <iostream>
#include <exception>
#include <stdexcept>
#include <functional>
#include <string>
// 1234--------
template<typename T>
class QeueArray
@odarbelaeze
odarbelaeze / problem3nplus1.cpp
Last active December 16, 2015 05:59
The 3n + 1 problem with some error
#include <iostream>
int cycle_lenght (int i)
{
int lenght = 1;
int n = i;
while (n != 1)
{
n = n % 2 == 0? n / 2 : 3 * n + 1;
lenght++;
#include <cstdio>
#include <exception>
#include <iostream>
#include <sstream>
#include <string>
// 1234--------
template<typename T>
class Stack
@odarbelaeze
odarbelaeze / sho.cc
Last active December 16, 2015 07:39
A [VMC](http://en.wikipedia.org/wiki/Variational_Monte_Carlo) implementation to find the ground state of the Simple Harmonic Oscillator.
// Compile with g++ -O2 -std=c++0x sho_test.cc -o sho_test
// or (gnu gcc 4.7 or above)
// Compile with g++ -O2 -std=c++11 sho_test.cc -o sho_test
// This package finds the ground state of the Simple Harmonic Oscillator
// with a test function \frac{\sqrt\alpha}{\pi^{\frac{1}{4}}} \exp( - \frac{1}{2} x^2\alpha^2)
#include <cmath>
#include <iomanip>
#include <iostream>
@odarbelaeze
odarbelaeze / gist:5867459
Created June 26, 2013 13:43
Using std::copy to cast between container types with c++11.
#include <algorithm>
#include <iostream>
#include <valarray>
#include <vector>
template<typename T>
std::ostream& operator<< (std::ostream& os, std::valarray<T> va)
{
for (auto&& i : va)
os << i << " ";
@odarbelaeze
odarbelaeze / gist:5882731
Created June 28, 2013 05:54
Interactive Django shell, showing how a bad unicode data error can be inserted.
In [1]: from ublog.models import Entry
In [2]: a = Entry.objects.get()
In [3]: a
Out[3]: <Entry: El título pero mas fuerte>
In [4]: a.title = "The title with more ñame"
In [5]: a.save()
@odarbelaeze
odarbelaeze / main.css
Created September 13, 2013 21:42
main.css compiled from sass-boostrap included in the yeoman webapp-generator.
/* line 141, ../../app/bower_components/sass-bootstrap/lib/_forms.scss */
.form-control[disabled],
.form-control[readonly],
fieldset[disabled] .form-control {
cursor: not-allowed;
background-color: #eeeeee;
}
/* line 148, ../../app/bower_components/sass-bootstrap/lib/_forms.scss */
@odarbelaeze
odarbelaeze / sample.f90
Created January 31, 2014 18:28
Update neighborhood subroutine in fortran
subroutine sample_updatenbh(innb_, inbh_, ennb_, enbh_, &
r_, species_, st_, it_, stat_)
integer, allocatable, dimension(:), intent(inout) :: innb_
integer, allocatable, dimension(:,:), intent(inout) :: inbh_
integer, allocatable, dimension(:), intent(inout) :: ennb_
integer, allocatable, dimension(:,:), intent(inout) :: enbh_
double precision, allocatable, dimension(:,:), intent(in) :: r_
integer, allocatable, dimension(:), intent(in) :: species_
type(sampleTraits), intent(in) :: st_
@odarbelaeze
odarbelaeze / ranges.py
Created May 19, 2014 23:03
side x side boards of zeros with python
side = 5
for i in range(side):
for j in range(side):
print 0, " ", # La última coma es para evitar el salto de linea
print ""