Skip to content

Instantly share code, notes, and snippets.

@daif
daif / file_cache_contents.php
Created January 4, 2017 16:50
Tiny Cache system
<?php
//Tiny Cache system
function file_cache_contents($url, $cache_time=360000) { // 60*60*5
$cache_dir = __DIR__.'/cache/';
$cache_file = $cache_dir.md5($url).'.cache';
@mkdir($cache_dir, 0775, true);
// return data from cached file if file exists and not expired
if(file_exists($cache_file) && filemtime($cache_file)+$cache_time >= time()) {
return(unserialize(file_get_contents($cache_file)));
}
@daif
daif / file_search.php
Last active February 12, 2017 22:06
search in text file
<?php
// script startup time and memory usage
$mem_usage = memory_get_usage();
$time_usage = microtime(true);
$return = 'FALSE';
$password = '070162';
// get password list file from https://github.com/danielmiessler/SecLists/tree/master/Passwords
/* don't touch the above lines */
/* ------------------------------------------------------------------- */
@daif
daif / imagehash.php
Last active September 30, 2017 09:59
a simple image hashing algorithm
<?php
function imageHash($image_file) {
// check if the file is existed and is readable
if(file_exists($image_file) && is_readable($image_file)) {
return false;
}
// get image dimensions
list($width, $height) = getimagesize($image_file);
<?php
// set your database path
$firebase = 'https://myrealtimedb.firebaseio.com/';
// Update or Save to fireBase
$data = FireBaseJson('PUT','MyContentPath', 'MyContentData');
print_r($data);
// Get from fireBase
$data = FireBaseJson('GET', 'MyContentPath');
@daif
daif / iban.php
Created February 21, 2019 13:54
Check IBAN number
<?php
/**
* Value should be an IBAN number
*
*
* @param string
* @return bool
*/
function iban($str)
{
@daif
daif / erpnext-installer.sh
Created November 10, 2019 08:00
ERPNext installer
#!/bin/bash
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@daif
daif / lamp-ubuntu-18-04.sh
Created December 8, 2019 08:07
LAMP installer
#!/bin/bash
# Copyright (C) 2019 Daif Alazmi
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@daif
daif / metabase-installer.sh
Created March 21, 2020 11:42
MetaBase 0.34.3 installer
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@daif
daif / BinarySearch.php
Created May 2, 2020 01:54
Implementation of binary search in PHP
<?php
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BinarySearch.phps 0.1
* Implementation of binary search in PHP
* by Daif Alazmi (http://daif.net)
@daif
daif / mysql-backup.sh
Created May 15, 2020 12:59
MySQL backup tool
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the