This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sometimes helpful when reconfiguring /etc/hosts to point locally and browsers are using a cached copy | |
dscacheutil -flushcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo lsof -i -n -P | grep TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name '*.py' | xargs wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In order to output all kernel devices, just run this | |
dmesg | |
#Alternate | |
camcontrol devlist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |