Skip to content

Instantly share code, notes, and snippets.

View hsleonis's full-sized avatar
🏝️
Travellers unite.

Hasan Shahriar hsleonis

🏝️
Travellers unite.
View GitHub Profile
@hsleonis
hsleonis / image-resize.php
Created April 25, 2016 05:59
Resize images with PHP
<?php
/**
* Resize image class will allow you to resize an image
*
* Can resize to exact size
* Max width size while keep aspect ratio
* Max height size while keep aspect ratio
* Automatic while keep aspect ratio
*/
class ResizeImage
@hsleonis
hsleonis / google-map-marker.html
Created April 20, 2016 10:34
Google map markers
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>
<script type='text/javascript'>
// <![CDATA[
var Mymap;
var geocoder;
var Latlng;
var Options;
var image;
var cx = 0;
var cy = 0;
@hsleonis
hsleonis / natural-image-size.js
Created April 10, 2016 09:31
Image natural size
/**
* Solution for unsupported browsers (create dummy image to get real dimensions):
*/
function realImgDimension(img) {
var i = new Image();
i.src = img.src;
return {
naturalWidth: i.width,
naturalHeight: i.height
@hsleonis
hsleonis / scroll-snap-html.css
Created April 10, 2016 07:08
Scroll snapping image gallery with CSS
/**
Reference:
Theory: https://webkit.org/blog/4017/scroll-snapping-with-css-snap-points
Examples: https://webkit.org/demos/scroll-snap
plunker: https://plnkr.co/edit/gTxGcEanBRjl7badrjBS
*/
.parent{
-webkit-scroll-snap-type: mandatory;
-webkit-scroll-snap-points-x: repeat(100%);
}
@hsleonis
hsleonis / google-map-custom.js
Created April 10, 2016 03:50
Custom grey colored Google Map
function initialize() {
var map, map2;
var styleArray = [
{
featureType: "all",
stylers: [
{ saturation: -80 }
]
},{
@hsleonis
hsleonis / ng-watch-model.js
Created April 6, 2016 07:54
Angular watch input value
// <input ng-model='pat' ng-pattern='false' />
$scope.name='';
$scope.$watch('name', function() {
$scope.name = $scope.name.toLowercase();
});
@hsleonis
hsleonis / ng-model-directive.js
Created April 6, 2016 07:37
Filters on ng-model in an input
// <input ng-model="sth" ng-trim="false" custom-validation>
app.directive('customValidation', function(){
return {
require: 'ngModel',
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function (inputValue) {
var transformedInput = inputValue.toLowerCase().replace(/ /g, '');
@hsleonis
hsleonis / page-meta.html
Created April 6, 2016 07:35
The <meta> tag provides metadata about the HTML document
Ref.: http://www.w3schools.com/tags/tag_meta.asp
<!-- for Google -->
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="generator" content="" />
<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="application-name" content="" />
@hsleonis
hsleonis / google-doc-viewer.html
Last active February 1, 2024 14:18
Google Doc Viewer Iframe at any website
<!--
Parameters:
url: document url (encode the url if it containes parameters, etc.), must be publicly available
hl: language (ex: en, ar, bn etc.)
embedded: embededable link, value true/false [MUST be used true to show]
-->
<iframe src="https://docs.google.com/viewerng/viewer?url=http://show.pdf&hl=bn&embedded=true"></iframe>
@hsleonis
hsleonis / php-curl.php
Last active April 4, 2016 09:50
CURL is a command line tool for getting or sending files using URL syntax
<?php
// Ref.: http://php.net/manual/en/function.curl-getinfo.php
// http://www.hackingwithphp.com/15/10/2/your-first-curl-scripts
//step1
$cSession = curl_init();
//step2
curl_setopt($cSession,CURLOPT_URL,"http://www.google.com/search?q=curl");
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false);
//step3