Skip to content

Instantly share code, notes, and snippets.

View solancer's full-sized avatar
🎯
Focusing

Srinivas Gowda solancer

🎯
Focusing
View GitHub Profile
@solancer
solancer / param.js
Created August 11, 2016 15:06
Javascript Params
function setURLParam(key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "i");
var newSearch = location.search;
// Is the key-value pair present in the existing search?
if (re.test(newSearch)) {
// Update a value
newSearch = newSearch.replace(re, '$1' + key + "=" + value + '$2$3');
} else {
// Add the key and its value
@solancer
solancer / Country-List-with-ISD-codes.json
Created November 24, 2016 10:49
Country List with ISD codes
[
{
"name":"United Arab Emirates",
"dial_code":"+971",
"code":"AE"
},
{
"name":"Afghanistan",
"dial_code":"+93",
"code":"AF"
@solancer
solancer / randIdGen.js
Created December 1, 2016 11:35
Random id generator
function randIdGen() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return '#' + text;
}
@solancer
solancer / input.filters.js
Created December 1, 2016 12:05
HTML input filters
<script type="text/javascript">
$(document).ready(function() {
var masks = {
'int': /[\d]/,
'float': /[\d\.]/,
'money': /[\d\.\s,]/,
'num': /[\d\-\.]/,
'hex': /[0-9a-f]/i,
'email': /[a-z0-9_\.\-@]/i,
@solancer
solancer / jquery.validate.js
Created December 1, 2016 12:11
jquery validate rules
// Validation wrappe init & rules
$("#form").validate({
errorClass: 'invalid',
validClass: 'valid',
errorPlacement: function(error, element) {
error.insertAfter($(element));
// error.insertAfter($(element).siblings('label'));
},
rules: {
'name': {
@solancer
solancer / htaccess.expires.headers
Created December 13, 2016 21:01
htaccess expires headers
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/atom+xml "access plus 1 hour"
@solancer
solancer / Install Ruby Gems on Mac OS X without sudo
Created January 3, 2017 15:21
Install Ruby Gems on Mac OS X without sudo
Install Ruby Gems on Mac OS X without sudo
1. Add GEM_HOME to your .bash_profile
For example, nano ~/.bash_profile and add
export GEM_HOME=/Users/srinivas/.gem where the path is to your own Home folder
2. Add the gem executables to your system path
Also in .bash_profile, add
@solancer
solancer / readme.md
Created March 13, 2017 10:56 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@solancer
solancer / wget_script.sh
Created April 23, 2017 14:46
Wget scrape images from website
wget -nd -H -p -A jpg,jpeg,png,gif -e robots=off example.com
@solancer
solancer / bootstrap-offset-col-right.css
Created August 10, 2017 22:25
offset to right css for bootstrap cause by default only left offset is possible
.col-xs-offset-right-12 {
margin-right: 100%;
}
.col-xs-offset-right-11 {
margin-right: 91.66666667%;
}
.col-xs-offset-right-10 {
margin-right: 83.33333333%;
}
.col-xs-offset-right-9 {