Skip to content

Instantly share code, notes, and snippets.

@datacodesolutions
datacodesolutions / array_to_object
Created September 11, 2012 14:35
Array to Object
function array_to_object($array) {
$return = new stdClass();
foreach ($array as $k => $v) {
if (is_array($v)) {
$return->$k = $this->array_to_object($v);
}
else {
$return->$k = $v;
@datacodesolutions
datacodesolutions / sublime_text_console_commands
Created September 15, 2012 23:56
Sublime Text Console Commands
# docs location
http://www.sublimetext.com/docs/2/api_reference.html
# log all input
sublime.log_input(True)
# log all commands
sublime.log_commands(True)
@datacodesolutions
datacodesolutions / vmware_keyboard_shortcuts
Created September 15, 2012 23:57
VMware Keyboard Shortcuts
Ctrl+Alt - Transfers mouse and keyboard input from the virtual machine to the local machine. Switches from full screen mode to running the VMware Remote Console in a separate window
Ctrl+G - Transfers mouse and keyboard input from the local machine to the virtual machine
Ctrl+Alt+Insert - Sends a Ctrl+Alt+Del signal to the virtual machine
Ctrl+Alt+Enter - Switches between full screen mode and running VMware Remote Console in a separate window
F11 - switches to full-screen mode and back to normal mode
@datacodesolutions
datacodesolutions / clean_text
Created September 15, 2012 23:58
Clean Text
function ($str) {
$working = json_encode($str);
$working = preg_replace('/\\\u([0-9a-z]{4})/', '&#x$1;', $working);
return json_decode($working);
};
@datacodesolutions
datacodesolutions / linux_commands
Created September 15, 2012 23:59
Linux Commands
#find all directories with a certain name and delete them
find ./ -type d -name "CVS" -exec rm -rf {} \;
@datacodesolutions
datacodesolutions / sublime_keyboard_shortcuts_windows.json
Created September 15, 2012 23:59
Sublime Keyboard Shortcuts (Windows)
[
{ "keys": ["shift+tab"], "command": "unindent" },
{ "keys": ["ctrl+shift+m"], "command": "toggle_minimap" },
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["ctrl+i"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": true} },
{ "keys": ["ctrl+shift+n"], "command": "new_window" },
{ "keys": ["ctrl+shift+w"], "command": "close_window" },
{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
@datacodesolutions
datacodesolutions / sublime_keyboard_shortcuts_mac.json
Created September 16, 2012 00:00
Sublime Keyboard Shortcuts (Mac)
[
{ "keys": ["shift+tab"], "command": "unindent" },
{ "keys": ["ctrl+shift+m"], "command": "toggle_minimap" },
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["ctrl+i"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": true} },
{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["ctrl+alt+d"], "command": "expand_selection", "args": {"to": "word"} },
{ "keys": ["ctrl+alt+d"], "command": "find_under_expand", "context":
@datacodesolutions
datacodesolutions / mysql_string_replace.sql
Created September 18, 2012 04:08
Mysql String Replace
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');
@datacodesolutions
datacodesolutions / regex_last_segment_url.php
Created September 23, 2012 01:42
Regular Expression: Last Segment URL
preg_match('/[^\/]+$/', $this->_image_url, $matches);
@datacodesolutions
datacodesolutions / ssh_execute_remote.sh
Created September 24, 2012 15:54
Execute Shell Commands via SSH on Remote Server
ssh -OPTIONS -p SSH_PORT user@remote_server "remote_command1; remote_command2; remote_script.sh"