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 / LICENSE
Last active January 11, 2026 18:47
Parsing JSON with lex and yacc
The MIT License (MIT)
Copyright (c) 2015 J Kishore Kumar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@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);
@justjkk
justjkk / ack_short.py
Created May 20, 2010 18:43
Ackermann Function in python
import sys
count=0
sys.setrecursionlimit(50000)
cache={}
def a(m,n):
global count
global cache
count=count+1
if cache.has_key(m) and cache[m].has_key(n):
return cache[m][n]
@justjkk
justjkk / nqueens.py
Created April 20, 2010 13:57 — forked from yuvipanda/nqueens.py
Recursive solution for N-Queens problem in Python
from math import *
import sys
chosen = {}
n = int(sys.argv[1])
def place(xpos, ypos):
if (ypos in chosen.values()):
return False
opponent = 1
@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 / dct.py
Created February 13, 2011 07:01
Discrete Cosine Transformation in python using FP
from math import cos
PI = 3.141592
N = 8
def f(u,v):
if u + v % 2: return 0
return 1
def sum(x,y):
@justjkk
justjkk / Ackermann0.c
Created May 20, 2010 16:09
Ackermann's Function using C
// Ackermann's Function - Full Recursive
#include<stdio.h>
#include<stdlib.h>
int ackermann(int x, int y);
int count = 0, indent = 0;
int main(int argc, char **argv)
{
int x,y;
if(argc!=3)
{
@justjkk
justjkk / knightstour.c
Created October 14, 2010 06:46
Backtracking solution to Knight's Tour problem
// Backtracking solution to Knight's Tour problem http://en.wikipedia.org/wiki/Knights_tour
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
// Constraint: MAXX should be greater than or equal to MAXY
#define MAXX 5
#define MAXY 5
typedef enum {FALSE, TRUE} bool;
int n = 0;
bool treaded_blocks[MAXX][MAXY];
@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 / .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>