Skip to content

Instantly share code, notes, and snippets.

<?php
check_malicious_upload();
function check_malicious_upload() {
$user_uploads = fetch_uploads();
foreach ($user_uploads as $key => $value) {
@kezenwa
kezenwa / indexeddbstorage.js
Created July 1, 2024 07:55 — forked from xnohat/indexeddbstorage.js
sync wrapper for IndexedDB to same localStorage API, working extractly same as localStorage, just replace localStorage to idbStorage
class IndexedDBStorage {
constructor(dbName = 'localStorageDB', storeName = 'localStorageStore') {
this.dbName = dbName;
this.storeName = storeName;
this._init();
this.cache = {};
}
_init() {
const request = window.indexedDB.open(this.dbName, 1);
@kezenwa
kezenwa / ActiveYouTubeURLFormats.txt
Created December 9, 2023 06:17 — forked from rodrigoborgesdeoliveira/ActiveYouTubeURLFormats.txt
Example of the YouTube videos URL formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://youtube.com/watch?v=-wtIMTCHWuI
http://m.youtube.com/watch?v=-wtIMTCHWuI
https://www.youtube.com/watch?v=lalOy8Mbfdc
https://youtube.com/watch?v=lalOy8Mbfdc
https://m.youtube.com/watch?v=lalOy8Mbfdc
http://www.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://m.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
var striptags = require('striptags')
function smartExcerpt (string) {
var re = /(^.*?[a-zA-Z0-9\)\”\"]{2,}[.!?])[\s\”\"]+\W*[A-Z]/
var matches = striptags(string).match(re)
return matches && matches[1] ? matches[1] : string
}
@kezenwa
kezenwa / stats.sh
Created May 3, 2023 19:24 — forked from egulhan/stats.sh
echos memory, disk and cpu usage
printf "Memory\t\tDisk\t\tCPU\n"
MEMORY=$(free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }')
DISK=$(df -h | awk '$NF=="/"{printf "%s\t\t", $5}')
CPU=$(top -bn1 | grep load | awk '{printf "%.2f%%\t\t\n", $(NF-2)}')
echo "$MEMORY\t$DISK\t$CPU"
@kezenwa
kezenwa / mime-types.php
Created May 3, 2023 19:24 — forked from egulhan/mime-types.php
Learn mime-types from extension name and vice-versa in PHP
<?php
/*
* @source http://stackoverflow.com/questions/1147931/how-do-i-determine-the-extensions-associated-with-a-mime-type-in-php
*/
function system_extension_mime_types() {
# Returns the system MIME type mapping of extensions to MIME types, as defined in /etc/mime.types.
$out = array();
$file = fopen('/etc/mime.types', 'r');
@kezenwa
kezenwa / cpuUsageInPercent.sh
Created May 3, 2023 19:23 — forked from egulhan/cpuUsageInPercent.sh
How to get CPU usage in percent on Linux
top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}'
@kezenwa
kezenwa / ftp-backup.pl
Created April 3, 2023 05:50 — forked from ZEROF/ftp-backup.pl
FTP Perl backup script for Debian 7
#!/usr/bin/perl -w
# ORGINAL FTP BACKUP SCRIPT V1.00
# Version 1.01 2nd hand coded BY ZEROF <zerof at backbox.org>
# This script was updated because some providers support only FTP passive mode (like online.net)
# And I needed Debian support as well (replaced path of gzip)
# SFTP support didn't work, need few lines of new code I guess, I didn't spend to much time on that part
# i just disabled, for now. If you have idea about fixing this, keep me posted.
# Is this best solution you will find? Nop, find some more secured scipt like duplicity
# COPYRIGHT 2013 - WEBHOSTINGHERO.COM
@kezenwa
kezenwa / amp-converter.php
Created October 3, 2022 06:27 — forked from williankeller/amp-converter.php
Convert HTML to AMP
<?php
class AMP {
private $html;
/**
* HtmlToAmp constructor.
*/
public function __construct($htmlContent) {
@kezenwa
kezenwa / ampify.php
Created October 3, 2022 06:26 — forked from adactio/ampify.php
Make a chunk of markup AMP-ready
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
function ampify($html='') {
# Replace img, audio, and video elements with amp custom elements
$html = str_ireplace(
['<img','<video','/video>','<audio','/audio>'],