Skip to content

Instantly share code, notes, and snippets.

@avanish
avanish / 8puzzle.py
Created January 15, 2019 08:20 — forked from flatline/8puzzle.py
An eight-puzzle solver in python
# Solves a randomized 8-puzzle using A* algorithm with plug-in heuristics
import random
import math
_goal_state = [[1,2,3],
[4,5,6],
[7,8,0]]
def index(item, seq):
@avanish
avanish / gabor_filter.py
Created May 23, 2018 04:08 — forked from kendricktan/gabor_filter.py
Gabor kernel filter example in python
import numpy as np
import cv2
# cv2.getGaborKernel(ksize, sigma, theta, lambda, gamma, psi, ktype)
# ksize - size of gabor filter (n, n)
# sigma - standard deviation of the gaussian function
# theta - orientation of the normal to the parallel stripes
# lambda - wavelength of the sunusoidal factor
# gamma - spatial aspect ratio
# psi - phase offset
@avanish
avanish / Flask-blueprint-with-imported-routes
Created April 10, 2018 15:22 — forked from Jaza/Flask-blueprint-with-imported-routes
Example of how to split a Flask blueprint into multiple files, with routes in each file, and of how to register all those routes.
*
@avanish
avanish / ViewController.m
Created April 24, 2017 03:43
Get FB Friends
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"me/friends"
parameters:nil
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
NSLog(@"%@", result);
}];
@avanish
avanish / ViewController.m
Created April 24, 2017 03:33
ViewController.m
// to list down all the available fonts in iOS
for (NSString *fontFamilyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:fontFamilyName]) {
NSLog(@"Family: %@ Font: %@", fontFamilyName, fontName);
}
}
@avanish
avanish / ViewController.m
Created February 2, 2017 08:39
Currency Formatter for Nepali Rupees
// Convert the currency format: 1,000,000 to Rs.10,00,00
//
// Initialization
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormatter setCurrencySymbol:@"Rs."];
[currencyFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_IN"]];
NSString *str = [currencyFormatter stringFromNumber:[NSNumber numberWithFloat:price]];
@avanish
avanish / ViewController.m
Created February 2, 2017 08:34
UINavigationController->UIViewController navigation without segue
// UIStoryboard->UINavigationController->UIViewController
//
// Initializations
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *controller = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:@"identifier"];
SecondViewController *svc = (SecondViewController *)controller.topViewController;
// Passing data
svc.some_code = self.object.some_code;
@avanish
avanish / ViewController.m
Last active February 15, 2017 08:40
UIViewController navigation without segue or parent UINavigationController
// UIViewController nagivation without the navigation controller.
// UIStoryboard->UINavigationController
//
// Initializations
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SecondViewController *svc = (SecondViewController *)[storyboard instantiateViewControllerWithIdentifier:@"identifierName"];
// Navigation
dispatch_async(dispatch_get_main_queue(), ^{