Skip to content

Instantly share code, notes, and snippets.

@kevinquinnyo
kevinquinnyo / phpunit
Created April 22, 2019 01:20
disable xdebug for unit tests, re-enable it when done or interupted
#!/bin/bash
trap "sudo phpenmod xdebug" EXIT
sudo phpdismod xdebug
vendor/bin/phpunit "$@"
@kevinquinnyo
kevinquinnyo / rich_types.php
Created December 19, 2018 03:52
weird idea for extending TypeError and having richer 'types' in php
<?php
// experiment with 'rich types' in php?
class RichTypeError extends TypeError
{
// maybe customize this
}
class _email
{
@kevinquinnyo
kevinquinnyo / bubble_sort.rs
Created January 6, 2018 20:24
bubble sort in rust attempt 1
fn main() {
let mut array: [i32; 5] = [5, 6, 3, 2, 8];
let sorted = bubble_sort(array);
for x in &sorted {
println!("{0}", x);
}
assert_eq!(sorted, [2, 3, 5, 6, 8], "Failed to sort array.");
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity as CakeEntity;
use Cake\Datasource\EntityTrait;
class Entity extends CakeEntity
{
use EntityTrait {
get as traitGet;
# Install Vundle -- A vim plugin manager
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# Test terminal 256 color support
bash < <(curl https://gist.githubusercontent.com/kevinquinnyo/1598610d133e4f9f872de1444677a5cf/raw/cbcc804a99efa28fed6d9299c8e1cedca2c9bcc7/bash-color-test.bash)
)
# Test vim 256 color support
vim "+runtime syntax/colortest.vim"
# Close vim, try again with this:
set nocompatible " be iMproved, required
filetype off " required
"set paste
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@kevinquinnyo
kevinquinnyo / bash-color-test.bash
Created September 25, 2016 20:40
Test terminal for 256 color support
# Stolen from http://www.commandlinefu.com/commands/view/6533/print-all-256-colors-for-testing-term-or-for-a-quick-reference
( x=`tput op` y=`printf %$((${COLUMNS}-6))s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done; )
#!/bin/bash
# .git/hooks/post-commit
txtred=$(tput setaf 1)
txtreset=$(tput sgr0)
git log -1 HEAD --pretty=format:%s | egrep -o '[A-Z]{2}-[0-9]+ #time' || \
echo -ne "\n${txtred} [!] Missing JIRA smart commit.${txtreset}\n\n"
#!py
def run():
states = {}
cache_private_ips = __salt__['tss.get_role_ips']('cache')
states['test-tss-module'] = {
'cmd.run': [
{'name': 'echo {0} > /tmp/tss-module-test.txt'.format(cache_private_ips)},
@kevinquinnyo
kevinquinnyo / gist:81fb02af7e305d4d37e73963fafc937c
Created April 10, 2016 18:54
utility function for multiple sls
def get_role_ips(role, interface='eth1'):
billing_id = __pillar__['cluster']['client']['billing_id']
cluster_name = __pillar__['cluster']['name']
ips = []
interfaces = __salt__['mine.get']('{0}*{1}-{2}.my-platform-domain.com'.format(role, billing_id, cluster_name), 'network.interfaces')
for minion, interface in interfaces.iteritems():
for name, data in interface.iteritems():
if name == interface:
ips.append(data['inet'][0]['address'])
return ips