Skip to content

Instantly share code, notes, and snippets.

View logc's full-sized avatar

Luis Osa logc

View GitHub Profile
@logc
logc / main.cpp
Last active August 29, 2015 13:58
kNN with Boost::Geometry
#include <functional>
#include <iostream>
#include <random>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/index/rtree.hpp>
namespace bg = boost::geometry;
@logc
logc / convert.py
Last active November 16, 2015 11:49
"""
Convert: filename of Gmail contacts -> XLSX file
Converts the contents of a filename where exported Gmail contacts can be found
into an XLSX spreadsheet where only the relevant information of the contacts is
found.
"""
import argparse
import codecs
import os
@logc
logc / gdb-session.fish
Created May 13, 2016 19:03
How to add a new structure to a GDB session
❯ gcc -g minimal.c -o minimal
❯ sudo gdb minimal
Password:
(gdb) break main
Breakpoint 1 at 0x100000f90: file minimal.c, line 3.
(gdb) run
Starting program: /private/tmp/c-repl/minimal
def parse_command_line():
"""Defines and parses command line arguments"""
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action='count', default=0)
return parser.parse_args()
def configure_logging(args):
"""Configures logging as specified by the author and the user"""
levels = [logging.WARNING, logging.INFO, logging.DEBUG]
@logc
logc / texdeps.sh
Created January 24, 2017 11:24
Installs TexLive dependencies in order to build "HPC book" by V. Eijkhout, available at https://bitbucket.org/VictorEijkhout/hpc-book-and-course
#! /usr/bin/env sh
wget http://mirrors.ctan.org/macros/latex/contrib/undertilde.zip
unzip undertilde.zip
cd undertilde
latex undertilde.ins
latex undertilde.dtx
makeindex undertilde.idx
mkdir -p /Users/$USER/Library/texmf/tex/latex/undertilde/
mv undertilde.sty /Users/$USER/Library/texmf/tex/latex/undertilde/
sudo tlmgr install comment arydshln wrapfig multirow dirtree algorithm2e \
@logc
logc / pypkg.sh
Last active March 8, 2017 09:48
Python packages with Sphinx & Github pages
#!/usr/bin/env bash
pkg_name=$1
pkg_root=$PWD/${pkg_name}
doc_root=${pkg_root}/docs/_build/html
hostname=`hostname`
year=`date '+%Y'`
version='0.1.0'
#lang typed/racket/base
(require racket/future)
(require racket/performance-hint)
(require racket/cmdline)
(require (only-in racket/unsafe/ops
unsafe-car
unsafe-cdr))
(require (rename-in racket/unsafe/ops
[unsafe-fx+ +]
[unsafe-fx- -]
@logc
logc / calendar_reminder.py
Last active June 8, 2017 10:00
Script to retrieve events from a Google Calendar, check if any of them happens tomorrow earlier than 11AM, and set a reminder in Reminders.app for today at 9PM
#!/usr/bin/env python
"""
Script to retrieve events from a Google Calendar, check if any of them happens
tomorrow earlier than 11AM, and set a reminder in Reminders.app for today at
9PM
"""
import argparse
import datetime
import sys
import os
@logc
logc / max_column_sum_by_key.rkt
Last active September 17, 2017 20:31
Faster Command Line Tools in Racket
#lang typed/racket/base
(require racket/cmdline
racket/string)
(: parse (-> String Integer Integer (Values String Integer)))
(define (parse line key-field-pos val-field-pos)
(let ([fields (string-split line "\t")])
(values (list-ref fields key-field-pos)
(assert (string->number (list-ref fields val-field-pos))
@logc
logc / mkscons.fish
Created November 28, 2017 20:46
Create a basic SCons project as Fish function
function mkscons --argument proj
mkdir -p $proj/include/core
mkdir -p $proj/src/core
mkdir -p $proj/tests/core
###############################################################################
# BUILD SCONSCRIPT
printf "\
env = Environment(CPPPATH=['include'])
env.Library(target='$proj', source=Glob('src/core/*.c'))
env.Program(target='$proj', source=Glob('src/*.c'),