Skip to content

Instantly share code, notes, and snippets.

View fazlurr's full-sized avatar

Fazlur Rahman fazlurr

View GitHub Profile
@fazlurr
fazlurr / GMapV2Direction.java
Created March 5, 2014 03:57
Android Java Class for showing directions between origin location and destination location with Gmap V2 Direction.
import java.io.InputStream;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
@fazlurr
fazlurr / height.html
Created March 11, 2014 01:52
A quick, non-elegant but working standalone solution with inline CSS and no jQuery requirements. AFAIK it works from IE9 too. from : http://stackoverflow.com/questions/11868474/how-to-make-the-web-page-height-to-fit-screen-height
<body style="overflow:hidden; margin:0">
<form id="form1" runat="server">
<div id="main" style="background-color:red">
<div id="content">
</div>
<div id="footer">
</div>
</div>
@fazlurr
fazlurr / dabblet.css
Created March 11, 2014 02:10 — forked from LeaVerou/dabblet.css
(C)Leanest CSS spinner ever
/**
* (C)Leanest CSS spinner ever
*/
@keyframes spin {
to { transform: rotate(1turn); }
}
.progress {
position: relative;
@fazlurr
fazlurr / canvas-upload.php
Created March 27, 2014 07:20 — forked from xjamundx/canvas-upload.php
Function to save base64 image to png with PHP
<?php
// requires php5
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
@fazlurr
fazlurr / printProperty.js
Created April 2, 2014 11:18
Javascript function to show all object property
for (var key in items.images) {
var obj = items.images[key];
for (var prop in obj) {
if(obj.hasOwnProperty(prop)){
console.log(prop + " = " + obj[prop]);
}
}
}
@fazlurr
fazlurr / hexToRgb.js
Created April 7, 2014 03:51
RGB to Hex and Hex to RGB conversion with Javascript, From : http://stackoverflow.com/a/5624139
function hexToRgb(hex) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
@fazlurr
fazlurr / DatabaseHelper.java
Created April 9, 2014 12:49
Copying SQLite database
public class DataBaseHelper extends SQLiteOpenHelper{
//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/YOUR_PACKAGE/databases/";
private static String DB_NAME = "myDBName";
private SQLiteDatabase myDataBase;
private final Context myContext;
@fazlurr
fazlurr / WP_Query_Args.php
Last active March 24, 2025 16:17 — forked from billerickson/gist:3698476
WP_Query arguments list
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@fazlurr
fazlurr / showPopupOnClose.js
Created April 23, 2014 10:42
jQuery function to show popup on window close
$(window).bind("beforeunload", function() {
return confirm("Do you really want to close?");
});
@fazlurr
fazlurr / imagePreview.js
Created April 28, 2014 04:33
jQuery function for showing preview on image upload
function preview(input) {
var theID = $(input).attr('data-id');
console.log(theID);
var imgPreview = $('.preview[data-id='+theID+']');
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
imgPreview.attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);