Skip to content

Instantly share code, notes, and snippets.

View praveenvvstgy's full-sized avatar

Praveen Gowda I V praveenvvstgy

View GitHub Profile
@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
@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 / 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 / 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 / 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
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
# -*- 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"
// GLblackjack.c
// By Eric Stringer 2002
// E-mail: nexusone@netzero.net
// A openGL example program, plays black jack (21)
//
// Keyboard inputs: [ESC] = quit
// 'L' = enables/disables lighting
// 'V' = toggle ortho/prespective view
// 'D' = Deal cards
// 'H' = Hit (add a card to player)
@praveenvvstgy
praveenvvstgy / README.md
Last active December 27, 2015 13:19 — forked from JoelBesada/README.md

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.
@praveenvvstgy
praveenvvstgy / >
Created July 17, 2013 10:09 — forked from anonymous/>
<!DOCTYPE html> <!-- Helpful things to keep in your <head/> // Brian Blakely, 360i -->
<head>
<!-- According to Heather Champ, former community manager at flickr,
you should not allow search engines to index your "Contact Us"
or "Complaints" page if you value your sanity. This is an HTML-
centric way of achieving that. -->
<meta name="robots" content="noindex" />
<!-- Suppress IE6's pop-up-on-mouseover toolbar for images, that can
interfere with certain designs. -->