I hereby claim:
- I am devm33 on github.
- I am devm33 (https://keybase.io/devm33) on keybase.
- I have a public key whose fingerprint is FB74 6ADC B899 CB2B E4C3 A712 E385 2F90 A94F A38B
To claim this, I am signing this object:
| function rand_string(n) { | |
| if (n <= 0) { | |
| return ''; | |
| } | |
| var rs = ''; | |
| try { | |
| rs = crypto.randomBytes(Math.ceil(n/2)).toString('hex').slice(0,n); | |
| /* note: could do this non-blocking, but still might fail */ | |
| } | |
| catch(ex) { |
| var zeroPad = function(str) { | |
| return ('0'+ str).slice(-2); | |
| }; | |
| var dateLocal = function() { | |
| var d = new Date(); | |
| var s = d.getFullYear() + '-'; | |
| s += zeroPad(d.getMonth()) + '-'; | |
| s += zeroPad(d.getDate()) + 'T'; | |
| s += zeroPad(d.getHours()) + ':'; | |
| s += zeroPad(d.getMinutes()) + ':'; |
| #!/usr/bin/env bash | |
| # Script to backup the home directory to an external hardrive mounted at /media/backup | |
| # Uses rsync, dpkg, and mail (for error logging) | |
| SRC='/home/*' | |
| DEST='/media/backup' | |
| RSYNC_OPTS='-haAXuv --delete' | |
| EXCLUDE='*/.cache/* */.thumbnails/* */.config/google-* lost+found .gvfs' | |
| EXCLUDE="$(echo $EXCLUDE | sed 's/\(\S\+\)/ --exclude \1/g')" |
| # Display summarized (s) human-readable (both h) sizes of sub-directories sorted descending | |
| # - remove / to include files in that folder | |
| # - remove r to sort ascending by size | |
| du -sh */ | sort -hr | |
| # Remove broken symlinks (leverages zsh) | |
| rm -- *(-@D) |
| /* Set up a local testing server to serve a static folder */ | |
| var express = require("express"); | |
| express().use(express.static(__dirname)).listen(5000, function(){ | |
| console.log('http://0.0.0.0:5000 listening...'); | |
| }); |
| /* | |
| * robotMaze.js | |
| * | |
| * The blue key is inside a labyrinth, and extracting | |
| * it will not be easy. | |
| * | |
| * It's a good thing that you're a AI expert, or | |
| * we would have to leave empty-handed. | |
| */ |
| function calc(expr) { | |
| return expr.split(/\s+/).reduce(function(stack, current){ | |
| var a, b, c; | |
| if(/[+\-*\/]/.test(current)){ | |
| b = stack.pop(); | |
| a = stack.pop(); | |
| switch(current) { | |
| case '+': c = a + b; break; | |
| case '-': c = a - b; break; | |
| case '*': c = a * b; break; |
| def sieve(n): | |
| x = [1]*n | |
| x[1] = 0 | |
| for i in range(2, n/2): | |
| j = 2*i | |
| while j<n: | |
| x[j] = 0 | |
| j = j+i | |
| return x |
| angular.module('dynAttrs', []) | |
| .directive('dynAttrs', () => { | |
| return { | |
| link: function(scope, element, attrs) { | |
| scope.$watch(attrs.dynAttrs, (dynAttrs) => { | |
| _.each(dynAttrs, (val, attr) => { | |
| if(val) { | |
| element.attr(attr, val); | |
| } else { | |
| element.removeAttr(attr); |
I hereby claim:
To claim this, I am signing this object: