Skip to content

Instantly share code, notes, and snippets.

View NoMan2000's full-sized avatar

Michael Ryan Soileau NoMan2000

  • Surge Forward
  • Reno, Nevada
View GitHub Profile
@NoMan2000
NoMan2000 / mysqldb.sql
Last active August 29, 2015 14:18
MySQL Development Statements.
SELECT * FROM city LIMIT 10;
SELECT 1;
SELECT 'Some Thing' as SexyThing;
SELECT 2+2 as adding;
SELECT 2+2, 'foo', 5*5, CONCAT('Mr ', 'Boombastic') as MrMan;
SELECT @a, @b, @c;
@NoMan2000
NoMan2000 / mount.sh
Created April 5, 2015 20:44
Check mounts
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
@NoMan2000
NoMan2000 / files.sh
Last active April 14, 2025 17:54
Change Permissions on Unix to 775 for directories and 664 for files
sudo find . -type f | xargs chmod -v 664
sudo find . -type d | xargs chmod -v 775
sudo chmod -R u=rwX,g=rwX,o=rX .
sudo chown -R ubuntu:www-data .
@NoMan2000
NoMan2000 / emailAddressRegex.js
Last active August 29, 2015 14:16
EmailAddressRegex
emailAddressPattern: /^[a-zA-Z0-9'._%+\-]+@[a-zA-Z0-9\-][a-zA-Z0-9.\-]*\.[a-zA-Z]{2,63}$/;
@NoMan2000
NoMan2000 / extends.js
Last active August 29, 2015 14:12
Function extender for JavaScript
Function.prototype.method = function(name, func) {
this.prototype[name] = func;
return this;
}
Function.prototype.extends = function(superclass) {
this.prototype = Object.create(superclass.prototype);
this.prototype.constructor = this;
}
@NoMan2000
NoMan2000 / Timeout.js
Created December 18, 2014 21:10
Timeout Object to prevent duplicate setTimeout calls
TimeHolder = {};
TimeHolder.delay = 2000;
TimeHolder.value = null;
TimeHolder.cancel = function cancel() {
clearTimeout(TimeHolder.value);
TimeHolder.value = null;
};
window.TimeHolder = TimeHolder;
if (TimeHolder.value === null) {
// Attempting to set a timeout call so that the class does not immediately trigger again.
var isValidJSON = function isValidJSON(data) {
if (String(data).length === 0) {
return false;
}
try {
var o = JSON.parse(data);
// if o checks for null, empty, or undefined.
// typeof object and not instanceof array makes sure it's an object and not an array.
// the error checker does the rest.
if (o && typeof o === "object" && !(o instanceof Array)) {
@NoMan2000
NoMan2000 / ArrayEmpty.js
Created November 14, 2014 19:35
Empty an array
Array.prototype.empty = function empty() {
while (this.length > 0) {
this.pop();
}
};
@NoMan2000
NoMan2000 / randomAlias.sh
Created September 28, 2014 21:03
Random bash aliasing
alias random='echo "$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12 | xargs echo)"'
@NoMan2000
NoMan2000 / Regex.pl
Created September 6, 2014 21:29
PCRE to match anything not a negative or positive number followed by digits
[^\d]+(?<!^[+-])