This file contains hidden or 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
#if canImport(UIKit) | |
import UIKit | |
extension UIColor { | |
static var random: UIColor { | |
return UIColor( | |
red: .random(in: 0...1), | |
green: .random(in: 0...1), | |
blue: .random(in: 0...1) | |
) |
This file contains hidden or 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 | |
/** | |
* Created by PhpStorm. | |
* User: hafiq | |
* Date: 28/02/2018 | |
* Time: 9:30 AM | |
*/ | |
namespace App\Library; |
This file contains hidden or 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
func saveImage(image: UIImage, name:String) { | |
let req = NSMutableURLRequest(url: NSURL(string:"http://127.0.0.1:3001/")! as URL) | |
let ses = URLSession.shared | |
req.httpMethod="POST" | |
req.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type") | |
req.setValue(name, forHTTPHeaderField: "X-FileName") | |
let jpgData = UIImageJPEGRepresentation(image, 1.0) | |
req.httpBodyStream = InputStream(data: jpgData!) | |
let task = ses.uploadTask(withStreamedRequest: req as URLRequest) | |
task.resume() |
This file contains hidden or 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 | |
if (! function_exists('store_file')) { | |
/** | |
* @param $file | |
* @param string $disk | |
* @param bool $add_time | |
* @param bool $replace_space | |
* @param null $prefix |
This file contains hidden or 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
// MIT License | |
// | |
// Copyright (c) 2017 Dariusz Rybicki Darrarski | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
In this tutorial you'll learn how to run a Vapor server in a Docker container on Heroku.
Recently, Heroku added the ability to run Docker images on their Runtime. You can use this system instead of the traditional buildpack-based system for various reasons, mainly for having more control over the environment your server will run on.
To complete this tutorial, you'll need:
This file contains hidden or 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 // /app/Http/Middleware/Cors.php | |
namespace App\Http\Middleware; | |
use Closure; | |
class Cors { | |
public function handle($request, Closure $next) | |
{ | |
return $next($request) |
This file contains hidden or 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
//Protocal that copyable class should conform | |
protocol Copying { | |
init(original: Self) | |
} | |
//Concrete class extension | |
extension Copying { | |
func copy() -> Self { | |
return Self.init(original: self) | |
} |
NewerOlder