Skip to content

Instantly share code, notes, and snippets.

View jellybeansoup's full-sized avatar

Daniel Farrelly jellybeansoup

View GitHub Profile
@jellybeansoup
jellybeansoup / wordpress.sh
Created March 25, 2014 14:46
A shell script for easily setting up a Wordpress dev environment.
#!/bin/sh
# We need an install path
if [ $# != 1 ]; then
echo "Usage: wordpress.sh <install-path>"
exit 1
fi
# Fix the path if it's relative
given_path=$1
@jellybeansoup
jellybeansoup / arrangeSubviews.m
Last active August 29, 2015 14:01
Eat my shorts, auto layout.
#pragma mark - Rearrange the subviews
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
[self arrangeSubviews];
}
- (void)arrangeSubviews {
// Cover image frame
@jellybeansoup
jellybeansoup / gist:9051a033e7b7929d2a70
Created July 5, 2014 00:43
My "fix" for the stuck grey buttons thing.
#pragma mark - Action sheet delegate
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
for( UIView *subview in actionSheet.subviews ) {
if( [subview isKindOfClass:[UIButton class]] ) {
UIButton *button = (UIButton *)subview;
[button setTitleColor:[UIColor mainTintColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor mainTintColor] forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor mainTintColor] forState:UIControlStateSelected];
}
@jellybeansoup
jellybeansoup / new.m
Last active August 29, 2015 14:06
Grid cell size calculator.
// Get the view's actual pixel width
CGFloat pixelWidth = self.collectionView.frame.size.width * UIScreen.mainScreen.scale;
// Maximum cells per row
CGFloat maxCells = ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) ? 10.0 : 5.0;
// Determine a cell width
CGFloat cellWidth = 0.0;
CGFloat cellSpacing = 2.0;
for( CGFloat i = cellSpacing; i <= 4; i++ ) {
#pragma mark - View life cycle
- (void)viewDidLoad {
[super viewDidLoad];
[_collectionView registerClass:[JSMRefreshViewCell class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"SearchViewRefresh"];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
// If we have more results to fetch
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "StaticTables.h"
@interface StaticTablesDataSourceTests : XCTestCase
@end
@implementation StaticTablesDataSourceTests
@jellybeansoup
jellybeansoup / example.json
Last active September 6, 2015 00:08
Example JSON for Mobile Couch e65
[
{
"key": "jellyandbean",
"title": "Jelly and Bean",
"tagline": "A weekly podcast about TV, movies, games and technology.",
"description": "Do you like tech? Games? TV? Movies? Well DANG. We have so much in common already! Jelly and Bean are two super pals who like to talk about all of the aforementioned topics (and more, probably), resulting in a nice little peek into the world of geeks, all in the form of a delicious weekly podcast that can be shoved into your ears thanks to the magic of sound waves!",
"archived": true,
"explicit": false,
"keywords": [
"jelly n bean",

Keybase proof

I hereby claim:

  • I am jellybeansoup on github.
  • I am jellybeansoup (https://keybase.io/jellybeansoup) on keybase.
  • I have a public key whose fingerprint is EEC8 CE91 DF6B 324F C28D ACAA E53E 0BCA FCDB 7881

To claim this, I am signing this object:

@jellybeansoup
jellybeansoup / OpenWithCleanup.sh
Created May 28, 2013 06:16
A shell script to remove duplicates in the "Open With" menu in OS X 10.5 and later.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
@jellybeansoup
jellybeansoup / TextViewDidChangeSelection.swift
Created August 15, 2017 05:39
textViewDidChangeSelection(_:)
// Exists inside of a scrollview subclass containing an "expanding" textview that lives underneath other content.
private var previousSelection: CGRect?
func textViewDidChangeSelection(_ textView: UITextView) {
guard textView.isFirstResponder else {
return
}
var selection = textView.layoutManager.boundingRect(forGlyphRange: textView.selectedRange, in: textView.textContainer).offsetBy(dx: insets.left, dy: insets.top)