Skip to content

Instantly share code, notes, and snippets.

View inadarei's full-sized avatar

Irakli Nadareishvili inadarei

View GitHub Profile
@inadarei
inadarei / HTTPOutput.php
Created November 9, 2011 23:58
URoute Response Example
Zaphpa_Request Object
(
[params] => Array
(
[id] => 234234
)
[data] => Array
(
[api] => 46546456456
@inadarei
inadarei / catalina.sh
Created November 14, 2011 22:20
Catalina Safe Start/Stop Script
#!/bin/sh
# -----------------------------------------------------------------------------------------------------
# Validate Input Data
# -----------------------------------------------------------------------------------------------------
usage="usage: $0 [command]
where [command] can be:
- safestart: check if servers are up and if they are not: start them.
- safestop: check if servers are down and if they are not: stop them.
@inadarei
inadarei / nginx.debian.vm
Created January 11, 2012 09:10
Nginx Config for Drupal
server {
listen 80;
server_name debian.vm;
root /var/www/debian.vm/drupal;
access_log /var/www/debian.vm/logs/access.log;
error_log /var/www/debian.vm/logs/error.log;
index index.html index.htm index.php;
# DRUPAL STUFF
@inadarei
inadarei / drupal.vcl
Created January 16, 2012 22:34
Varnish VCL for Drupal
acl internal {
"127.0.0.1";
}
backend default {
.host = "127.0.0.1";
.port = "81";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
'path' => '/news/{id}/{categories}/{title}/{year}',
'handlers' => array(
'id' => Zaphpa_Constants::PATTERN\_NUM,
'categories' => Zaphpa_Constants::PATTERN\_ARGS,
'title' => Zaphpa_Constants::PATTERN\_ALPHA,
'year' => Zaphpa_Constants::PATTERN\_YEAR,
),
[params] => Array
(
[id] => 212424
[categories] => Array
(
[0] => us
[1] => politics
[1] => elections
)
[title] => some-title-goes-here
'handlers' => array(
'id' => Zaphpa_Constants::PATTERN_DIGIT, //numeric
'uuid' => 'handle_uuid', //callback function
),
'handlers' => array(
'id' => Zaphpa_Constants::PATTERN_DIGIT, //numeric
'full_date' => Zaphpa_Template::regex('\d{4}-\d{2}-\d{2}'); // custom regex
),
@inadarei
inadarei / gist:1975651
Created March 5, 2012 00:36 — forked from dhh/gist:1975644
Rails Mass Assignment Protection
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@inadarei
inadarei / camel_case_parser.php
Created March 25, 2012 23:01
CamelCaseParser
// Originally from: http://stackoverflow.com/questions/4519739/split-camelcase-word-into-words-with-php-preg-match-regular-expression
// Answer by ridgerunner
// The beauty of this solution is that it is ok with words starting with lower-case and consecutive uppercase letters.
$ccWord = 'oneTwoThreeFour';
$re = '/# Match position between camelCase "words".
(?<=[a-z]) # Position is after a lowercase,
(?=[A-Z]) # and before an uppercase letter.
/x';
$a = preg_split($re, $ccWord);