This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-------------------------------------------------+ | |
| Flattens FQL (Facebook Query Language) results in | |
| a good format | |
+-------------------------------------------------*/ | |
function flattenFQL($array) { | |
if (!is_array($array)) { | |
return $array; | |
} | |
$result = array(); | |
foreach ($array as $data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Picks one random jpg/jpeg/png format image from the specified directory. | |
* @param string $dir Images directory path. | |
* @param boolean $realPath True to return real path of the image. | |
* @return string Path to one random image. | |
*/ | |
function getRandomImg ( $dir, $realPath = false ) { | |
$dir = rtrim($dir, '/'); // Just in case if there is any trailing slash. | |
$images = glob($dir . '/*.{jpg,jpeg,png}', GLOB_BRACE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# (The MIT License) | |
# | |
# Copyright (c) 2013 M.S. Babaei | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function contains($str, $content, $ignorecase=true) { | |
if ($ignorecase){ | |
$str = strtolower($str); | |
$content = strtolower($content); | |
} | |
return strpos($content,$str) ? true : false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ============================================================ | |
| :=Stop Window Refresh | |
=============================================================== */ | |
function stopRefresh() { | |
if (window.myRefresh && window.clearTimeout) window.clearTimeout(myRefresh); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Function: check for valid email input */ | |
function checkEmail($string) { | |
$string = preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $string); | |
if(!$string){ | |
echo "Email Address is Invalid,please check and enter your email address again eg: email@domain.com."; | |
} | |
return $string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getGooglAuthToken = function(b){ | |
var c = function(){ | |
for (var l=0, m=0, ml=arguments.length; m<ml; m++) l = l + arguments[m] & 4294967295; | |
return l; | |
} | |
var d = function(l){ | |
l = String(l > 0 ? l : l + 4294967296); | |
var m = l; | |
for (var o=0, n=false, p=m.length-1; p>=0; --p){ | |
var q = Number(m.charAt(p)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; | |
var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | |
var is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1; | |
if(is_chrome) { | |
alert("This message is for Chrome Users!"); | |
} else if(is_firefox) { | |
alert("This message is for Firefox Users!"); | |
} else if(is_opera) { | |
alert("This message is for Opera Users!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-------------------------------------------------+ | |
| Get server status based on URL or IP | |
+-------------------------------------------------*/ | |
function getServerStatus($serverUrl) { | |
$ping = @fsockopen ($serverUrl, 80, $errno, $errstr, 10); | |
if (!$ping) { | |
return 'Server is DOWN :('; | |
} else { | |
@fclose($ping); | |
return 'Server is UP :)'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Command to empty Trash with 35-pass security method. This is the most secure deletion, | |
# so you will not be able to recover any file deleted with this method. | |
# Replace <MAC_USER> with your Mac username. | |
## | |
srm -rfv /Users/<MAC_USER>/.Trash/* | |
## | |
# Command to empty Trash with 7-pass security method that meets the |