Skip to content

Instantly share code, notes, and snippets.

@andkirby
andkirby / ps-git.sh
Last active April 22, 2016 06:59
Example of PS1 with condition.
#!/usr/bin/env bash
alias __ch_task='if [[ "" != $(git rev-parse --git-dir 2> /dev/null) ]]; then echo -n $(ch config task); fi;'
export PS1='$(__ch_task)'
@andkirby
andkirby / version_sort.php
Last active October 4, 2022 09:54
Semantic versions sorting
<?php
/**
* Sort versions list
*
* Add an alias in GIT
* $ git config --global alias.tags "!git tag | xargs -i -0 php "$(where version_sort)" {}"
* @link https://gist.github.com/andkirby/0046df5cad44f86b670a102b7c8b7ba7
*/
try {
if (php_sapi_name() != 'cli') {
@andkirby
andkirby / debug_wrapper.php
Last active April 1, 2016 13:48
This class can wrap each method in a class with custom code.(it wasn't tested with namespaces)
<?php
/**
* Usage:
* <?php
* // target class which should be wrapped
* class Class_For_Testing extends stdClass
* {
* public static function complexParams(stdClass $a, array &$foo = null, $bar = 'baz')
* {
* echo 'This is a test1' . PHP_EOL;
@andkirby
andkirby / magento.prod.mob.conf
Last active November 2, 2016 13:49
mob nginx config
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/pki/tls/certs/www.m.com_2015-06-18.crt;
ssl_certificate_key /etc/pki/tls/private/www.m.com_2015-06-18.key;
ssl_session_timeout 7m;
## Specify your SSL options here
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
/**
* Validate password
*
* @param Varien_Object $object
* @return bool
*/
public function validate($object)
{
$password = $object->getPassword();