Skip to content

Instantly share code, notes, and snippets.

View achudars's full-sized avatar
🥔
every challenge is an opportunity

Aleks achudars

🥔
every challenge is an opportunity
View GitHub Profile
::-webkit-scrollbar {
width: 15px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #fff;
}
::-webkit-scrollbar-thumb {
@achudars
achudars / web-snippet-030 ( 100% width and height background in CSS )
Last active December 17, 2015 00:19
100% width and height background in CSS
background: url('../image/site/bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
@achudars
achudars / web-snippet-029 ( LocalStorage as REST using JavaScript )
Last active December 17, 2015 00:19
LocalStorage as REST using JavaScript
function gets(storage)
{
var array;
if(!localStorage[storage]) array = [];
else array = JSON.parse(localStorage[storage]);
return array;
}
function get(storage, id)
{
@achudars
achudars / web-snippet-028 ( PHP Error collection and reporting )
Last active December 17, 2015 00:19
PHP Error collection and reporting
<?php
// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
@achudars
achudars / web-snippet-027 ( Generating random numbers in JavaScript )
Last active December 17, 2015 00:19
Generating random numbers in JavaScript
/**
* Returns a random number between min and max
*/
function getRandomArbitary (min, max) {
return Math.random() * (max - min) + min;
}
/**
* Returns a random integer between min and max
* Using Math.round() will give you a non-uniform distribution!
@achudars
achudars / web-snippet-026 ( SVG to PNG fallback for Images )
Last active December 17, 2015 00:19
SVG to PNG fallback for Images
if (!Modernizr.svg) {
$('img[src$=".svg"]').each(function()
{
$(this).attr('src', $(this).attr('src').replace('.svg', '.png'));
});
}
@achudars
achudars / web-snippet-025 ( HTML Meta Tags for Responsive Layouts )
Last active December 17, 2015 00:19
HTML Meta Tags for Responsive Layouts
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true">
@achudars
achudars / web-snippet-024 ( Most recent tweet using jQuery )
Last active December 17, 2015 00:19
Most recent tweet using jQuery
$.getJSON("http://twitter.com/statuses/user_timeline/username.json?callback=?", function(data) {
$("#twitter").html(data[0].text);
});
@achudars
achudars / web-snippet-023 ( JavaScript array_flip function )
Last active December 17, 2015 00:19
JavaScript array_flip function - A JavaScript equivalent of PHP’s array_flip
function array_flip (trans) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Pier Paolo Ramon (http://www.mastersoup.com/)
// + improved by: Brett Zamir (http://brett-zamir.me)
// * example 1: array_flip( {a: 1, b: 1, c: 2} );
// * returns 1: {1: 'b', 2: 'c'}
// * example 2: ini_set('phpjs.return_phpjs_arrays', 'on');
// * example 2: array_flip(array({a: 0}, {b: 1}, {c: 2}))[1];
// * returns 2: 'b'
@achudars
achudars / web-snippet-022 ( selected or checked check-boxes in a form using JavaScript )
Last active December 17, 2015 00:19
Get the value of the selected /checked check-boxes in a form using JavaScript and HTML
Check the web site programming language you know:
<form action="script.php" method="post">
<input type="checkbox" name="chb[]" value="html" />HTML<br/>
<input type="checkbox" name="chb[]" value="css" />CSS<br/>
<input type="checkbox" name="chb[]" value="javascript" />JavaScript<br/>
<input type="checkbox" name="chb[]" value="php" />php<br/>
<input type="checkbox" name="chb[]" value="python" />Python<br/>
<input type="checkbox" name="chb[]" value="net" />Net<br/>
<input type="button" value="Click" id="btntest" />
</form>