Skip to content

Instantly share code, notes, and snippets.

@mcescalante
mcescalante / gist:6803535
Created October 3, 2013 02:02
FreeNAS 8.2 rsync remote to local, non-standard port
#Sync all verbose with progress from remote server to local. This is intended as a one shot sync, not to be scheduled as a cron job. Written for use with FreeNAS 8.2 as non-standard ports take a bit of work to get working.
#XXXX after the p flag should be replaced with the port.
rsync -avPz -e "ssh -pXXXX $portNumber" user@remote:/path/to/files/ /local/path/
@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 / 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 / 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 / netstatmav.sh
Created June 10, 2014 16:28
Mavericks netstat -tlpn equivalent
sudo lsof -i -n -P | grep TCP
@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 / 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 / gist:10916956
Created April 16, 2014 18:24
Count lines of code in directory
find . -name '*.py' | xargs wc -l
@mcescalante
mcescalante / gist:10152645
Created April 8, 2014 16:33
FreeNAS kernel/driver commands
#In order to output all kernel devices, just run this
dmesg
#Alternate
camcontrol devlist
@mcescalante
mcescalante / gist:10097027
Last active August 29, 2015 13:58
pip Xcode clang 3.4 workaround
#Add this line before the "pip install..." command to bypass annoying errors on build with clang 3.4 Xcode tools
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"