Skip to content

Instantly share code, notes, and snippets.

@smasty
smasty / bootstrap.sh
Created May 8, 2016 17:16
LunaCI bootstrap script
#!/usr/bin/env bash
REPO=`dirname "$(cd ${0%/*} && echo $PWD/${0##*/})"`
LUADIST_BOOTSTRAP="$REPO/luadist-bootstrap"
INSTALLATION="$REPO/_install"
DATA_DIR="data"
# Get LuaDist bootstrap
git clone "https://github.com/LuaDist-core/bootstrap.git" "$LUADIST_BOOTSTRAP"
-- LuaDist Manifest file
-- Generated on 2016-03-23, 13:35
{
packages = {
lua_cliargs = {
["1.1-1"] = {
dependencies = {
"lua >= 5.1"
}
},
{
packages = {
["lunaci"] = {
["0.2-1"] = {
dependencies = {
"lua >= 5.1",
"penlight >= 1.3.3.luadist",
"lualogging >= 1.3.0",
}
}
@smasty
smasty / test.lua
Last active February 20, 2016 13:23
Test
-- manifest test
-- testing push access to gist repo
@smasty
smasty / filter.java
Last active August 29, 2015 14:01
Filter projects based on criteria. Uses a filterable Iterator with custom predicate, regexps and reflection.
/**
* List projects based on criteria.
* @param action
* @param user
*/
public Iterable<IProject> executeAction(ListProjectsAction action, IUser user) {
Iterable<IProject> items = projects.values();
if(action.getParams().containsKey("filter")){
Pattern pattern = Pattern.compile(Pattern.quote(action.getParam("pattern"))
@smasty
smasty / gist:3800452
Created September 28, 2012 15:15
Converts unprintable PDFs exported to SVG by Evince to PNG images.
<?php
$data = file_get_contents($argv[1]);
$offset = isset($argv[2]) ? $argv[2] : 0;
if(preg_match_all('~data:image\/png;base64,([^"]+)"~i', $data, $matches)){
foreach($matches[1] as $k=>$i){
$id = $k+1+$offset;
echo "Processing page $id...";
$image = imagecreatefromstring(base64_decode($i));
@smasty
smasty / GameOfLife.php
Created May 20, 2012 13:01
The Game of Life in PHP
<?php
/**
* The Game of Life - a PHP simulator of the famous game.
* Early development state.
*
* Copyright 2011 Martin Srank (http://smasty.net)
*
* This source file is subject to the MIT license:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@smasty
smasty / Navigation.breadcrumbs.latte.html
Created September 25, 2011 10:25
NavigationControl for Nette Framework
{*
* Available variables:
* - $control (NavigationControl) The control.
*}
<div class="control breadcrumbs" n:inner-foreach="$control->getComponents() as $node">
{if $iterator->last}
<span class="current">{$node->label}</span>
{else}
<a href="{$node->link}">{$node->label}</a> &raquo;
{/if}
@smasty
smasty / SmartPresenterFactory.php
Created September 25, 2011 10:16
Smart presenter factory - supports custom name conventions for presenters.
<?php
namespace Smasty\Extensions;
use Nette,
Nette\Environment;
/**
* Smart presenter factory - supports custom name conventions for presenters.
@smasty
smasty / bashrc.sh
Created September 14, 2011 14:29
Bash prompt with exit code and Git branch
# ========= PS1 SETTINGS
# Git branch
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/@\1/'
}
# Pipe code notifiation
bash_prompt_command() {