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];
@solancer
solancer / droplet-proxy.sh
Created April 14, 2016 13:16
Proxy Server on Digitalocean Droplet
#!/usr/bin/env bash
# How to start:
# 1. Sign up for DigitalOcean with this link https://www.digitalocean.com/
# 2. Go to https://cloud.digitalocean.com/settings/applications and find you API key
# 3. In your shell, run 'export DIGITALOCEAN_TOKEN="INSERT TOKEN HERE"', without the outer quotes.
# 4. `brew install jq`
# 5. `./digitalocean-proxy`
# 6. When you are done, press CTRL+C ONCE, and everything will be cleaned up.

##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 / jquery.validate.boilerplate.js
Created May 8, 2016 20:12
My jquery.validate.boilerplate.js
// initialize validate plugin on the form
$('#contact-form').validate({
errorPlacement: function (error, element) {
var lastError = $(element).data('lastError'),
newError = $(error).text();
$(element).data('lastError', newError);
if(newError !== '' && newError !== lastError){
@solancer
solancer / mod_pagespeed .htaccess
Last active January 11, 2023 07:25
mod_pagespeed .htaccess configuration
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
@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 / apache-nginx-ftp
Created July 27, 2016 10:53
Correct permissions for /var/www/html
// Adding current user to www-data
sudo adduser $USER www-data
//change ownership to user:www-data and
sudo chown $USER:www-data -R /var/www/html
sudo chmod u=rwX,g=srX,o=rX -R /var/www/html
// change file permissions of existing files and folders to 755/644
sudo find /var/www/html -type d -exec chmod g=rwxs "{}" \;
@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);