Skip to content

Instantly share code, notes, and snippets.

View gchavez2's full-sized avatar

Gustavo gchavez2

View GitHub Profile
@gchavez2
gchavez2 / c_papi.c
Last active August 29, 2015 14:19
Necessary additions to C file to get access to performance counters
#include <papi.h>
#define NUM_EVENTS 1
int main ( int argc, char ** argv ) {
int Events[NUM_EVENTS] = {PAPI_TLB_DM}; //Data TLB misses
<your code>
PAPI_read_counters(values, NUM_EVENTS);
@gchavez2
gchavez2 / cut_mp3.py
Created July 3, 2016 12:28
Cut mp3 file with Python and pydub
# https://github.com/jiaaro/pydub
from pydub import AudioSegment
files_path = ''
file_name = ''
startMin = 9
startSec = 50
@gchavez2
gchavez2 / Papi memory counters
Last active October 30, 2017 23:57
Papi memory counters
We couldn’t find that file to show.
@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;
@gchavez2
gchavez2 / preprocessor.cpp
Last active January 4, 2018 19:14
See output of preprocessing
g++ -E helloworld.cpp > helloworld.txt
#include "misc/TaskTimer.hpp"
{
timer.start();
// CODE here
if (!mpi_rank())
cout << "# time = " << timer.elapsed() << endl;
@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
@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 / 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 / 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; }