Skip to content

Instantly share code, notes, and snippets.

@fprochazka
fprochazka / LookoutControl.php
Created October 15, 2010 10:41
LookoutControl - Control with fake life cycle
<?php
namespace Kdyby\Control;
use Nette;
use Nette\String;
class LookoutControl extends Nette\Application\Control
@orlin
orlin / Guardfile
Created December 6, 2010 13:08
CoffeeScript + Jim bundles / Guard
guard 'coffeescript', :output => 'app/javascripts', :wrap => false, :shallow => false do
watch('^app/coffeescripts/(.*)\.coffee')
end
def jimify(bundles, why = nil)
bundles = Array(bundles)
message = "Jim bundle & compress (bundles: #{bundles.join(", ")})"
message += " due to #{why} change" if why
puts message
# just bundle them first, so that livereload happens faster
@therobot
therobot / lets
Created December 23, 2010 14:46 — forked from afgomez/lets.sh
#!/bin/bash
# lets. A productivity booster
# based on ideas from https://gist.github.com/605292
#
# Copy your /etc/hosts to /etc/hosts.play and create a new one called /etc/hosts.work with a list of blocked sites
# Usage: sudo lets [play|work]
if [ $# = 0 ]
then
@Aurielle
Aurielle / BasePresenter.php
Created January 18, 2011 19:33
Koncept n:if-allowed (ověřování ACL v šablonách - Nette Framework) - funkční pouze s n:href
<?php
/*
* Předpokládá ACL následujícího tvaru:
* resource: Jméno presenteru / komponenty (PHP, včetně namespace)
* privilege: Jméno akce / signálu
*/
public function userAllowed($component, $destination = NULL)
{
if($destination === NULL) // No destination specified, can cause unexpected results when used with n:if-allowed as it would check for previous link!
@fprochazka
fprochazka / whereCalled.php
Created April 12, 2011 11:05
Shows where was method called
<?php
function wc($level = 1) {
if (\Nette\Debug::$productionMode) { return; }
$o = function ($t) { return (isset($t->class) ? htmlspecialchars($t->class) . "->" : NULL) . htmlspecialchars($t->function) . '()'; };
$f = function ($t) {
$file = defined('APP_DIR') ? 'app' . str_replace(realpath(APP_DIR), '', realpath($t->file)) : $t->file;
return '<a href="' . \Nette\DebugHelpers::editorLink($t->file, $t->line) . '">' . htmlspecialchars($file) . ':' . (int)$t->line . '</a>';
};
<?php
/**
* @see https://github.com/HosipLan/Nette-addDynamic
*/
class CreatePresenter extends BasePresenter
{
protected function startup()
{
<?php
namespace Kdyby\Loaders;
use Doctrine;
class DoctrineLoader
{
@starenka
starenka / papu.py
Created August 5, 2011 23:45
greps menus of my fav restaurants close to my office
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
from pyquery import PyQuery as pq
doc = pq(url='http://www.jinakrajina.cz/cz/poledni-menu')
noms = doc.find('td > p')
print '\n%s'%noms[0].text_content()[2:]
for i,nom in enumerate(noms[1:-1:2],1):
print '[%d] %s'%(i,nom.text_content().strip())
@ondrejmirtes
ondrejmirtes / .bash_profile
Created September 12, 2011 08:18
Git configuration
export PS1="\u:\W $ "
#GIT bash by HABR (modified by Dundee)
export PSORIG="$PS1"
function GITBRANCH() {
BRANCH="$(git branch 2>/dev/null | grep '*' | cut -d" " -f2-)"
if [ -n "$BRANCH" ] ; then
export PS1="\u:\W "
export PS1=$PS1$(echo -en "\[\033[00;37m\]$BRANCH \[\033[00m\]")
# inconsistent
# behavior in a class
class A
foo: ->
el.addEventListener 'click', @bar
bar: =>
# the class instance, ideal but a special case for the fat arrow
console.log(@)