open -a TextEdit filename
Then go download Notepad from the Mac App Store because TextEdit kind of sucks.
Dev Notebook
open -a TextEdit filename
Then go download Notepad from the Mac App Store because TextEdit kind of sucks.
In your UIPopoverPresentationControllerDelegate:
func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { let presentedViewController = controller.presentedViewController let navigationController = UINavigationController(rootViewController: presentedViewController) let dismissButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "dismissPopover:") presentedViewController.navigationItem.rightBarButtonItem = dismissButton return navigationController } func dismissPopover(sender: AnyObject) { self.dismissViewControllerAnimated(true, completion: nil) }
When you get the error App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file., you can override the security and allow all http urls through by adding this to your info.plist file:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key><true> </true></dict>
However, before doing this, check to see if there is an https version of the url. That will work just as well, and https won’t throw that error.
Here is a helper function that handles user input. You can just plop all this in a file called HelperFunctions.swift
.
/* This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, by Yong Bakos. */ import Foundation // Wait for the user to type something in the console, and return what // they type as a String with the trailing newline character removed. func getln() -> String { let stdin = NSFileHandle.fileHandleWithStandardInput() var input = NSString(data: stdin.availableData, encoding: NSUTF8StringEncoding) input = input!.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet()) return input as! String }
If you have an NSDate object from a UIDatePicker and you want to display it formatted:
let dateFormatter = NSDateFormatter() dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle myDateLabel.text = dateFormatter.stringFromDate(myDatePicker.date)
Remember whenever you create a new Seeder class, to run composer dump-autoload
so the framework can find it!
(function() { alert('Hello World'); })();
A new Laravel 5 installation comes with user registration out of the box. If you don’t want to use this feature, here is a clean way to disable it. Open up app\Http\Controllers\Auth\AuthController.php and add the following methods:
public function getRegister() { return redirect('auth/login'); // Or wherever } public function postRegister() { }
These will override the parent methods in the AuthenticatesAndRegistersUsers trait.
To have laravel automatically generate all the REST routes for a controller, use Route::resource()
Route::resource('users', 'UsersController');
Here’s an example of how to use form-model binding with FormBuilder.
{!! Form::model($user, ['route' => ['users.update', $user->id], 'method' => 'PATCH']) !!}