Skip to content

Instantly share code, notes, and snippets.

View Streek's full-sized avatar
🎃
Building Better Worlds

Keith Connolly Streek

🎃
Building Better Worlds
View GitHub Profile
@Streek
Streek / phone_format.php
Created March 13, 2012 03:32
Phone Number Auto-Formatting
<?php
function phone_number($sPhone){
$sPhone = ereg_replace("[^0-9]",'',$sPhone);
if(strlen($sPhone) != 10) return(False);
$sArea = substr($sPhone,0,3);
$sPrefix = substr($sPhone,3,3);
$sNumber = substr($sPhone,6,4);
$sPhone = "(".$sArea.")".$sPrefix."-".$sNumber;
return($sPhone);
}
@Streek
Streek / errors.php
Created April 18, 2012 08:07
Error Reporting in PHP
<?php
//Allows all errors and notices to be displayed.
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
@Streek
Streek / connect.php
Created April 18, 2012 08:08
Extract Database Information Via PHP on Heroku
<?php
//$_ENV['SHARED_DATABASE_URL'] should be changed to your environment variable.
extract(parse_url($_ENV['SHARED_DATABASE_URL']));
R::setup("pgsql:host=$host dbname=".substr($path,1), $user, $pass);
?>
@Streek
Streek / navigationPushPop.m
Last active December 28, 2015 13:49
So I wanted to push a view into the navigation stack while simultaneously popping to that view (so that view slide animation goes backwards!). This was my solution. Just assumes your last navigation area is your current view and the second to last is replaced with the new view. You can easily add instead of replacing.
NSMutableArray* newViewControllers = [self.navigationController.viewControllers mutableCopy];
[newViewControllers replaceObjectAtIndex:[newViewControllers indexOfObject:self] withObject:loginController];
[self.navigationController setViewControllers:newViewControllers animated:YES];
@Streek
Streek / anagram.rb
Created April 4, 2014 22:03
Solve for Anagram
#Keith Connolly
#require ruby -v 1.9.2 or higher.
#Extend String because it's clean.
class String
#does the same as permutation but on a string.
def char_arr(&block)
#Split all chars into an array.
arr = split(//)
#Pick all possible arrangements of that array.
@Streek
Streek / gist:810a313d6180d35db896
Last active September 23, 2015 21:25
Zsh shell for a lazy fast git process. Include a second value (any value) to push to heroku after the gitpush.
fastgit () {
print "Adding changes and commiting to current head..."
git add .
git commit -a -m "$1"
print "Pushing..."
git push
if [ -z "$2" ];
then
print "Finishing up..."
else
@Streek
Streek / pull_to_refresh.swift
Created March 1, 2016 21:19
Web View Pull To Refresh.
override func viewDidLoad() {
super.viewDidLoad()
addPullToRefreshToWebView()
}
func addPullToRefreshToWebView(){
var refreshController:UIRefreshControl = UIRefreshControl()
refreshController.bounds = CGRectMake(0, 50, refreshController.bounds.size.width, refreshController.bounds.size.height) // Change position of refresh view
refreshController.addTarget(self, action: Selector("refreshWebView:"), forControlEvents: UIControlEvents.ValueChanged)
@Streek
Streek / dkr
Created May 2, 2017 22:37
Start or stop all docker containers.
#!/bin/bash
echo "Operation starting..."
if [[ $1 == "s" || $1 == "start" ]]; then
echo "--Starting All Docker Containers--"
docker start $(docker ps -a -q)
echo "All Containers Started..."
fi
@Streek
Streek / pio
Created May 2, 2017 22:41
Start all Prospectify.io docker containers.
#!/bin/bash
echo "Operating on PIO containers..."
if [[ $1 == "s" || $1 == "start" ]]; then
echo "--Starting PIO Containers--"
docker start piopgapp
docker start piopgdata
echo "Containers Started..."
fi
@Streek
Streek / shortcuts.sh
Last active August 17, 2017 17:25
Docker Shortcuts
#This works on the majority of systems including windows with powershell.
#Start all docker containers
docker start $(docker ps -a -q)
#Stop all docker containers
docker stop $(docker ps -a -q)
#Remove all docker containers
docker rm $(docker ps -a -q)