Skip to content

Instantly share code, notes, and snippets.

View justjkk's full-sized avatar

J Kishore Kumar justjkk

  • Bangalore, India
View GitHub Profile
@justjkk
justjkk / .htaccess
Created December 7, 2016 08:22
Wordpress .htaccess file with security headers
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
diff --git a/Router/DefaultPatternGenerationStrategy.php b/Router/DefaultPatternGenerationStrategy.php
index 2fe5dfb..714ea37 100755
--- a/Router/DefaultPatternGenerationStrategy.php
+++ b/Router/DefaultPatternGenerationStrategy.php
@@ -66,6 +66,9 @@ class DefaultPatternGenerationStrategy implements PatternGenerationStrategyInter
// prefix with locale if requested
if (self::STRATEGY_PREFIX === $this->strategy
|| (self::STRATEGY_PREFIX_EXCEPT_DEFAULT === $this->strategy && $this->defaultLocale !== $locale)) {
+ if ($i18nPattern == '/') {
+ $i18nPattern = '';
@justjkk
justjkk / .env
Created June 29, 2015 13:37
Autoenv for python
DIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[ "$VIRTUAL_ENV" != "$DIR/venv" ] && . $DIR/venv/bin/activate
@justjkk
justjkk / dir.sh
Created April 17, 2015 10:42
Directory where bash file is present
#!/bin/bash
DIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@justjkk
justjkk / config.yaml
Created February 5, 2015 13:59
Sensio Insight php-memcached extension
pre_composer_script: |
memcached -d
sudo apt-get -y -q --force-yes install zlib1g-dev pkg-config libmemcached-dev
cd /tmp
wget https://github.com/php-memcached-dev/php-memcached/archive/2.2.0.tar.gz
tar zxvf 2.2.0.tar.gz
cd php-memcached-2.2.0
phpize
./configure --disable-memcached-sasl
make
@justjkk
justjkk / checkload.sh
Created August 8, 2012 07:45
Check load on the server
LOAD_THRESHOLD="2.0"
if [ $(echo $(cut -d" " -f2 /proc/loadavg) " > $LOAD_THRESHOLD" | bc -l) -eq 1 ]; then
echo "High load";
else
echo "Low load";
fi
@justjkk
justjkk / mdb-wc.sh
Created May 16, 2012 04:30
mdb-wc recipe to display wc stats on mdb tables
function mdb-wc {
IFS_ORIG=$IFS;
IFS=$'\n';
for t in `mdb-tables -1 "$1"`
do
echo $t;
mdb-export "$1" "$t" | wc;
done;
IFS=$IFS_ORIG;
}
@justjkk
justjkk / ph.py
Created May 4, 2012 13:34
CLI Wrapper around python-phonenumbers library
#!/usr/bin/env python
"""Minimal CLI wrapper around phonenumbers library so that PHP can use it
Author: Kishore Kumar <[email protected]>
Usage: python ph.py <command> <args>
Commands:
help - Print this
@justjkk
justjkk / github-issues.py
Created May 2, 2012 20:13
Backup github issues
#!/usr/bin/env python
"""
Backup github issues
Input: Read from settings.py
Output: JSON data written to stdout
Usage: ./github-issues.py >xyz-issues.json
"""
@justjkk
justjkk / camel2Title.php
Created November 28, 2011 21:06
CamelCase to Title Case PHP Regex
<?php
function camelToTitle($camelStr)
{
$intermediate = preg_replace('/(?!^)([[:upper:]][[:lower:]]+)/',
' $0',
$camelStr);
$titleStr = preg_replace('/(?!^)([[:lower:]])([[:upper:]])/',
'$1 $2',
$intermediate);