Skip to content

Instantly share code, notes, and snippets.

View gchavez2's full-sized avatar

Gustavo gchavez2

View GitHub Profile
@gchavez2
gchavez2 / AsyncforEach.js
Created July 5, 2018 03:08
Asyncronous for each
// Asyncronous for each
async.forEach(messageIds, function(messageId, callback) {
// Do stuff
callback();
}, function(err) {
if (err) return next(err);
// Success
});
function mit18086_poisson
%MIT18086_POISSON
% Sets up and solves a 1d, 2d and 3d Poisson problem
% on domain [0 1]^dim, with homogeneous Dirichlet b.c.
% everywhere and constant right hand side.
% Uses successive Kronecker products to construct
% sparse system matrices
% 03/2007 by Benjamin Seibold
% http://www-math.mit.edu/~seibold/
//Mongo Installation
// Generate mongod with parameters
echo "mongod --dbpath=~/data --nojournal" > mongod
chmod a+x mongod
// 1. Run the mongo deamon (mongod)
cd ~/data
./mondog
@gchavez2
gchavez2 / index.html
Created June 27, 2018 21:57
Basic form with Bootstrap 4
<html>
<header>
<title>Form with bootstrap</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
body {background-color: #ddd;}
strong { font-size: 1.3em; }
@gchavez2
gchavez2 / PyMongoHelloWorld
Last active May 16, 2018 02:35
PyMongo Hello World
from pymongo import MongoClient
import datetime
from datetime import timedelta
import pprint
client = MongoClient('mongodb://localhost:27017/')
db = client['demodb']
collection = db['test_collection']
@gchavez2
gchavez2 / conda
Last active May 16, 2018 03:00
Installing conda (Python Anaconda)
conda info --envs
conda create --name mongo_py_env
source activate mongo_py_env
source deactivate
conda install <package>
conda install pymongo
@gchavez2
gchavez2 / setup_mongodb.txt
Last active May 16, 2018 03:01
Installing up MongoDB in OS X
brew install mongodb
mkdir -p /Users/gichavez/Documents/Github/data
echo "mongod --dbpath=/Users/gichavez/Documents/Github/data --nojournal" > mongod
chmod a+x mongod
./mongod
#include "misc/TaskTimer.hpp"
{
timer.start();
// CODE here
if (!mpi_rank())
cout << "# time = " << timer.elapsed() << endl;
@gchavez2
gchavez2 / preprocessor.cpp
Last active January 4, 2018 19:14
See output of preprocessing
g++ -E helloworld.cpp > helloworld.txt
@gchavez2
gchavez2 / testTimer.cpp
Created October 30, 2017 23:55
Chrono timers C++11
// g++ -std=c++11 testTimer.cpp -o testTimer.out
// ./testTimer.out
#include <iostream>
#include <chrono>
#include <ctime>
long fibonacci(unsigned n)
{
if (n < 2) return n;