Skip to content

Instantly share code, notes, and snippets.

View praveenvvstgy's full-sized avatar

Praveen Gowda I V praveenvvstgy

View GitHub Profile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.21"
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug
@praveenvvstgy
praveenvvstgy / synchgh-pages
Last active August 29, 2015 14:04
Sync master with gh-pages by adding these lines to .git/config under [remote “origin”]
push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master
@praveenvvstgy
praveenvvstgy / queue-with-stack.py
Created November 10, 2014 11:35
Implement a queue with 2 stacks . Your queue should have an enqueue and a dequeue function and it should be "first in first out" (FIFO). Optimize for the time cost of m function calls on your queue. These can be any mix of enqueue and dequeue calls. Assume you already have a stack implementation and it gives O(1) time push and pop.
stack1 = []
stack2 = []
def enqueuue(a):
stack1.append(a)
def dequeue():
if len(stack2) > 0:
return stack2.pop()
elif len(stack2) == 0 and len(stack1) > 0:
@praveenvvstgy
praveenvvstgy / balanced_paranthesis.py
Created November 10, 2014 12:16
Check for balanced parentheses in an expression
def braces_validator(string):
openers = "({["
closers = ")}]"
stack = []
for char in string:
if char in openers:
stack.append(openers.index(char))
elif char in closers:
if len(stack) == 0 or stack.pop() != closers.index(char):
return False
@praveenvvstgy
praveenvvstgy / matching-parens.py
Created November 10, 2014 15:46
Write a function that, given a sentence, along with the position of an opening parenthesis, finds the corresponding closing parenthesis.
openers = "({["
closers = ")}]"
def paranthesis_match(string, pos):
stack = [string[pos]]
for i in range(pos + 1, len(string)):
if string[i] in openers:
stack.append(string[i])
if string[i] in closers:
stack.pop()
@praveenvvstgy
praveenvvstgy / thumb.sh
Created April 5, 2015 16:55
Create a thumbnail using ImageMagick
for file in `find . -type f -name "*.jpg"`
do
thumbnail_file="./thumbnail/${file##*/}"
if [ ! -e "${file%/*}/thumbnail" ]; then mkdir -p "${file%/*}/${thumbnail_dir}"; fi
echo "Create thumbnail for image $file"
`convert -thumbnail x300 $file $thumbnail_file`
done

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after

JSON API

Top Level

The top-level of a JSON API document has the following keys:

  • Resource names (posts, comments, people, etc.)
  • A meta section

Singular Resources

Twilight Theme Terminal Colors

Based on the timeless TextMate theme.

Basic Colors

Foreground:     #FEFFD3

Background: #141414