Skip to content

Instantly share code, notes, and snippets.

View ninthspace's full-sized avatar

Chris Aves ninthspace

View GitHub Profile
@ninthspace
ninthspace / server.badbots
Last active June 9, 2021 08:42 — forked from hans2103/server.badbots
NGINX to block bad bots. (add Twenga|TwengaBot if you want to exclude them too)
if ($http_user_agent ~* (360Spider|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|discobot|DISCo|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearchSpider|ExpertSearch|Express\ WebPictures|ExtractorPro|extract|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|Genieo|genieo|GetRight|GetWeb\!|GigablastOpenSource|GozaikBot|Go\!Zilla|Go\-Ahead\-Got\-It|GrabNet|grab|Grafula|GrapeshotCrawler|GTB5|GT\:\:WWW|Guzz
@ninthspace
ninthspace / Controller.php
Last active April 15, 2021 17:19
Time travel with Dusk without pesky JavaScript
<?php
// update Controller.php as follows
namespace App\Http\Controllers;
use App\Services\TimeTravel;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
@ninthspace
ninthspace / php.yml
Created May 16, 2020 15:48
Tests and Code Coverage with GitHub Actions
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
tests:
@ninthspace
ninthspace / gist:4360267
Last active November 9, 2018 12:03
How I migrated from rbenv to chruby, and kept per-project gems nice and tidy.

Remove rbenv and any rubies, gems etc.:

$ rm -rf ~/.rbenv

Uninstall rbenv if installed via Homebrew

$ brew uninstall rbenv

Remove references to rbenv in ~/.bash_profile etc.

@ninthspace
ninthspace / deleteCompletedTasks.m
Created May 19, 2012 16:59
Deleting tasks, with optional confirmation
- (void)deleteCompletedTasksWithConfirmation:(id)sender {
if ([[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%d", AlistoPrefKeyConfirmDeletion]]) {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Delete completed tasks?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete tasks" otherButtonTitles:nil];
[sheet showFromToolbar:[[self navigationController] toolbar]];
} else {
[self deleteCompletedTasks];
}
}
@ninthspace
ninthspace / cellForRowAtIndexPath.m
Created May 19, 2012 15:59
Choosing between XIBs
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TaskItem *task = [fetchedResultsController objectAtIndexPath:indexPath];
TaskItemCell *cell;
// check display settings
if ([[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%d", AlistoPrefKeyTypeShowTaskNumbers]]) {
cell = [tableView dequeueReusableCellWithIdentifier:@"TaskItemCellWithID"];
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"TaskItemCell"];
@ninthspace
ninthspace / setWithTaskItem.m
Created May 19, 2012 15:57
Setting the content of a UITableViewCell
- (void)setWithTaskItem:(TaskItem *)task {
// set the text which displays the title of the task
NSString *text = [task title];
UILabel *titleLabel = [self taskTitleLabel];
[titleLabel setText:text];
// create a checkbox appropriately set according whether the task is completed or not
NSString *completedString = @"";
@ninthspace
ninthspace / SettingsViewController.h
Created May 18, 2012 16:13
SettingsViewController
#import <UIKit/UIKit.h>
@interface SettingsViewController : UITableViewController
typedef enum {
AlistoPrefKeyTypeShowTaskNumbers = 0,
AlistoPrefKeyConfirmDeletion = 1
} AlistoPrefKeyType;
@property (nonatomic, retain) IBOutlet UITableViewCell *showTaskNumbersCell;
@ninthspace
ninthspace / MyStoreClass.m
Created May 11, 2012 16:21
Hooking up a NSFetchedResultsController
+ (NSFetchedResultsController *)fetchedResultsController:(id <NSFetchedResultsControllerDelegate>)delegate {
NSManagedObjectContext *context = [CACoreData sharedManagedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"MyModel" inManagedObjectContext:context]];
// must have a sort key
NSSortDescriptor *anySortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"someSortKey" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObjects:anySortDescriptor, nil]];
@ninthspace
ninthspace / CACoreData.h
Created May 11, 2012 15:38
Class for generating singleton Core Data artifacts
//
// CACoreData.h
// Alisto
//
// Created by Chris Aves on 09/05/2012.
// Copyright (c) 2012 Junctionbox Media. All rights reserved.
//
#import <Foundation/Foundation.h>