Skip to content

Instantly share code, notes, and snippets.

View jonasbjork's full-sized avatar
🇸🇪
Everyday I am shuffelin'

Jonas Björk jonasbjork

🇸🇪
Everyday I am shuffelin'
View GitHub Profile
<?php
// Randomize database server connection
$server = array(
'sql1',
'sql2',
'sql3',
);
$rand = rand(0,count($server)-1);
@jonasbjork
jonasbjork / dns.php
Created August 15, 2012 14:42
PHP code to interact with DNS
<?php
$domains = array(
'jonasbjork.net',
'google.com',
'idg.se',
'facebook.com',
'aftonbladet.se' );
foreach ($domains as $d) {
@jonasbjork
jonasbjork / datum.php
Created August 15, 2012 15:07
Test with dates in PHP
<?php
date_default_timezone_set('Europe/Stockholm');
// sunday = 0;
$day = date("w");
print $day;
if ($day == 1) {
$d = strtotime(date("Y-m-d", time()));
@jonasbjork
jonasbjork / StrArray.class.php
Created October 26, 2012 09:38
Convert string delimited with = to an array
<?php
class StrArray {
private $arr = array();
/**
* Adds string "a=b" to array with a as key and b as value
*
* @author Jonas Björk <jonas.bjork@me.com>
@jonasbjork
jonasbjork / db.php
Created December 4, 2012 09:50
PHP code that parses wp-config.php and returns mysql command for connection to the database.
<?php
/**
* Get database connection string from a wp-config.php file.
*
* Usage: php db.php /var/www/wp-config.php
*
* Output: mysql -h DB_HOST -u DB_USER -pDB_PASSWORD DB_NAME
*
* @author Jonas Björk <jonas.bjork@me.com>
* @date 2012-12-04
@jonasbjork
jonasbjork / deskhide.sh
Created January 18, 2013 13:13
A Bash script to hide/show icons on Mac OSX Desktop.
#!/bin/bash
#
# Deskhide - hides ALL icons on your desktop
# (C)2013 Jonas Björk <jonas.bjork@me.com>
# Licensed under GNU GPLv2+
#
# You must make this script executable: "chmod +x deskhide"
# Then start Terminal.App, iTerm.App or another terminal
# and run this program with:
#
@jonasbjork
jonasbjork / sjombord.sh
Created April 21, 2013 16:38
Script for login to SJ Ombord WLAN on SJ's trains.
#!/bin/bash
#Set these variables!
PRIOCARD=""; # Your SJ Prio card number (Black)
CARDPASS=""; # Your SJ Prio card code (4 digits)
#There is normally no need to modify anything below...
URL="https://www.ombord.info/hotspot/hotspot.cgi";
AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19";
@jonasbjork
jonasbjork / vbox-extensions.sh
Created April 30, 2014 08:42
Download VirtualBox Extension Pack for installed VirtualBox version
#!/bin/bash
VERSION=$(VBoxManage --version)
MAJOR=$(echo ${VERSION} | awk -F'r' '{print $1}')
MINOR=$(echo ${VERSION} | awk -F'r' '{print $2}')
DOWNLOAD="http://download.virtualbox.org/virtualbox/${MAJOR}/Oracle_VM_VirtualBox_Extension_Pack-${MAJOR}-${MINOR}.vbox-extpack"
wget $DOWNLOAD
@jonasbjork
jonasbjork / nodeinstall.sh
Created April 30, 2014 12:33
Install node on macosx
#!/bin/bash
# Install nvm from https://github.com/creationix/nvm
curl https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh
# Read nvm settings
source ~/.profile
# Install NodeJS version
nvm install 0.10.26
@jonasbjork
jonasbjork / omnifocus.scpt
Created May 7, 2014 14:58
Testing Omnifocus and Apple Script
tell application "OmniFocus"
tell front document to make new inbox task with properties {name:"Testing Apple Script task", note:"There is no note."}
end tell