This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateStates < ActiveRecord::Migration | |
def change | |
create_table :states do |t| | |
t.string :name | |
t.string :abbrev | |
t.timestamps | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should select all cells and go back" do | |
wait 0.5 do #Wait for the view to load | |
ips = [] | |
([email protected]_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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Here's the same thing in Objective-C | |
#import "WebView.h" | |
@implementation WebView | |
@synthesize webView = _webView; | |
-(void) viewDidLoad | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Create new instance of phpQuery with the poorly formatted HTML string | |
phpQuery::newDocument($document_html_string); | |
$my_data = array(); //Init array for holding the records | |
foreach(pq("#main table tr") as $block) { | |
//Get the key/value by selecting the table header element. | |
//We namespace it to the current block so we don't | |
// get _all_ the page's TH elements. | |
$key = pq('th', $block)->text(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Get the HTML string from cURL | |
//Create new instance of phpQuery | |
//We assume the phpoQuery library is included at the top or your script. | |
phpQuery::newDocument($document_html_string); | |
$inputs = array(); //Create an empty array to hold the inputs. | |
//Get all the inputs on the page and put them in an array. | |
foreach(pq(':input') as $id => $block) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Example implementation | |
*/ | |
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation | |
{ | |
NSLog(@"Launched with URL: %@", url.absoluteString); | |
NSDictionary *userDict = [self urlPathToDictionary:url.absoluteString]; | |