For excessively paranoid client authentication.
Updated Apr 5 2019:
because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.
some other notes:
#!/bin/bash | |
# Monitors for signals from gnome-screensaver and activates or deactivates | |
# bitcoin miners accordingly. | |
# Params to the mining programs are all hardcoded. Change 'em manually. Leave the "&"s. | |
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'" | \ | |
while read line; do | |
case "$line" in |
machine github.com | |
login technoweenie | |
password SECRET | |
machine api.github.com | |
login technoweenie | |
password SECRET |
namespace YourNamespace | |
{ | |
using System; | |
using System.Windows.Forms; | |
static class Program | |
{ | |
/// <summary> | |
/// | |
/// </summary> |
#!/usr/bin/env python | |
import os.path | |
import os | |
from urllib import urlretrieve | |
import imp | |
print "starting up, hang with me..." | |
urlretrieve('https://raw.github.com/facebook/fbconsole/master/src/fbconsole.py', |
#Mobile Device Detection via User Agent RegEx
Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.
I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.
The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".
Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(
if (!String.format) | |
String.format = function String_format(value) { | |
if (arguments.length === 0) | |
return null; | |
for (var i = 1, l = arguments.length; i !== l; ++i) | |
value = value.replace(RegExp('\\{' + (i - 1) + '\\}','gm'), arguments[i]); | |
return value; | |
}; |
if (!String.toRegExp) | |
String.toRegExp = function String_toRegExp(pattern, flags) { | |
return new RegExp(pattern.replace(/[\[\]\\{}()+*?.$^|]/g, function (match) { return '\\' + match; }), flags); | |
}; |
// example function where arguments 2 and 3 are optional | |
function example( err, optionalA, optionalB, callback ) { | |
// retrieve arguments as array | |
var args = []; | |
for (var i = 0; i < arguments.length; i++) { | |
args.push(arguments[i]); | |
} | |
// first argument is the error object |
#!/bin/bash | |
# bash generate random alphanumeric string | |
# | |
# bash generate random 32 character alphanumeric string (upper and lowercase) and | |
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
# bash generate random 32 character alphanumeric string (lowercase only) | |
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1 |