TLDR: Use for...of
instead of forEach()
in asynchronous code.
For legacy browsers, use for(...;...;...)
or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
<?php | |
namespace App\Http\Controllers; | |
use App\Models\Project; | |
use Illuminate\Http\Request; | |
class ProjectController extends Controller | |
{ | |
public function update(Request $request, Project $project) |
upload(files) { | |
const config = { | |
onUploadProgress: function(progressEvent) { | |
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
console.log(percentCompleted) | |
} | |
} | |
let data = new FormData() | |
data.append('file', files[0]) |
# pylint: skip-file | |
import time | |
import re | |
import md5 | |
import requests | |
import json | |
INSTAGRAM_URL = "https://www.instagram.com" | |
HASHTAG_ENDPOINT = "/graphql/query/?query_hash={}&variables={}" |
using UnityEngine; | |
/// <summary> | |
/// Small helper class to convert viewport, screen or world positions to canvas space. | |
/// Only works with screen space canvases. | |
/// </summary> | |
/// <example> | |
/// <code> | |
/// objectOnCanvasRectTransform.anchoredPosition = specificCanvas.WorldToCanvasPoint(worldspaceTransform.position); | |
/// </code> |
This is a sample script for retrieving screen shots of sites using Google Apps Script. In order to retrieve the screen shot, here, I used PageSpeed API.
When you use this, please copy and paste the following script, and set an URL you want to retrieve a screen shot.
var siteUrl = "### URL you want to retrieve a screen shot. ###";
var url =
"https://www.googleapis.com/pagespeedonline/v4/runPagespeed?screenshot=true&fields=screenshot&url=" +
encodeURIComponent(siteUrl);
<?php | |
namespace App\Http\Controllers\Auth; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Foundation\Auth\AuthenticatesUsers; | |
use Illuminate\Http\Request; | |
class LoginController extends Controller | |
{ |
This is a simple instruction to use Tabler in your next Laravel project.
(Tabler is a beautiful dashboard: https://tabler.io/)
How to install:
gistfile1.txt
in your Laravel project.tabler.js
to recourses/js
.tabler.scss
to resources/sass
.webpack.mix.js
with your current webpack.mix.js
<?php | |
namespace App\Providers; | |
use Illuminate\Support\Facades\View; | |
use Illuminate\Support\ServiceProvider; | |
use Illuminate\View\Factory as ViewFactory; | |
class AppServiceProvider extends ServiceProvider | |
{ |
<?php | |
// use to generate key : 'openssl rand -hex 32' | |
function my_encrypt($data, $passphrase) { | |
$secret_key = hex2bin($passphrase); | |
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')); | |
$encrypted_64 = openssl_encrypt($data, 'aes-256-cbc', $secret_key, 0, $iv); | |
$iv_64 = base64_encode($iv); | |
$json = new stdClass(); | |
$json->iv = $iv_64; |