Skip to content

Instantly share code, notes, and snippets.

View cliftonlabrum's full-sized avatar

Clifton Labrum cliftonlabrum

View GitHub Profile
@cliftonlabrum
cliftonlabrum / gist:4590797
Last active December 11, 2015 10:59
Install Ruby, Passenger, and Apache on Digital Ocean
--- Install Ruby ---
rvm install ruby-1.9.3-p194
--- Install Passenger ---
gem install passenger
--- Install Apache Dependencies ---
* To install Apache 2:
sudo apt-get install apache2-mpm-prefork
@cliftonlabrum
cliftonlabrum / gist:4596018
Created January 22, 2013 16:25
Check for which ports are open on a machine (Mac computer, *nix server, etc.)
netstat –lp --inet
@cliftonlabrum
cliftonlabrum / gist:4626282
Created January 24, 2013 18:43
Remove log creation from local VirtualHost.sh script
If you have a ~/.virtualhost.sh.conf file with:
PROMPT_FOR_LOGS="no"
ALWAYS_CREATE_LOGS="no"
The virtualhost definition will not have any log files defined, and will default to the global access_log and error_log (in /var/log/apache2 by default on Mac OS X).
@cliftonlabrum
cliftonlabrum / gist:4696438
Created February 2, 2013 07:27
Do a database migration on a Rails production server.
rake RAILS_ENV=production db:migrate
@cliftonlabrum
cliftonlabrum / gist:4993012
Last active December 13, 2015 23:39
Objective-C Class for Multiple Colors and Fonts
//--- PPColor.m ---
@implementation PPColor
+ (UIColor *)grayColor {
return [UIColor colorWithRed:0.35 green:0.35 blue:0.35 alpha:1.0];
}
+ (UIColor *)darkGrayColor {
return [UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1.0];
@cliftonlabrum
cliftonlabrum / gist:5067512
Created March 1, 2013 20:28
Doing a Git Pull with a Rebase instead of a Merge
Pull with rebase instead of merge
$ git pull --rebase
# e.g. if on branch "master": performs a `git fetch origin`,
# then `git rebase origin/master`
Because branch merges in git are recorded with a merge commit, they are supposed to be meaningful—for example, to indicate when a feature has been merged to a release branch. However, during a regular daily workflow where several team members sync a single branch often, the timeline gets polluted with unnecessary micro-merges on regular git pull. Rebasing ensures that the commits are always re-applied so that the history stays linear.
You can configure certain branches to always do this without the --rebase flag:
@cliftonlabrum
cliftonlabrum / gist:5143626
Created March 12, 2013 15:02
Get a JS runtime for Rails on a Digital Ocean server
# Get a JavaScript runtime for Rails
sudo apt-get install nodejs
@cliftonlabrum
cliftonlabrum / gist:5143657
Created March 12, 2013 15:05
Grouped UITableView in Objective-C
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
@cliftonlabrum
cliftonlabrum / webkitTapHighlight.js
Created September 23, 2013 16:29
When you click on part of a webView that is either a link or otherwise made clickable with JS, the clickable area turns gray (touch any link in Safari on your iPhone to see this). I didn't want this to happen because I want my webView to behave like it's a native component. This will turn it off.
<script type="text/javascript">
document.documentElement.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
</script>
@cliftonlabrum
cliftonlabrum / dataToFromWebViewTitanium.js
Created September 23, 2013 16:32
Passing Data to a webView and back in Titanium.
//Send data to webView in Titanium
var timeGraph = Ti.UI.createWebView({ url:'graphs/timeGraph.html', touchEnabled:true });
timeGraph.addEventListener('load', function(){
Ti.App.fireEvent('graphCareer', series);
});
<!-- Receive data in webView -->
<script type="text/javascript">