Skip to content

Instantly share code, notes, and snippets.

View leogdion's full-sized avatar

leogdion leogdion

View GitHub Profile
node_modules
config.json
examples
examples.zip
#!/bin/bash
# Generate a random password
# $1 = number of characters; defaults to 32
# $2 = include special characters; 1 = yes, 0 = no; defaults to 1
function randpass() {
[ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}
echo
}
@leogdion
leogdion / php_cgi.sh
Created June 13, 2013 18:27
php script for
#!/bin/sh
#
# php-cgi - php-fastcgi swaping via spawn-fcgi
#
# chkconfig: - 85 15
# description: Run php-cgi as app server
# processname: php-cgi
# config: /etc/sysconfig/phpfastcgi (defaults RH style)
# pidfile: /var/run/php_cgi.pid
# Note: See how to use this script :
#!/bin/sh
ipaddress=`ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d:`
sed -e "s/^/${ipaddress} /" /usr/local/etc/hostnames
#!/bin/bash
function var() {
eval $2=`grep -Po "define\('$3',\s*'(\K[^']+)" $1 | head -n 1`
}
wp_config=$1
base_dir=$2
date_prefix=$(date -u +"%y%m%d%H")
alias sudoscreen='sudo PATH=$PATH screen'
cd ~
mkdir -p ~/.nave
mkdir -p ~/.scripts
mkdir -p ~/.installation
# Download scripts
cd ~/.scripts
curl -o backup-wpdb.sh https://gist.github.com/leogdion/8343509/raw
curl -o hostnames.sh https://gist.github.com/leogdion/8226872/raw
curl -o /etc/profile.d/sudoscreen.sh https://gist.github.com/leogdion/8442367/raw
# Download nave script

Keybase proof

I hereby claim:

  • I am leogdion on github.
  • I am leogdion (https://keybase.io/leogdion) on keybase.
  • I have a public key whose fingerprint is 85D8 5DAF 9102 74F8 0106 1C1E 7BE6 BF0D 1B27 893A

To claim this, I am signing this object:

@leogdion
leogdion / index.js
Created September 8, 2016 00:02
Finding The Earliest Date Available Based On Time Slots
console.log("hello world");
@leogdion
leogdion / serialNumber.swift
Created October 18, 2016 14:25
How To Get A Serial Number on macOS in Swift
var serialNumber: String? {
let platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice") )
guard platformExpert > 0 else {
return nil
}
guard let serialNumber = (IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformSerialNumberKey as CFString, kCFAllocatorDefault, 0).takeUnretainedValue() as? String)?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) else {
return nil
}