Skip to content

Instantly share code, notes, and snippets.

Daniel Sposito dsposito

Block or report user

Report or block dsposito

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
@ipmb
ipmb / settings.py
Last active Sep 10, 2019
Django logging example
View settings.py
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
anonymous
anonymous / illuminate-support-loc.txt
Created Apr 21, 2016
illuminate/support LOC
View illuminate-support-loc.txt
phploc 3.0.0 by Sebastian Bergmann.
Directories 3
Files 51
Size
Lines of Code (LOC) 5756
Comment Lines of Code (CLOC) 2422 (42.08%)
Non-Comment Lines of Code (NCLOC) 3334 (57.92%)
Logical Lines of Code (LLOC) 790 (13.72%)
@miohtama
miohtama / secure_uuid.py
Created Jul 30, 2015
Generate full 128-bit randomness UUID version 4 on Python, break spefification to stir extra 6 bits of randomness
View secure_uuid.py
def secure_uuid():
"""Create a non-conforming 128-bit random version 4 UUID.
Random UUID is a RFC 4122 compliant UUID version 4 128-bit number. By default 6 fixed bits, 4 bits for version and 2 bits reserved for other purposes, are fixed. This function behaves like Python's ` uuid4()`` but also randomizes the remaining six bits, generating up to 128 bit randomness.
This function also sources all bytes from `os.urandom()` to guarantee the randomness and security and does not rely operating system libraries.
Using ``secure_uuid()`` poses a risk that generated UUIDs are not accepted when communicating with third party system. However, they are observed to be good for URLs and to be stored in PostgreSQL.
More information
@waylonflinn
waylonflinn / install-python-data-science.sh
Last active Dec 4, 2016
Install Data Science and NLP libraries for python3 in a virtualenv (Numpy, Scipy, Matplotlib, Pandas, Gensim, OpenBLAS and PyTables)
View install-python-data-science.sh
#!/usr/bin/env bash
## create an ubuntu 14.04 hvm instance, then from your home directory:
# 1. download this script
# wget https://gist.githubusercontent.com/waylonflinn/506f563573600d944923/raw/install-python-data-science.sh
# 2. make it executable
# chmod a+x install-python-data-science.sh
@redox
redox / base.html.haml
Last active Dec 6, 2018
Algolia extends HipChat to customer support
View base.html.haml
#chat-box.ubuntu.hidden-xs
.closed
.pull-right
= link_to_function content_tag(:i, nil, class: 'glyphicon glyphicon-chevron-up').html_safe, 'chat.show()'
.m-l-small
= link_to_function 'Chat with us', 'chat.show()'
.opened{style: 'display: none'}
.header
.pull-right
= link_to_function content_tag(:i, nil, class: 'glyphicon glyphicon-plus-sign').html_safe, 'chat.maximize()', class: 'maximize', style: 'display: none'
@lttlrck
lttlrck / gist:9628955
Created Mar 18, 2014
rename git branch locally and remotely
View gist:9628955
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
View summary_tool.py
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@nikic
nikic / objects_arrays.md
Last active Aug 29, 2019
Post explaining why objects often use less memory than arrays (in PHP)
View objects_arrays.md

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@grawity
grawity / GitHub protocol comparison.md
Last active Aug 29, 2019
A comparison of protocols offered by GitHub (for #git on Freenode).
View GitHub protocol comparison.md

Primary differences between SSH and HTTPS. This post is specifically about accessing Git repositories on GitHub.

Protocols to choose from when cloning:

plain Git, aka git://github.com/

  • Does not add security beyond what Git itself provides. The server is not verified.

    If you clone a repository over git://, you should check if the latest commit's hash is correct.

@tkdave
tkdave / gist:4150916
Created Nov 26, 2012
Installing OpenCV python libs on mac to work with virtualenv and brew
View gist:4150916
# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
brew update
You can’t perform that action at this time.