Skip to content

Instantly share code, notes, and snippets.

View shyamsalimkumar's full-sized avatar

Shyam S Kumar shyamsalimkumar

  • Berlin
  • 09:54 (UTC +02:00)
View GitHub Profile
@shyamsalimkumar
shyamsalimkumar / gist:6729720
Created September 27, 2013 14:45
Heroku error
2013-09-27T14:33:22.580805+00:00 app[web.1]: hello
2013-09-27T14:33:23.013649+00:00 app[web.1]: Angular App Server - listening on p
ort: 14321
2013-09-27T14:34:23.045521+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2013-09-27T14:34:23.045966+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-27T14:34:24.288334+00:00 heroku[web.1]: Process exited with status 137
2013-09-27T14:34:24.306647+00:00 heroku[web.1]: State changed from starting to c
rashed
2013-09-27T14:30:26.852676+00:00 heroku[api]: Deploy f37f973 by shyam.salim.kuma
/*
html5doctor.com Reset Stylesheet
v1.6.1
Last Updated: 2010-09-17
Author: Richard Clark - http://richclarkdesign.com
Twitter: @rich_clark
*/
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude,
lon = position.coords.longitude;
console.log('Geolocation - Latitude: '+ lat +', Longitude: '+ lon);
});
}
else {
console.log('Geolocation is not supported for this Browser/OS version yet.');
}
@shyamsalimkumar
shyamsalimkumar / gist:5991195
Created July 13, 2013 16:11
Page Visibility API (code to check for page visibility)
document.addEventListener('visibilitychange', function(e) {
console.log('hidden:' + document.hidden,
'state:' + document.visibilityState)
}, false);
@shyamsalimkumar
shyamsalimkumar / gist:5752642
Last active December 18, 2015 08:19
PHP - Automatic mailto links
$pattern = "/([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i";
$replace = "\\1";
$text = preg_replace($pattern, $replace, $stringa);
echo htmlspecialchars($text);
@shyamsalimkumar
shyamsalimkumar / gist:5752640
Last active December 18, 2015 08:19
PHP - Watermark images automatically
function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$font = 'arial.ttf';
$font_size = 10;
imagettftext($image_p, $font_size, 0, 10, 20, $black, $font, $WaterMarkText);
if ($DestinationFile<>'') {
@shyamsalimkumar
shyamsalimkumar / gist:5752628
Last active December 18, 2015 08:19
PHP - Generate CSV file from a array
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
@shyamsalimkumar
shyamsalimkumar / gist:5752591
Last active July 26, 2019 22:38
HTML/JS Right Click Disable
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
});
</script>
@shyamsalimkumar
shyamsalimkumar / gist:5752563
Last active December 18, 2015 08:18
PHP - Get file extension
function getFileExtension($str)
{
$arrSegments = explode('.', $str); // may contain multiple dots
$strExtension = $arrSegments[count($arrSegments) - 1];
$strExtension = strtolower($strExtension);
return $strExtension;
}