Skip to content

Instantly share code, notes, and snippets.

@thanosp
thanosp / figo.sh
Last active August 12, 2020 07:38
shell function to find and go to the directory of a go project
# go to the source of a go project in $GOPATH
# Usage: $ figo projectname
figo () {
FIGODIR=`find $GOPATH/src -name "$1" -print -maxdepth 3 | grep -v vendor | head -n1`
if [ "$FIGODIR" = "" ]; then FIGODIR=`find $GOPATH/src -name "$1" -print -maxdepth 4 | grep -v vendor | head -n1`; fi
cd $FIGODIR
}
@thanosp
thanosp / commit-msg.sh
Last active October 5, 2016 09:29
.git/hooks/commit-msg for JIRA branch
#!/bin/sh
#
[[ -n "$(cat $1 | grep 'fixup!')" ]] && FIXUP="YES"
JIRA_PREFIX="CSB-"
TICKET=$JIRA_PREFIX$(git symbolic-ref HEAD | rev | cut -d/ -f1 | rev | grep -o -E "[0-9]+" | head -n1)
if [[ "" != "`head -n1 $1`" && -n "${TICKET}" && -z "${FIXUP}" ]]; then
sed -i.bak -e "1s/^/[${TICKET}] /" $1
fi
<?php
declare(strict_types=1);
namespace Tests\Endouble\Sanity;
use Generator;
use SplFileInfo;
use SplFileObject;
use Symfony\Component\Finder\Finder;
use Tests\Endouble\UnitTestCase;
@thanosp
thanosp / tabfix.rc
Created March 22, 2012 12:32
Tabfix
tabfix()
{
if [ -z "$1" ]; then
echo -e 'Usage: tabfix [path]'
else
baseDir="$1"
find "$baseDir" -name "*.php" |while read line
do
expand -t 4 -i $line > $line.new
mv $line.new $line
@thanosp
thanosp / skellie-partial-call.php
Created February 25, 2012 09:54
calling a skellie partial
<?php
$params = array(
'categorySlug' => 'news',
'limit' => 7
);
echo $this->partial('list', 'category', $params); ?>
@thanosp
thanosp / category.php
Created February 25, 2012 09:43
skellie partial argument usage
<?php
query_posts(array(
'posts_per_page' => $this->limit?:10,
'category_name' => $this->categorySlug,
'paged' => get_query_var('paged')
));
if (have_posts()) {?>
<section class="categoryList">
<header><h2><?php echo $this->title?:'Archive'; ?></h2></header>
@thanosp
thanosp / functions.php
Created February 25, 2012 07:08
Install Skellie with cherry picking on
<?php
require_once __DIR__ .'/library/Skellie/Frame.php';
use Skellie\Frame;
/**
* Takes over the rendering process and uses layouts instead
* @param string $templateFile
* @return null
*/
add_filter('template_include', function ($templateFile) {
$frame = new Frame($templateFile);
@thanosp
thanosp / getTheLimitedExcerpt.php
Created February 19, 2012 14:44
Wordpress custom smart excerpt
<?php
/**
* Limits an excerpt to the given number of characters
* @param integer $limit in words
* @param boolean $allowUnfilteredManualExcerpt Gives the manual excerpt priority
* @return string
*/
function getTheLimitedExcerpt($limit = 30, $allowUnfilteredManualExcerpt = false)
{
global $post;
@thanosp
thanosp / comments.php
Created February 15, 2012 19:44
Wordpress comments
<h2>Leave a comment</h2>
<?php
comment_form(array('comment_notes_after'=>'', 'title_reply' => ''));
echo $this->partial('list', 'comments');
@thanosp
thanosp / gist:1815052
Created February 13, 2012 08:33
Glitch
G̸̡͉̙̫̻̺̝͉̣̩͕͍̓͑̈̒̆̀ͅlitcȟ̚̕ ̍͒͏"