This file contains 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 | |
namespace App\Helpers; | |
/* | |
* Access the US States in a format of your choosing by simply calling: | |
* UsStates::getStates(array $format, bool $stateAllCaps, bool $includeTerritories) | |
* check the getStates method below for more details on how to format | |
*/ | |
class UsStates | |
{ | |
public static $usStates = [ |
This file contains 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
// This syntax reflects changes made to the Swift language as of Aug. '16 | |
extension UIView { | |
// Example use: myView.addBorder(toSide: .Left, withColor: UIColor.redColor().CGColor, andThickness: 1.0) | |
enum ViewSide { | |
case Left, Right, Top, Bottom | |
} | |
This file contains 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
function newlaravel | |
{ | |
# Modify to suit your own system | |
YAML=/home/users/Nathan/Homestead.yaml | |
PROJECTSDIR="/media/nathan/Secondary Storage/Github" | |
HOMESTEADDIR="/media/nathan/Secondary Storage/Github" | |
HOSTFILE=/etc/hosts | |
PROJECTNAME=$1 | |
# |
This file contains 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
// Do you often find yourself writing lines of code that look like this? | |
// let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController") as! ViewController | |
// Here's a simpler way, using generics and Swift type-casting (as long as the viewcontroller's storyboard identifier is its class name). | |
// Now you can write: let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController() as ViewController | |
extension UIStoryboard { | |
func instantiateViewController<T: UIViewController>() -> T { | |
guard let vc = instantiateViewControllerWithIdentifier(String(T)) as? T else { | |
fatalError("Could not locate viewcontroller with with identifier \(String(T)) in storyboard.") | |
} |
This file contains 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
# Sleep 5 tries to avoid Heroku truncating the output by terminating the connection before everything has transferred. | |
# Dump structure.sql as heroku_structure.sql | |
heroku run 'bundle exec rake db:structure:dump && cat db/structure.sql && sleep 5' --app app-name > db/heroku_structure.sql | |
# Dump schema.rb as heroku_schema.db | |
heroku run 'bundle exec rake db:schema:dump && cat db/schema.rb && sleep 5' --app app-name > db/heroku_schema.rb |
This file contains 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
// Responsive interpolation mixin, great for making resposive text, but can work on anything. | |
@mixin interpolate($elements, $min-size, $max-size, $precision: 10, $property: 'font-size', $unit: 'rem', $min-width: 360, $max-width: 960){ | |
$increment: ($max-size - $min-size)/$precision; | |
@for $i from $precision through 0{ | |
@if $i == $precision{ | |
#{$elements}{ | |
#{$property}: #{$max-size - $i * $increment}#{$unit}; | |
} | |
} @else { | |
@media only screen and (min-width: #{$max-width - $i * ($max-width - $min-width)/$precision}px) { |
This file contains 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
(function( $ ) { | |
$.fn.photoswipe = function(options){ | |
var galleries = [], | |
_options = options; | |
var init = function($this){ | |
galleries = []; | |
$this.each(function(i, gallery){ | |
galleries.push({ | |
id: i, |
Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.
They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).
You will want to create an index.html
file and copy/paste the contents of 1-base.html
and then create a scripts.js
file and copy/paste the contents of one of the examples into it.
NewerOlder