Skip to content

Instantly share code, notes, and snippets.

View donarb's full-sized avatar

Don Arbow donarb

View GitHub Profile
@haxorjim
haxorjim / gist:1371323
Created November 16, 2011 20:45
Validate Tracking Numbers in PL/SQL
function fedex12(p_tracking_number varchar2) return boolean is
trk varchar2(12);
tot number:=0;
mult number:=1;
chr varchar2(1);
begin
--if the data passed is 12 digits then strip everything but valid FedEx tracking number characters.
if length(p_tracking_number) = 12 then
for x in 1..length(p_tracking_number) loop
chr := upper(substr(p_tracking_number,x,1));
@dkw5877
dkw5877 / AppCoordinator.swift
Created April 26, 2017 20:46
Example of AppCoordinator Object
import UIKit
class Coordinator { }
class AppCoordinator {
fileprivate var isLoggedIn = false
fileprivate let navigationController:UINavigationController
fileprivate var childCoordinators = [Coordinator]()
@dkw5877
dkw5877 / AuthenticationCoordinator.swift
Last active November 17, 2017 18:26
Example of Authentication Coordinator Object
import UIKit
protocol AuthenticationCoordinatorDelegate:class {
func coordinatorDidAuthenticate(coordinator:AuthenticationCoordinator)
}
class AuthenticationCoordinator:Coordinator {
weak var delegate:AuthenticationCoordinatorDelegate?
let navigationController:UINavigationController
@dkw5877
dkw5877 / ProfileCoordinator.swift
Created April 26, 2017 20:49
Example of Profile Coordinator Object
import UIKit
protocol ProfileFlowCoordinatorDelegate:class { }
class ProfileFlowCoordinator:Coordinator {
fileprivate let navigationController:UINavigationController
fileprivate let profileViewController:ProfileViewController
fileprivate let navigationDelegate:NavigationControllerDelegate?
@gaganpreet
gaganpreet / pagination_without_count.py
Created October 23, 2017 12:30
Flask SQLAlchemy Pagination without count query
def optimised_pagination(query, per_page, page):
'''A more efficient pagination for SQLAlchemy
Fetch one item before offset (to know if there's a previous page)
Fetch one item after limit (to know if there's a next page)
The trade-off is that the total items are not available, but if you don't need them
there's no need for an extra COUNT query
'''
offset_start = (page - 1) * per_page
query_offset = max(offset_start - 1, 0)