Skip to content

Instantly share code, notes, and snippets.

@zahedkamal87
zahedkamal87 / .block
Created September 24, 2022 13:50 — forked from d3noob/.block
Collapsible tree diagram in v4
license: mit
@zahedkamal87
zahedkamal87 / README.md
Created June 22, 2022 14:43 — forked from dsferruzza/README.md
Configure a memory_limit for scheduled tasks of a Laravel app on Clever Cloud

Problems

  • some of my Laravel's scheduled tasks fail because the default memory_limit of PHP is too low
  • running php -d memory_limit=xxx artisan schedule:run does not seem to have any effect
  • there is no way to provide a custom php.ini for CLI-only on Clever Cloud

Solution

This patch adds a simple way to set memory_limit using a CLI_MEMORY_LIMIT environment variable. This new setting only applies when the Laravel app is booted from CLI (like when running php artisan ... commands) and have no effect on the memory_limit value in web context.

@zahedkamal87
zahedkamal87 / test-memory-limit.php
Created June 22, 2022 14:43 — forked from thonixx/test-memory-limit.php
Test PHPs memory limit
<pre>
<?php
$megabyte = 1528; // define the max megabytes which should be tested
function tryAlloc($megabyte){
echo "try allocating {$megabyte} megabyte...";
$mb = $megabyte;
$dummy = str_repeat("-",1048576*$mb);
echo "pass.";
echo "Usage: " . memory_get_usage(true)/1048576;
@zahedkamal87
zahedkamal87 / jsonBinApi.js
Created April 23, 2022 19:56 — forked from laosb/jsonBinApi.js
Simple API wrapper for JSONBin.io.
import fetch from 'node-fetch'
const secretKey = process.env.JSONBIN_SECRET_KEY
const basicHeaders = () => ({
'Content-Type': 'application/json',
'X-Master-Key': secretKey,
})
export const createBin = async (
@zahedkamal87
zahedkamal87 / sketch.js
Created April 19, 2022 13:11 — forked from golanlevin/sketch.js
PoseNet skeletons with ml5.js & p5.js, using a pre-loaded video
// Copyright (c) 2018 ml5
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/* ===
ml5 Example
PoseNet example using p5.js
=== */
@zahedkamal87
zahedkamal87 / index.html
Created December 22, 2020 19:48 — forked from shiawuen/index.html
Sample to upload file by chunk
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>test upload by chunk</title>
</head>
<body>
<input type="file" id="f" />
<script src="script.js"></script>
function saveSelection() {
if (window.getSelection) {
var sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
return sel.getRangeAt(0);
}
} else if (document.selection && document.selection.createRange) {
return document.selection.createRange();
}
return null;
<?php
/**
* Get Vimeo video id from url
*
* Supported url formats -
*
* https://vimeo.com/11111111
* http://vimeo.com/11111111
@zahedkamal87
zahedkamal87 / youtube_id_regex.php
Created May 12, 2020 02:24 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@zahedkamal87
zahedkamal87 / gist:0f63e1663e930c1688545f3642272b01
Created April 11, 2020 06:43 — forked from samarpanda/gist:4125105
Test your php code execution time and Memory usage
<?php
// from http://php.net/manual/en/function.filesize.php
function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);