Skip to content

Instantly share code, notes, and snippets.

View fccoelho's full-sized avatar
🏠
Working from home

Flávio Codeço Coelho fccoelho

🏠
Working from home
View GitHub Profile
@maxcollombin
maxcollombin / wfs-geopandas.py
Created August 21, 2023 08:08
Script to read data from an OGC WFS service to GeoPandas
# -*- coding: utf-8 -*-
"""
wfs-geopandas.py
Script to read data from an OGC WFS service to GeoPandas
Author: [Maxime Collombin]
Reference: https://gis.stackexchange.com/questions/299567/reading-data-to-geopandas-using-wfs
Date: [14/08/2023]
"""
import geopandas as gpd
@mjdietzx
mjdietzx / residual_block.py
Last active September 18, 2021 11:21
Clean and simple Keras implementation of the residual block (non-bottleneck) accompanying Deep Residual Learning: https://blog.waya.ai/deep-residual-learning-9610bb62c355.
from keras import layers
def residual_block(y, nb_channels, _strides=(1, 1), _project_shortcut=False):
shortcut = y
# down-sampling is performed with a stride of 2
y = layers.Conv2D(nb_channels, kernel_size=(3, 3), strides=_strides, padding='same')(y)
y = layers.BatchNormalization()(y)
y = layers.LeakyReLU()(y)
@denten
denten / gist:4886b62c7292a776fa8e
Created May 20, 2014 03:19
lazy mongodb corpus
import pymongo
from nltk.data import LazyLoader
from nltk.tokenize import TreebankWordTokenizer
from nltk.util import AbstractLazySequence, LazyMap, LazyConcatenation
class MongoDBLazySequence(AbstractLazySequence):
def __init__(self, host='localhost', port=27017, db='test', collection='corpus', field='text'):
self.conn = pymongo.Connection(host, port)
self.collection = self.conn[db][collection]
self.field = field
@turicas
turicas / virtualenv_execute.py
Created June 8, 2012 19:23
Execute Python code in a virtualenv, return its stdout and stderr
#!/usr/bin/env python
# coding: utf-8
import os
import shlex
from subprocess import Popen, PIPE
def execute_in_virtualenv(virtualenv_name, commands):
'''Execute Python code in a virtualenv, return its stdout and stderr.'''
@turicas
turicas / monitoring.py
Created June 7, 2012 19:46
Monitoring information about host/OS and some processes (used at PyPLN's broker)
#!/usr/bin/env python
# coding: utf-8
import socket
from time import time
import psutil
def get_outgoing_ip((host, port)):
"""Connect to remote host/port, return local IP used by OS"""
import sys
import shlex
from subprocess import Popen, PIPE
from IPython.utils.py3compat import unicode_to_str
def shebang(line, cell):
cmd = shlex.split(unicode_to_str(line))
p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
out,err = p.communicate(cell)
if err:
import sys
import time
from subprocess import Popen, PIPE
def magic_pypy(line, cell):
cmd = ['pypy', '-c', cell]
tic = time.time()
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
p.wait()
toc = time.time()
@pjotrp
pjotrp / gist:2282903
Created April 2, 2012 11:44
Using BLAS/LAPACK/LINPACK from the D language
/**
The following example uses this function to calculate the matrix-vector product using
a blas/lapack routine:
/ 3 1 3 \ / -1 \
| 1 5 9 | * | -1 |.
\ 2 6 5 / \ 1 /
D2 version based on the C version at http://www.seehuhn.de/pages/linear
@fccoelho
fccoelho / README
Created September 21, 2011 17:26 — forked from uiltondutra/gist:231960
MongoDB init script for a sharding node.
To install this init script, you should save mongodb to /etc/init.d/ and mongosharding.conf to /etc/
then run the following commands as root or with sudo:
chmod 755 /etc/init.d/mongodb
chown root:root /etc/init.d mongodb
update-rc.d mongodb defaults
This installation procedure was tested on UBUNTU 11.10
@onedesign
onedesign / mongodb-upstart.sh
Created January 4, 2011 21:29
Ubuntu upstart script for MongoDB with automatic repair
# Ubuntu upstart file at /etc/init/mongodb.conf
pre-start script
mkdir -p /var/lib/mongodb/
mkdir -p /var/log/mongodb/
end script
start on runlevel [2345]
stop on runlevel [06]