Skip to content

Instantly share code, notes, and snippets.

View paganotoni's full-sized avatar
💭
⚡️⚡️

Antonio Pagano paganotoni

💭
⚡️⚡️
View GitHub Profile
@paganotoni
paganotoni / gist:5769704
Created June 12, 2013 22:30
Invite to repo on heroku.
heroku sharing:add [email protected]
Ref http://devcenter.heroku.com/articles/custom-domains
Heroku Setup
1. Install Custom Domain Plugin for your app
heroku addons:add custom_domains
2. Add domain names
heroku domains:add www.example.com
GoDaddy Setup
1. Go to your domain under your account
@paganotoni
paganotoni / counting.js
Created December 14, 2012 19:35
Counting Characters by type.
var pass = document.basic.password.value;
var chars = pass.length;
var l_let = pass.match(/[a-z]/g).length;
var u_let = pass.match(/[A-Z]/g).length;
var num = pass.match(/\d/g).length;
alert(
"# Chars: "+chars+"\n"+
"# Lower: "+l_let+"\n"+
"# Upper: "+u_let+"\n"+
"# Numbers: "+num
Groovy also has a Time Category class which gives you DSL style syntax for manipulating dates. Here is an example:
import org.codehaus.groovy.runtime.TimeCategory
now = new Date()
println now
use(TimeCategory) {
footballPractice = now + 1.week - 4.days + 2.hours - 3.seconds
}
println footballPractice
which will produce output like this:
@paganotoni
paganotoni / ngnix_reverse
Created December 7, 2012 04:25
ngnix reverse proxy
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
server_name ci.yourcompany.com;
location / {
@paganotoni
paganotoni / tomcat.sh
Created December 3, 2012 18:13 — forked from valotas/tomcat.sh
Tomcat init.d script
#!/bin/bash
#
# tomcat7 This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat7
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@paganotoni
paganotoni / portInUse.groovy
Created December 2, 2012 16:09
Checking port in use
boolean portTaken = false;
ServerSocket socket = null;
try {
socket = new ServerSocket(portNumber);
} catch (IOException e) {
portTaken = true;
} finally {
// Clean up
if (socket != null) socket.close();
}
@paganotoni
paganotoni / primesScript.groovy
Created November 3, 2012 20:02
Simple Prime Numbers Groovy Script
#!/usr/bin/env groovy
public class PrimeNumberEvaluator {
// Evaluates a number looking if its prime or not
static boolean isPrime( def number ){
def divisors = []
for( def possibleDivisor in (1..number) ){
if( (number % possibleDivisor) == 0 ){ divisors << possibleDivisor }
if( divisors.size() > 2 ){ break }
@paganotoni
paganotoni / ssh-known-hosts-mgmt.sh
Created October 25, 2012 04:07 — forked from bradland/ssh-known-hosts-mgmt.sh
SSH known_hosts tools
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -H -F github.com
@paganotoni
paganotoni / EBSDeploy.groovy
Created October 13, 2012 14:57
Grails Amazon EBS deploy Script
includeTargets << grailsScript("_GrailsInit")
import com.amazonaws.auth.*
import com.amazonaws.services.s3.*
import com.amazonaws.services.elasticbeanstalk.*
import com.amazonaws.services.elasticbeanstalk.model.*
def projectWarFilename
def optionMap = [scripts: []]