Skip to content

Instantly share code, notes, and snippets.

View ayushgoel's full-sized avatar

Ayush ayushgoel

View GitHub Profile
@ayushgoel
ayushgoel / DropboxAPI_testing.py
Created October 21, 2011 21:03
Testing Dropbox new Python API
## author: Ayush Goel
## Python 2.7 used
## get the Dropbox new API from https://www.dropbox.com/developers/
## mail: ayushgoel111@gmail.com
## put in your APP KEY and APP SECRET KEY
## do remember to install oauth, setuptools, simplejson
## not included by default in Python 2.7 installation
## http://pypi.python.org/pypi/setuptools
@ayushgoel
ayushgoel / NQueen.cpp
Created November 9, 2011 15:42
N- Queen generic solution
#include<iostream>
using namespace std;
/** this is the size of chess board */
#define N 5
/** Given a completed board, this prints it to the stdout */
void print_solution(int state[N][N])
{
int i,j;
@ayushgoel
ayushgoel / inorder.c
Created February 3, 2012 11:02
Linking inorder successor in a binary tree
// Global var to contain the inorder predecessor
node * prev;
void add_inorder(node * nd)
{
// Base case
if (nd == NULL)
return;
// Recursive call for inorder processing
@ayushgoel
ayushgoel / create_contacts.py
Created October 1, 2012 11:39
Create random contacts CSV
import random
# Change this number to get more contacts
number_of_contacts = 100
# Give FileName here
filename = 'contacts.csv'
all_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
@ayushgoel
ayushgoel / get-contact-image
Created March 13, 2014 07:18
Getting image from contact as UIImage in iOS
UIImage *contactImage = ({
NSData *imageData = CFBridgingRelease(ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatOriginalSize));
[UIImage imageWithData:imageData];
});
@ayushgoel
ayushgoel / makeIOSicons
Created April 11, 2014 19:04
Create icons from an image for iOS with predefined sizes
#! /usr/bin/python3
import PIL.Image as Image
import sys
imageNamePrefix = "Icon"
extension = ".png"
sizesToConvertTo = [(58, 58), (80, 80), (120, 120)];
def saveImage(image, imageName):
@ayushgoel
ayushgoel / hex-to-color
Created September 9, 2014 09:31
Convert Hex value for colour to decimal (cfcfcf) -> (207 207 207)
#! /usr/bin/python
import sys
def colorForHex(x):
if len(x) != 6:
return "Poorly formatted HEX", x
try:
r = int(x[:2], 16)
g = int(x[2:4], 16)
@ayushgoel
ayushgoel / git-subtree-add
Last active August 29, 2015 14:08
Easily add git subtree
#!/usr/bin/env bash
if [ $# -lt 2 ]
then
echo "ERROR: Less arguments."
echo "Usage: git-subtree-add <git-url> <ref(commit)>"
else
REPO_NAME=`echo $1 | sed 's%^.*/\([^/]*\)\.git$%\1%g'`
echo "Adding subtree for "
echo $REPO_NAME
@ayushgoel
ayushgoel / euler52.py
Last active August 29, 2015 14:08
Project Euler 52
def digits(x):
return set([int(j) for j in str(x)])
x = 1000
while True:
#write code
y = int(1.668*x)
for i in range(x, y):
print i
@ayushgoel
ayushgoel / removeFirst3Chars.py
Created December 9, 2014 08:20
Rename all files in current folder - remove first 3 chars
for i in os.listdir('.'):
if i.startswith('.') == False: #Hidden files
os.rename(i, i[3:])