server { | |
listen 80; | |
server_name lucid32.dev; | |
access_log /var/log/nginx/localhost.access.log; | |
## Default location | |
location / { | |
root /vagrant/yourprojectname; | |
index index.php; | |
} |
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
| π | π | π | π |
π© | π | π | π | π¨ | π° | π£ | π’ | π | π | π² | π± | | π« | π | π‘ | π€ | πͺ | π | π·
π | π΅ | πΏ | π | π | πΆ | π | π½ | π | π | π | β€οΈ | π | π | π | π | π | π | π | β¨
;; based on core.logic 0.8-alpha2 or core.logic master branch | |
(ns sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [rows x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in rows [x y]))) |
#!/bin/bash | |
# $1 is the var | |
# $2 is replace from | |
# $3 is replace to | |
EXPECTED_ARGS=3 | |
E_BADARGS=65 | |
HELP=$(cat <<EOF | |
Usage with three arguments: | |
`basename $0` /var/www/path/ typo type |
In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:
This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
<?php | |
namespace Sonata\Bundle\DemoBundle\Controller; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Sonata\Bundle\DemoBundle\Model\MediaPreview; | |
use Symfony\Component\HttpFoundation\Request; | |
class DemoController extends Controller | |
{ |
import string | |
import sys | |
# list of valid characters to use in the shortener slug | |
CHARSET = string.digits + string.lowercase + string.uppercase | |
# convert a numeric id to a url-shortener-type slug | |
def shorty(id): | |
slug = "" | |
while id > 0: |