Skip to content

Instantly share code, notes, and snippets.

bin/console doctrine:schema:update --dump-sql -e test | awk '!/CONSTRAINT/' | mysql -u user -p dbname
@matejb
matejb / mock_iterator.php.md
Last active June 17, 2016 13:35
PHP Mock iterator
/**
     * Mock iterator
     *
     * This attaches all the required expectations in the right order so that
     * our iterator will act like an iterator!
     *
     * @param Iterator $iterator The iterator object; this is what we attach
     *      all the expectations to
     * @param array An array of items that we will mock up, we will use the
@matejb
matejb / lx.md
Last active March 24, 2016 11:20
linux cmds

port in use by program: netstat -lp

kill apps by port: fuser -k smtp/tcp

gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"
@matejb
matejb / svn_diff_msg
Last active August 29, 2015 14:21
find out all new msg key in uncommited content
svn status -q | xargs | svn diff | grep ^+ | grep msg. | sed -r -e 's|(.+)\$msg\.([^}]+)(.+)|\2|' | sort | uniq
@matejb
matejb / smtp_debug
Last active December 21, 2015 12:18
One line pyton debug SMTP server
sudo python -m smtpd -n -c DebuggingServer localhost:25
@matejb
matejb / gist:6264049
Created August 18, 2013 21:14
one line web server in bash
Author: http://www.razvantudorica.com/08/web-server-in-one-line-of-bash/
while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat index.html; } | nc -l 8080; done
index.html can be any file you want to serve it.
You can access it after that as: http://host_ip:8080/
@matejb
matejb / gist:4267099
Created December 12, 2012 11:29
Komodo Edit PHP debuging macros
//=== var_dump anything in clipboard ===\\
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }
komodo.view.selection = 'echo \'<pre>\';'
ko.commands.doCommand('cmd_newline')
komodo.view.selection = 'echo __FILE__ . \' @ \' . __LINE__ . "\\n";';
ko.commands.doCommand('cmd_newline')
komodo.view.selection = 'var_dump(';
ko.commands.doCommand('cmd_paste')
@matejb
matejb / gist:3979882
Created October 30, 2012 12:21
jQuery custom validate function example
$(document).ready(function(){
$.validator.addMethod('hex_format', function(value, element){
var hexregex = /^[0-9ABCDEF]{6}$/i;
return hexregex.test(value);
});
$.validator.addMethod('http_url_format', function(value, element){
if (value.length == 0)
{
@matejb
matejb / gist:1700070
Created January 29, 2012 18:41
String ASCII echo
$sub = str_split(substr($input_string, 0, 400));
$chars = '';
$ords = '';
foreach ($sub as $character)
{
if ($character == "\n" || $character == "\r")
continue;
$chars .= $character . ' ';
$ords .= ord($character) . "\t";