Skip to content

Instantly share code, notes, and snippets.

Flávio Juvenal da Silva Junior fjsj

Block or report user

Report or block fjsj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
simonw /
Last active Jun 19, 2019
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using and

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
pjbull /
Last active Jun 26, 2019
Sparse Interaction Terms for scikit-learn
from sklearn.base import BaseEstimator, TransformerMixin
from scipy import sparse
from itertools import combinations
class SparseInteractions(BaseEstimator, TransformerMixin):
def __init__(self, degree=2, feature_name_separator="_"): = degree
self.feature_name_separator = feature_name_separator
GitRay /
Last active May 24, 2019 — forked from mrocklin/
Serialization benchmark
# This has been edited to work with python3. Some of the tested combinations will not work in python2.
import pandas as pd
df = pd.DataFrame({'text': [str(i % 1000) for i in range(1000000)],
'numbers': range(1000000)})
import pickle
# Python 3 has no cPickle
#import cPickle
import json
from functools import partial
superdaigo /
Created Apr 22, 2016
Celery rate_limit test script
# Test celery's rate_limit
Tested version of python
$ python --version
Python 2.7.11
## Requirements
$ pip install celery==3.1.23
$ pip install SQLAlchemy==1.0.12
kristopolous / hn_seach.js
Last active Jul 1, 2019
hn job query search
View hn_seach.js
function query() {
// HN is done with very unsemantic classes.
job_list ='.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')),
query_list =,
shown = 0, total = job_list.length;
// Traverses up the dom stack trying to find a match of a specific class
function up_to(node, klass) {
if (node.classList.contains(klass)) {
nealtodd / gist:a8f87b0d95e73eb482c5
Created Jun 10, 2015
Django management command to detect missing migration files.
View gist:a8f87b0d95e73eb482c5
import sys
from django.apps import apps
from django.conf import settings
from import BaseCommand
from django.db import connections
from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.state import ProjectState
from django.db.utils import OperationalError
itamarhaber / 00_copy_key.lua
Last active Feb 1, 2019
The fastest, type-agnostic way to copy a Redis key, as discussed in
View 00_copy_key.lua
-- @desc: The fastest, type-agnostic way to copy a Redis key
-- @usage: redis-cli --eval copy_key.lua <source> <dest> , [NX]
local s = KEYS[1]
local d = KEYS[2]
if"EXISTS", d) == 1 then
if type(ARGV[1]) == "string" and ARGV[1]:upper() == "NX" then
return nil
econandrew /
Last active Apr 13, 2019
Instructions for installing an OpenStreetMap Nominatim geocoder instance on Amazon Linux / EC2 (Dec 2014)

Installing Nominatim on Amazon Linux / EC2

  1. Introduction

The official instructions for installing Nominatim are complete, but brief in places, and several steps must be changed in the Amazon Linux environment (which is roughly CentOS / Redhat). The steps below are rough record of what I did to get it working, but I didn't keep perfect track so you shouldn't rely on them as a shell script. Just follow each step, make sure it worked, and hopefully you'll need to adapt very little (version numbers, for one thing). (I also skip in and out of root, but you can be more careful if you like.)

  1. Setting up the EC2 instance

jacoor /
Created Mar 5, 2014
additional data for listApiView for
class TransactionsList(ListAPIView):
List all transactions for currently logged in user, paginated by 25
page -- page number
ordering -- yoddle_amount, created, yoddle_description, reverse order ie. -yoddle_amount
model = Transaction
dogoku / A
Last active Dec 4, 2018 — forked from tiffon/Find Results.hidden-tmLanguage
Search result syntax highlighting for Sublime Text
View A

#ST2/3 Search result syntax highlighting

##Introduction and disclaimer

This is gist contains an edited Find Results.hidden-tmLanguage which adds syntax highlighting to your ST search results. As far as I know, there is no plugin that does this and for that reason it needs to be done via config.

DISCLAIMER: Use this HACK at your risk and backup the original files you are about to mess with.

##Usage Guide for Sublime Text 2

You can’t perform that action at this time.