Skip to content

Instantly share code, notes, and snippets.

View pantoniotti's full-sized avatar

Philippe Antoniotti pantoniotti

View GitHub Profile
@pantoniotti
pantoniotti / url.js.coffee
Last active December 18, 2015 00:19
Bunch of userfull Url related methods in a coffeescript class
# Url Class
class @Url
constructor: (@path) ->
getQueryValue: (key) ->
try
queries = @getAllQueries()
i = 0
if queries && queries.length > 0
@pantoniotti
pantoniotti / time.js.coffee
Last active December 18, 2015 00:19
Some time methods in a coffeescript class
# Time Class
class @Time
constructor: (@seconds) ->
getElapsedTimeString: (seconds) ->
currentTimeString = "00:00:00"
try
hours = Math.floor(seconds / 3600)
seconds = seconds % 3600
@pantoniotti
pantoniotti / cookies.js.coffee
Created June 3, 2013 01:40
Cookies class in coffeescript
# Cookie Class
class window.Cookie
create : (name, value, days) ->
if days
date = new Date
time = date.getTime()
date.setTime(time + (days*24*60*60*1000))
expires = "; expires=" + date.toGMTString()
else
@pantoniotti
pantoniotti / calls_controller.rb
Last active December 18, 2015 00:19
Example of a controller
class CallsController < ApplicationController
include ApplicationHelper
include CallsHelper
before_filter :setup_lists
before_filter :set_sources
def index
now = Date.today
@pantoniotti
pantoniotti / rcopy.sh
Created June 5, 2013 20:21
Remote copying file
# type the following commands in terminal on your local machine
# to copy something from this system to some other system:
scp /path/to/local/file username@hostname:/path/to/remote/file
# to copy something from some system to some other system:
scp username1@hostname1:/path/to/file username2@hostname2:/path/to/other/file
# to copy something from another system to this system:
scp username@hostname:/path/to/remote/file /path/to/local/file
@pantoniotti
pantoniotti / db_backup.sh
Created June 5, 2013 21:35
Database Backup script
#!/bin/bash
### MySQL Server Login Info ###
MUSER="root"
MPASS="root_password"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
BAK="/path/to/export"
# USE THIS CODE TO BACKUP ONLY ONE SPECIFIC DB
@pantoniotti
pantoniotti / net-http cheats
Created June 20, 2013 20:45
Nice collection of Net Http request examples
Source : https://github.com/augustl/net-http-cheat-sheet
########################
#Standard HTTP Request
#######################
require "net/http"
require "uri"
uri = URI.parse("http://google.com/")
@pantoniotti
pantoniotti / curl_install.sh
Created June 27, 2013 19:17
Installing curl on ubuntu
#!/usr/bin/env bash
if aptitude search '~i ^curl$' | grep -q curl; then
apt-get -y install curl git-core python-software-properties
fi
#!/usr/bin/env bash
if aptitude search '~i ^nginx$' | grep -q nginx; then
echo "nginx already installed, skipping."
else
aptitude -y install nginx
service nginx start
fi
@pantoniotti
pantoniotti / copy_ssh_keys.sh
Created June 27, 2013 21:10
Installs ssh keys on server to avoid password prompt everytime
#!/usr/bin/env bash
# deployer is the admin user
# replace the x by your own server IP
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> ~/.ssh/authorized_keys'