Skip to content

Instantly share code, notes, and snippets.

@avanish
avanish / ViewController.m
Last active Feb 15, 2017
UIViewController navigation without segue or parent UINavigationController
View ViewController.m
// 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(), ^{
@avanish
avanish / ViewController.m
Created Feb 2, 2017
UINavigationController->UIViewController navigation without segue
View ViewController.m
// 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
Created Feb 2, 2017
Currency Formatter for Nepali Rupees
View ViewController.m
// 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]];
View 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);
}
}
View ViewController.m
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 / Flask-blueprint-with-imported-routes
Created Apr 10, 2018 — 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 / gabor_filter.py
Created May 23, 2018 — forked from kendricktan/gabor_filter.py
Gabor kernel filter example in python
View gabor_filter.py
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 / 8puzzle.py
Created Jan 15, 2019 — forked from flatline/8puzzle.py
An eight-puzzle solver in python
View 8puzzle.py
# 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):