Skip to content

Instantly share code, notes, and snippets.

View vinaydotblog's full-sized avatar
🏠
Working from home

Vinay Aggarwal vinaydotblog

🏠
Working from home
View GitHub Profile
@vinaydotblog
vinaydotblog / functions.php
Created March 7, 2012 05:27
php: Fetch public user tweets
<?php
// Functions to fetch public tweets of any user
// Let's update this
function get_tweets($screen_name = 'vinnizworld'){
$api_url = "https://api.twitter.com/1/statuses/user_timeline.json";
$feed = $api_url."?screen_name=".$screen_name."&limit=20";
$headers = get_headers($feed);
@vinaydotblog
vinaydotblog / functions.php
Created March 7, 2012 05:31
php: check domain availability
<?php
//Check the availability of Domain Name
function check_domain_availability($domain)
{
$recordexists = checkdnsrr($domain, "ANY");
if ($recordexists) echo "The domain name has been taken. Sorry!";
else echo "The domain name is available!";
}
@vinaydotblog
vinaydotblog / Easy Background Grid
Created March 27, 2012 13:21 — forked from JeffreyWay/Easy Background Grid
This is an easy way to set a background grid for new websites.
.grid-overlay:before {
content: "";
position: fixed;
background-color: rgba(34,102,153,0.5);
background: -webkit-linear-gradient(skyblue 2px, transparent 2px), -webkit-linear-gradient(0, skyblue 2px, transparent 2px), -webkit-linear-gradient(skyblue 1px, transparent 1px), -webkit-linear-gradient(0, skyblue 1px, transparent 1px);
background: -moz-linear-gradient(skyblue 2px, transparent 2px), -moz-linear-gradient(0, skyblue 2px, transparent 2px), -moz-linear-gradient(skyblue 1px, transparent 1px), -moz-linear-gradient(0, skyblue 1px, transparent 1px);
background: -o-linear-gradient(skyblue 2px, transparent 2px), -o-linear-gradient(0, skyblue 2px, transparent 2px), -o-linear-gradient(skyblue 1px, transparent 1px), -o-linear-gradient(0, skyblue 1px, transparent 1px);
background: -ms-linear-gradient(skyblue 2px, transparent 2px), -ms-linear-gradient(0, skyblue 2px, transparent 2px), -ms-linear-gradient(skyblue 1px, transparent 1px), -ms-linear-gradient(0, skyblue 1px, transparent 1px);
background
@vinaydotblog
vinaydotblog / gist:2215818
Created March 27, 2012 13:21 — forked from JeffreyWay/gist:1946898
JS: Event listener for all browsers
// Event listener for all browsers
// Including some comments
var addEvent = (function () {
var filter = function(el, type, fn) {
for ( var i = 0, len = el.length; i < len; i++ ) {
addEvent(el[i], type, fn);
}
};
if ( document.addEventListener ) {
@vinaydotblog
vinaydotblog / .htaccess
Created March 27, 2012 17:59
Codeigniter / Yii index.php remove
AddType text/cache-manifest manifest
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /
# Do not enable rewriting for files or directories that exist
@vinaydotblog
vinaydotblog / gist:2224204
Created March 28, 2012 06:27 — forked from JeffreyWay/Easy Background Grid
This is an easy way to set a background grid for new websites.
.grid-overlay:before {
content: "";
position: fixed;
background-color: rgba(34,102,153,0.5);
background: -webkit-linear-gradient(skyblue 2px, transparent 2px), -webkit-linear-gradient(0, skyblue 2px, transparent 2px), -webkit-linear-gradient(skyblue 1px, transparent 1px), -webkit-linear-gradient(0, skyblue 1px, transparent 1px);
background: -moz-linear-gradient(skyblue 2px, transparent 2px), -moz-linear-gradient(0, skyblue 2px, transparent 2px), -moz-linear-gradient(skyblue 1px, transparent 1px), -moz-linear-gradient(0, skyblue 1px, transparent 1px);
background: -o-linear-gradient(skyblue 2px, transparent 2px), -o-linear-gradient(0, skyblue 2px, transparent 2px), -o-linear-gradient(skyblue 1px, transparent 1px), -o-linear-gradient(0, skyblue 1px, transparent 1px);
background: -ms-linear-gradient(skyblue 2px, transparent 2px), -ms-linear-gradient(0, skyblue 2px, transparent 2px), -ms-linear-gradient(skyblue 1px, transparent 1px), -ms-linear-gradient(0, skyblue 1px, transparent 1px);
background
@vinaydotblog
vinaydotblog / bookmarkScroll
Last active October 2, 2015 10:07
Smooth scroll with HTML bookmarks
// Menified Version of Smooth scrool Script given below:
(function(b){var c=window.location.hash;1<c.length&&(c=b(c),c.length&&b("html,body").animate({scrollTop:c.offset().top},400));b(document).on("click","a",function(c){var a=b(this).attr("href");if(a&&~a.indexOf("#")){var a=a.substr(a.indexOf("#")+1),d=b("a[name="+a+"]"),e=b("#"+a);console.log(a);d=d.length?d:e;d.length&&(c.preventDefault(),b("html,body").animate({scrollTop:d.offset().top},400))}})})(jQuery);
@vinaydotblog
vinaydotblog / gist:2225241
Created March 28, 2012 10:22
Placeholder Support for old browsers using JavaScript
// Placeholder Support for old browsers using JavaScript (without jQuery)
// Test on IE6+, Firefox, Chrome
if( 'placeholder' in document.createElement('input') == false ){
var inputs = document.getElementsByTagName('input');
for(var i = 0 ; i < inputs.length ; i++ ){
var input = inputs[i], placeholder = input.getAttribute('placeholder'),
textColor = input.style.color;
if(placeholder){
input.value = placeholder;
input.style.color = '#aaa';
@vinaydotblog
vinaydotblog / php
Created March 30, 2012 07:11
php: Calculate disk space and Conversion without loops
<?php
/* Copied from http://in2.php.net/manual/en/function.disk-free-space.php */
// Calculate Disk space and Conversion without loops
// Output: 31.24 GB
$bytes = disk_free_space(".");
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
echo $bytes . '<br />';
@vinaydotblog
vinaydotblog / Menified
Created April 6, 2012 10:24
js: Send / Receive data using ajax
var ajax = function(a,b,c){var d="",e=/fun/.test(typeof b)?"GET":"POST",c="GET"===e?b:c;xhr=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");xhr.onreadystatechange=function(){4<=xhr.readyState&&200==xhr.status&&c(xhr.responseText)};if("POST"==e&&/obj/.test(typeof b)){for(var f in b)d+=f+"="+encodeURIComponent(b[f])+"&";d=d.slice(0,-1)}xhr.open(e,a,!0);xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");xhr.send(d);