Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am felipeochoa on github.
  • I am fovc (https://keybase.io/fovc) on keybase.
  • I have a public key whose fingerprint is 6AEE AC8F 9B16 8B71 430C 16A6 EA6F 759A D809 0E61

To claim this, I am signing this object:

@felipeochoa
felipeochoa / react-context-as-dynamic-scope.jsx
Created November 13, 2016 09:15
Testing the overriding of parent context in children
/**
* Children can override parent's context, which means context is a form of dynamic scoping.
* Tested at: https://jsfiddle.net/79e293az/
* https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js
* https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js
*/
class Parent extends React.PureComponent {
getChildContext() {
/* When using a PureComponent, changes to the store will still trigger re-renders of the children
*
* Tested with https://jsfiddle.net/poqf128w/4/
*
* https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js
* https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js
* https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js
* https://cdnjs.cloudflare.com/ajax/libs/react-redux/4.4.5/react-redux.js
*/
const names = [
(defun fov-list-packages-and-versions ()
"Returns a list of all installed packages and their versions"
(mapcar
(lambda (pkg)
`(,pkg ,(package-desc-version
(cadr (assq pkg package-alist)))))
package-activated-list))
;; Unfortunately the following function does not work
;; if the specific versions you need aren't the latest
// ==UserScript==
// @name Check Netflix availability from you IMDB watchlist
// @namespace https://github.com/felipeochoa
// @description Filter your IMDB watchlist based on Netflix availability
// @author https://github.com/felipeochoa
// @include http://www.imdb.com/user/*/watchlist
// @include http://www.imdb.com/user/*/watchlist?*
// @include https://www.imdb.com/user/*/watchlist
// @include https://www.imdb.com/user/*/watchlist?*
// @version 1.0
@felipeochoa
felipeochoa / Postgres migration.md
Last active May 25, 2020 16:45
Migrating from sqlite to postgres

Postgres migration

I had to migrate what had started as a toy website and has now become a real website from running on sqlite to postgres today. I use a push-to-deploy setup, so the process was a bit tricky. I only needed like 10 minutes of downtime to do it, but had to make sure I had all the steps in order. For future record:

  1. Update requirements.txt to include psycopg2 and push the latest version of production branch so that any migrations get applied on the sqlite DB and psycopg2 is installed in the virtual env.
@felipeochoa
felipeochoa / xltoken.py
Last active August 29, 2015 14:23
A regular expression to tokenize excel formulae
import re
TOKEN_RE = re.compile(r"""
(?P<scientific>[1-9](?:\.[0-9]+)?[Ee][+-]?[1-9][0-9]*)|
(?P<string>"(?:[^"]*"")*[^"]*"(?!"))|
(?P<link>'(?:[^']*'')*[^']*'(?!'))|
(?P<sq_bracket>\[[^]]*\])|
(?P<error>\#NULL!|\#DIV/0!|\#VALUE!|\#REF!|\#NAME?|\#NUM!|\#N/A)|
(?P<wspace>\ +)|
(?P<operator>[-+*/^&=%]|>=|<=|<>|>(?!=)|<(?![=>]))|
#!/usr/bin/env python3
"""
Used to fetch cover art. Based heavily on obeythepenguin's
`Cover Fetcher' (http://coverfetcher.sourceforge.net/)
obeythepenguin AT users.sourceforge.net, but attempting to
provide a CLI interface.
"""
import argparse