Skip to content

Instantly share code, notes, and snippets.

View fmtarif's full-sized avatar

Faisal Muhammad fmtarif

View GitHub Profile
@fmtarif
fmtarif / gist:8399309
Created January 13, 2014 12:15
js filter() to get unique array values
var cats = ['tech','politics','tech','politics','spirituality'];
cats.filter(function(v,i){return cats.indexOf(v) == i}) // will return ["tech", "politics", "spirituality"]
@fmtarif
fmtarif / gist:9189366
Last active August 29, 2015 13:56
parse html as php
AddType application/x-httpd-php .html
# Some server would require the following
#AddHandler php-script .html
@fmtarif
fmtarif / browse.html
Created February 27, 2014 09:09
file should go in htdocs/
<!doctype html>
<html>
<head>
<style>
iframe { position: fixed; border: none; height: 100%; top: 0; }
</style>
<!--<script src="jquery.js"></script>-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(window).load(function(){
@fmtarif
fmtarif / strip array
Created March 6, 2014 06:58
#php - shortest recursive array processor
if (get_magic_quotes_gpc()) {
function strip_array($var) {
return is_array($var)? array_map("strip_array", $var):stripslashes($var);
}
$_POST = strip_array($_POST);
$_SESSION = strip_array($_SESSION);
$_GET = strip_array($_GET);
}
@fmtarif
fmtarif / override cache php
Created March 30, 2014 06:47
#php - override cache php
<?php
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
@fmtarif
fmtarif / gist:11244153
Last active December 1, 2019 18:10
#mysql - MySQL common fields/columns type and size
# http://stackoverflow.com/questions/354763/common-mysql-fields-and-their-appropriate-data-types
INT(11) for anything that is either an ID or references another ID
DATETIME for time stamps
VARCHAR(255) for anything guaranteed to be under 255 characters (page titles, names, etc)
TEXT for pretty much everything else.
VARCHAR(255) for emails
TIMESTAMP for dates, tracking creation or changes
DECIMAL(3,2) (unsigned) for 5-star rating value
@fmtarif
fmtarif / wp-config.php
Last active November 16, 2020 23:00
#wp wordpress config file boilerplate
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
<?php
// PHP Logical operators: The difference between OR vs ||, AND vs &&
// Key concept #1: "||" and "&&" have greater precedence than "=", "OR", "AND"
// http://php.net/manual/en/language.operators.precedence.php
// Key concept #2: PHP logical operators are short-circuit
// http://en.wikipedia.org/wiki/Short-circuit_evaluation
// http://php.net/manual/en/language.operators.logical.php
@fmtarif
fmtarif / gist:11380420
Last active August 29, 2015 14:00
#php - useful short circuits
<?php
mysql_connect(localhost,$user,$password) or die( “Unable to connect”);
/*
if ($from && $to && $msg) {
sendMail();
}
*/
$from && $to && $msg && sendMail();
@fmtarif
fmtarif / backup-cleanup.sh
Created April 29, 2014 07:28
#linux #sysadmin backup scripts
#!/bin/bash
#start
#-----------------------------------------------------------------------
find /srv/backup/daily/databases/ -name '*.gz' -mtime +7 | xargs rm -f;
find /srv/backup/daily/websites/ -name '*.gz' -mtime +7 | xargs rm -f;
# Are Weekly Backups Implemented?
# find /srv/backup/weekly/ -name '*.gz' -mtime +30 | xargs rm -f;
#-----------------------------------------------------------------------
#end