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 / jpegResizer.py
Created December 15, 2015 23:30
jpegResizer.py Author: Srinivas Gowda
#/usr/bin/env python
import sys
import os.path
import PIL
from PIL import Image
if __name__ == "__main__":
@solancer
solancer / gist:6e0bab55e97cfb6d0d5b
Created December 16, 2015 00:37 — forked from slivero/gist:3164297
Resampling a JPEG image in PHP using GD (not imagemagick)
<?php
/**
* Class used for resampling images
*/
class Resampler
{
/**
* Resample an image
*
@solancer
solancer / Mysql Cheat Sheet
Created March 29, 2016 14:52
Mysql Cheat Sheet
MySQL Common Commands
Access monitor: mysql -u [username] -p; (will prompt for password)
Show all databases: show databases;
Access database: mysql -u [username] -p [database] (will prompt for password)
Create new database: create database [database];

##Open Graph Code Snippet

Put this in the header of your site. Update the info below with dynamic content leaving article as is.

<meta property="og:title" content="Site Title" />
<meta property="og:type" content="article" />
<meta property="og:image" content="Image URL" />
<meta property="og:url" content="Page URL" />
<meta property="og:description" content="Page Description" />
@solancer
solancer / email-input-pattern.html
Created June 21, 2016 20:41
Email HTML regex pattern
<input type="text"
pattern="[a-zA-Z0-9_]+(?:\.[A-Za-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?!([a-zA-Z0-9]*\.[a-zA-Z0-9]*\.[a-zA-Z0-9]*\.))(?:[A-Za-z0-9](?:[a-zA-Z0-9-]*[A-Za-z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?"
required>
@solancer
solancer / srini.js
Created July 28, 2016 05:58
www-with-node-js-and-express
var express = require("express");
var app = express.createServer();
var port = 9090;
app.all(/.*/, function(req, res, next) {
var host = req.header("host");
if (host.match(/^www\..*/i)) {
next();
} else {
res.redirect(301, "http://www." + host);
@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,