Skip to content

Instantly share code, notes, and snippets.

View krvajal's full-sized avatar
:electron:
What's happening?

Miguel Carvajal krvajal

:electron:
What's happening?
  • @wearesinch
  • Antwerpen, Belgium
View GitHub Profile
.loading {
background: url(https://a-v2.sndcdn.com/assets/images/loader-db80c5.gif) no-repeat center center;
clear: both;
text-align: center;
height: 40px;
width: 100%;
}
@krvajal
krvajal / AndroidContext.java
Created April 10, 2016 16:04
Simple singleton for getting the Android context available anywhere
public final class AndroidContext {
private static Context context;
public static Context getContext() {
return context;
}
public static void setContext(Context context) {
AndroidContext.context = context;
@krvajal
krvajal / timer.py
Created June 1, 2016 15:11
timer from python
from timeit import default_timer as timer
start = timer()
# long operation here
duration = timer() - start
print "Duration", duration
@krvajal
krvajal / error.js
Created June 4, 2016 23:37
Report js errors to google analytics
window.onerror = (msg, file, line, column, error=null)=>{
try{
if(error){ // error param not supported everywhere
msg = error.stack;
}
ga('send','event','error', `${file}:{line}`, msg)
}catch(e){
// no-op
#!python
def savitzky_golay(y, window_size, order, deriv=0, rate=1):
r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
The Savitzky-Golay filter removes high frequency noise from data.
It has the advantage of preserving the original shape and
features of the signal better than other types of filtering
approaches, such as moving averages techniques.
Parameters
----------
y : array_like, shape (N,)
/*
problema de la entrevista que mencioné en el último podcast:
https://soundcloud.com/sin-humo/entrevistas-de-trabajo-y-111mil
la idea es crear la función 'deferred', que permita un comportamiento
similar a lo que serían promises de javascript.
el deferred puede 'resolverse' con un valor cualquiera, o con otro 'deferred'.
en el segundo caso, el próximo `then` debería "esperar" también a este.
# Install the Python Requests library:
# `pip install requests`
import requests
def send_request():
# My API
# GET https://api.invertironline.com/api/micuenta/estadocuenta
import os
def get_filepaths(directory):
"""
This function will generate the file names in a directory
tree by walking the tree either top-down or bottom-up. For each
directory in the tree rooted at directory top (including top itself),
it yields a 3-tuple (dirpath, dirnames, filenames).
"""
file_paths = [] # List which will store all of the full filepaths.
#include <string>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <array>
using namespace std;
using namespace boost;
@krvajal
krvajal / index.html
Last active January 4, 2018 23:44 — forked from anonymous/index.html
Redux store implementation
<script src="https://fb.me/react-with-addons-15.1.0.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://fb.me/react-15.1.0.js"></script>