Skip to content

Instantly share code, notes, and snippets.

@mcescalante
mcescalante / findstuff.sh
Created May 27, 2014 13:43
Find large things with Linux
#ncdu is another utility that might be useful (and it's interactive)
#Find 10 largest files
find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
#Find 10 largest directories (change f to d)
find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
@mcescalante
mcescalante / xorprng.c
Last active August 29, 2015 14:02
XORshift PRNG
//PRNG using XOR shifting for performance reasons
func GenRand(gen *uint32) int {
*gen += *gen
*gen ^= 1
if int32(*gen) < 0 {
*gen ^= 0x88888eef
}
a := *gen
return int(a)
}
@mcescalante
mcescalante / netstatmav.sh
Created June 10, 2014 16:28
Mavericks netstat -tlpn equivalent
sudo lsof -i -n -P | grep TCP
@mcescalante
mcescalante / flushcache.sh
Created August 5, 2014 21:51
Flush DNS Cache OSX
#sometimes helpful when reconfiguring /etc/hosts to point locally and browsers are using a cached copy
dscacheutil -flushcache
@mcescalante
mcescalante / formMacro.html
Created January 29, 2015 17:36
jinja macro for rendering form field errors
{% macro with_errors(field) %}
<div class="form_field">
{% if field.errors %}
{% set css_class = 'has_error ' + kwargs.pop('class', '') %}
{{ field(class=css_class, **kwargs) }}
<ul class="errors">{% for error in field.errors %}<li>{{ error|e }}</li>{% endfor %}</ul>
{% else %}
{{ field(**kwargs) }}
{% endif %}
</div>
@mcescalante
mcescalante / lolcomment.css
Created February 24, 2015 00:43
funny css file comment
/*
TODO: Rewrite this from scratch
TODO: Use this code as an example of how not to code:
- no comments
- nondescript var names
- inline html generation
- inline css generation
- not keeping a reference to DOM elements
- browser checks
- code quadruplication (I've never actually seen that before)
@mcescalante
mcescalante / cx_oracle_install_instructions.md
Last active November 13, 2017 20:46
cx_Oracle installation instructions/notes for macOS or Linux

cx_Oracle Installation Instructions

I've had to put cx_Oracle (python Oracle database connector) on macOS and Linux, and both processes were similar but poorly documented on Oracle's website.

These instructions were written and tested using the client 12.1. The instructions for any 12.x are the same, but you may need to change 12_1 to 12_2 in commands if you are using version 12.2, etc.

Instructions

  1. Download 64 bit (easy to download 32 by mistake) basic + sdk instantclient from Oracle website (Note: you need an account, I used throwaway email)
@mcescalante
mcescalante / instructions.md
Last active July 25, 2023 14:07
Run a Flask application with gunicorn and nginx

This guide assumes:

  • You have a VPS (something like DigitalOcean, Linode, etc.)
  • You have a Flask application and a basic understanding of command line instructions
  • You've got nginx installed and know where your configuration files are

Instructions

  1. First, you should install gunicorn on your box or virtualenv with pip:
@mcescalante
mcescalante / .tmux.conf
Created November 8, 2016 21:07
My OSX/macOS tmux configuration, tested on 10.11.x
#allow mousing
set -g mouse-utf8 on
set -g mouse on
# Return pre-2.1 mousing behaviour
# https://github.com/tmux/tmux/issues/145
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# Use vim keybindings in copy mode
@mcescalante
mcescalante / keybase.md
Created October 13, 2017 15:06
keybase proof

Keybase proof

I hereby claim:

  • I am mcescalante on github.
  • I am mcescalante (https://keybase.io/mcescalante) on keybase.
  • I have a public key whose fingerprint is 59F6 7311 E003 5EBE 4A0C D3C3 238D 8F30 A94E F114

To claim this, I am signing this object: