First, Lets find out what version of PHP we're running (To find out if it's the default version).
To do that, Within the terminal, Fire this command:
which php
// https://github.com/onevcat/Kingfisher/wiki/Installation-Guide | |
// https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet | |
import UIKit | |
import Kingfisher | |
class example { | |
func viewDidLoad { | |
// Apply KingFisher | |
let resource = ImageResource(downloadURL: imgUrl!) |
// Missing Field Key thì thêm ? | |
struct CourseMisingFied: Decodable { | |
let id: Int? | |
let name: String? | |
let link: String? | |
let imageUrl: String? | |
} |
let url = URL(string: "https://jsonplaceholder.typicode.com/posts")! | |
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in | |
guard let data = data else { return } | |
print(String(data: data, encoding: .utf8)!) | |
} | |
task.resume() |
let queue = DispatchQueue(label: "queue_action_1") | |
queue.async { | |
for i in 1...5 { | |
print("async=" + String(i)) | |
} | |
} | |
for i in 1...5 { | |
print("sync=" + String(i)) | |
} |
extension UIImageView { | |
/// Loads image from web asynchronosly and caches it, in case you have to load url | |
/// again, it will be loaded from cache if available | |
func load(url: URL, placeholder: UIImage?, cache: URLCache? = nil) { | |
let cache = cache ?? URLCache.shared | |
let request = URLRequest(url: url) | |
if let data = cache.cachedResponse(for: request)?.data, let image = UIImage(data: data) { | |
self.image = image | |
} else { | |
self.image = placeholder |
import sys | |
import MySQLdb | |
import hashlib | |
from datetime import datetime | |
from scrapy.exceptions import DropItem | |
from scrapy.http import Request | |
class EmptyItemPipeline(object): | |
def process_item(self, item, spider): |
// based on ggwarpig stackoverflow anwser to | |
// "Where do I find the Instagram media ID of a image" | |
// @ https://stackoverflow.com/a/37246231 | |
function instagram_id_to_url($instagram_id){ | |
$url_prefix = "https://www.instagram.com/p/"; | |
if(!empty(strpos($instagram_id, '_'))){ |
<?php | |
function convertAll($str) { | |
$regex = "/[@#](\w+)/"; | |
$hrefs = [ | |
'#' => 'hashtag?tag', | |
'@' => 'profile?username' | |
]; | |
$result = preg_replace_callback($regex, function($matches) use ($hrefs) { |
brew install autoconf | |
php -m | |
php -v | |
which php | |
pecl install mongodb | |
Check Folder | |
/Applications/MAMP/bin/php/php7.0.15/lib/php/extension/no-debug-non-zts | |
update template php.ini to add ext | |
extension=mongodb.so |