Skip to content

Instantly share code, notes, and snippets.

View samarpanda's full-sized avatar
👋

Samar Panda samarpanda

👋
View GitHub Profile
@samarpanda
samarpanda / Ecmascript5 strict mode
Created February 4, 2012 07:10
Ecmascript5 strict mode
!(function($){
"use strict"
//Define your library strictly.
})(jQuery|Ender)
@samarpanda
samarpanda / boxshadow.css
Created February 14, 2012 05:06
Boxshadow for IE7 and IE8 css
.boxshadow{
background-color: #fff;
filter: progid:DXImageTransform.Microsoft.Shadow(color='#b7b8b3', Direction=120, Strength=3);
zoom: 1;
}
.boxshadow-disable{
filter: progid:DXImageTransform.Microsoft.Shadow(enabled=false);
}
@samarpanda
samarpanda / .htaccess
Created March 1, 2012 22:57
Htaccess configuration for password protected directory on web
AuthType Basic
AuthName "Restricted Resource"
AuthUserFile PATH_OF_HTPASSES_FILE
Require valid-user
# Relplace PATH_OF_HTPASSES_FILE with path to file .htpasses
@samarpanda
samarpanda / transitionend.html
Created August 18, 2012 18:09 — forked from davidcalhoun/transitionend.html
Example usage of a cross-browser ontransitionend event (CSS transition)
We couldn’t find that file to show.
@samarpanda
samarpanda / Utils.php
Created August 22, 2012 04:19
Get php page url
function getPageUrl() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on"){
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
@samarpanda
samarpanda / gist:3726988
Created September 15, 2012 08:33
Batch optimise images with a single command
#For jpeg files
#Need to install jpegtran in ubuntu
sudo apt-get install libjpeg-progs
Usage tips:
#To optimise a single jpeg image:
jpegtran -copy none -optimise -outfile image.jpg image.jpg
#To optimise all jpegs in the current directory:
for img in `ls *.jpg`; do jpegtran -copy none -optimise -outfile $img $img; done
@samarpanda
samarpanda / Utility.php
Created October 8, 2012 11:26
Generating random password like wordpress using php
<?php
class Utility{
static $random = "";
static function generate_password($length = 12, $special_chars=true)
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if($special_chars) $chars .= '!@#$%^&*_-()';
$password = "";
for($i=0;$i<$length;$i++)
@samarpanda
samarpanda / hash_hmac_receiver.php
Created October 9, 2012 11:06
Adding content verification using hmac in php
<?php
function get_private_key_for_public_key($public_key) {
// extract private key from database or cache store
return 'private_key_user_id_9999';
}
// Data submitted
$data = $_GET['data'];
$data = json_decode(stripslashes($data), TRUE);
@samarpanda
samarpanda / Samar.js
Created October 14, 2012 03:48
Prototype to build a Javascript library
window.dome = (function(){
function Dome(els){
}
var dome = {
get: function(selector){
}
};
return dome;
});
@samarpanda
samarpanda / Counter.js
Created October 14, 2012 05:05
Counter
var counter = (function(){
var i = 0,
timer = {};
timer.get = function(){
return i;
};
timer.set = function(value){
i = value;
};
timer.increment = function(){