Skip to content

Instantly share code, notes, and snippets.

View markrickert's full-sized avatar

Mark Rickert markrickert

View GitHub Profile
@markrickert
markrickert / aliases.bash
Created January 22, 2014 21:36
wo - "Work On", a bash alias for quickly cd-ing into directories
# wo = work on
wo() {
code_dir=~/Dropbox # replace it with your development directory
cd $(find $code_dir -type d -maxdepth 3 | grep -i $* | grep -Ev Pods --max-count=1)
}
@markrickert
markrickert / fix-xcode.rb
Last active February 2, 2020 01:31
Quick fix to all your Xcode SDK issues. When you update Xcode, just run this script and all is well.
#!/usr/bin/env ruby
# fix-xcode
# Mark Rickert <[email protected]>
# Symlinks all your old SDKs to Xcode.app every time it is updated.
# Create a directory called /SDKs and run this script.
#
# Each time you upgrade Xcode, run fix-xcode.
@markrickert
markrickert / statesscreen.rb
Created September 2, 2013 13:38
Example on how to set the background color/view of a ProMotion GroupedTableScreen
class StatesScreen < PM::TableScreen
title "States"
def will_appear
view.backgroundView = nil
view.backgroundColor = UIColor.redColor
end
def table_style
@markrickert
markrickert / migration_create_states.rb
Created August 20, 2013 14:45
Rails DB Seed for US States
class CreateStates < ActiveRecord::Migration
def change
create_table :states do |t|
t.string :name
t.string :abbrev
t.timestamps
end
end
end
@markrickert
markrickert / spec.rb
Created July 30, 2013 18:50
Trying to loop through a UITableView... it prints out the "puts" line all at once.
it "should select all cells and go back" do
wait 0.5 do #Wait for the view to load
ips = []
(1..@screen.table_view.numberOfSections-1).to_a.each do |section| # (skip the first section)
rows = @screen.table_view.numberOfRowsInSection(section)
(0..rows-1).to_a.each do |row|
ips << NSIndexPath.indexPathForRow(row, inSection:section)
end
@markrickert
markrickert / fibonacci.rb
Created March 13, 2013 00:04
Fibonacci Sequence
# Find the fibonacci sequence of the position n
def fib (n)
return n if [0,1].include?(n)
fib(n-1) + fib(n-2)
end
@markrickert
markrickert / webview.m
Created August 21, 2012 20:22
Load RubyMotion links from a UIWebView in Safari
//Here's the same thing in Objective-C
#import "WebView.h"
@implementation WebView
@synthesize webView = _webView;
-(void) viewDidLoad
{
// DLog is almost a drop-in replacement for NSLog
// DLog();
// DLog(@"here");
// DLog(@"value: %d", x);
// Unfortunately this doesn't work DLog(aStringVariable); you have to do this instead DLog(@"%@", aStringVariable);
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
@markrickert
markrickert / giratchive.sh
Created June 12, 2012 20:20
Git Archive Bash Script
#!/bin/bash
# Takes one parameter: a remote git repository URL.
#
# This is the stuff this script does:
#
# 1. Clones the repository
# 2. Fetches all remote branches
# 3. Compresses the folder
# 4. Deletes the cloned folder.
@markrickert
markrickert / auth.php
Created April 4, 2012 19:03
Authenticate via HTTP against WordPress user database
<?php
//Force SSL so that passwords aren't sent in the clear.
if($_SERVER["HTTPS"] != "on") {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
exit();
}
//Here's where the Wordpress magic happens.