Skip to content

Instantly share code, notes, and snippets.

View pankajparashar-zz's full-sized avatar

Pankaj Parashar pankajparashar-zz

View GitHub Profile
@pankajparashar-zz
pankajparashar-zz / todo.sh
Created February 8, 2014 07:43
The best todo list app for any developer
Make a list of your todos in /etc/motd:
* Dump prod.sql
- Don't forget to sanitize
* Finish Foo project
And now you'll see it every time you open a new prompt:
* Dump prod.sql
- Don't forget to sanitize
@pankajparashar-zz
pankajparashar-zz / spool.sql
Last active August 29, 2015 14:02
The perfect SQLPLUS script.
SET TRIMSPOOL ON
SET TRIMOUT ON
SET HEADSEP OFF
SET ECHO OFF
SET VERIFY OFF
SET TERMOUT ON
SET HEADING OFF
SET PAGESIZE 0
SET FEEDBACK OFF
SET NEWPAGE NONE
@pankajparashar-zz
pankajparashar-zz / password_hashing_api.md
Created September 15, 2012 15:06 — forked from nikic/password_hashing_api.md
The new Secure Password Hashing API in PHP 5.5 - http://crackstation.net/hashing-security.htm

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

@pankajparashar-zz
pankajparashar-zz / snippet.js
Created October 29, 2012 11:39 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Responsive Design Testing</title>
<style>
body { margin: 20px; font-family: sans-serif; overflow-x: scroll; }
.wrapper { width: 6000px; }
.frame { float: left; }
h2 { margin: 0 0 5px 0; }
@pankajparashar-zz
pankajparashar-zz / html5-canvas.js
Last active December 13, 2015 17:09
Stretch HTML5 canvas to fill the size of the view-port, preserving the aspect ratio.
window.addEventListener(
'load',
function () {
var canvas = document.getElementsByTagName('canvas')[0];
fullscreenify(canvas);
},
false
);
@pankajparashar-zz
pankajparashar-zz / generatePassword.php
Last active December 14, 2015 17:38
A function for generating a random password of whatever length you need. You don't get super-secure passwords from this but they certainly should be good enough for e.g. a "forgotten your password?" feature. To avoid generating passwords containing offensive words, vowels are excluded from the list of possible characters. To avoid confusing user…
<?php
function generatePassword ($length = 8)
{
// start with a blank password
$password = "";
// define possible characters - any character in this string can be
// picked for use in the password, so if you want to put vowels back in
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@pankajparashar-zz
pankajparashar-zz / resizer.js
Created March 16, 2013 08:30
Responsive Design Bookmarklet.
javascript:void((function(d){if(self!=top||d.getElementById('toolbar')&&d.getElementById('toolbar').getAttribute('data-resizer'))return false;d.write('<!DOCTYPE HTML><html style="opacity:0;"><head><meta charset="utf-8"/></head><body><a data-viewport="240x240" data-icon="handy">Mobile</a><a data-viewport="320x480" data-icon="mobile">Mobile (e.g. Apple iPhone)</a><a data-viewport="320x568" data-icon="mobile" data-version="5">Apple iPhone 5</a><a data-viewport="600x800" data-icon="small-tablet">Small Tablet</a><a data-viewport="768x1024" data-icon="tablet">Tablet (e.g. Apple iPad 2-3rd, mini)</a><a data-viewport="1024x768" data-icon="display" data-version="17″">17″ Display</a><a data-viewport="1280x800" data-icon="notebook">Widescreen</a><a data-viewport="2560x1600" data-icon="display" data-version="30″">30″ Apple Cinema Display</a><script src="http://lab.maltewassermann.com/viewport-resizer/resizer.min.js"></script></body></html>')})(document));