Skip to content

Instantly share code, notes, and snippets.

View adrianorsouza's full-sized avatar
🏠
Working from home

Adriano Rosa adrianorsouza

🏠
Working from home
View GitHub Profile
@adrianorsouza
adrianorsouza / post-update
Last active August 29, 2015 13:59
Git post-update hook script for bare repo on server
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
echo "--initializing hook--"
git --git-dir /var/www/site_name.com/.git --work-tree /var/www/site_name.com pull repo Production
@adrianorsouza
adrianorsouza / X-header-options
Last active August 29, 2015 13:59
X-header Options
X-Content-Type-Options:nosniff
X-Frame-Options:(deny|sameorigin)
X-XSS-Protection:1; mode=block
# For SSL
Strict-Transport-Security: max-age=16070400; includeSubDomains
# for images
X-Robots-Tag:noindex, nofollow
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
# BUILD PHP 5.5.15 on Mac OSX 10.9 (A.K.A Mavericks)
# @author Adriano Rosa (http://adrianorosa.com)
# date 2014-08-05 23:58
#
# References:
# http://stackoverflow.com/questions/22686284/os-x-mavericks-how-to-upgrade-php-5-4-to-5-5-latest
# http://php.net/manual/en/mssql.requirements.php
# http://stackoverflow.com/questions/6588174/enabling-postgresql-support-in-php-on-mac-os-x
# https://bugs.php.net/bug.php?id=41555
# http://xdebug.org/docs/install
diff --git a/developer/js/module-shorten.js b/developer/js/module-shorten.js
index df2e8f8..71f8965 100644
--- a/developer/js/module-shorten.js
+++ b/developer/js/module-shorten.js
@@ -32,6 +32,11 @@
return;
}
+ // Skip whether the window is shorten_hash
+ if ( el === 'user' && hash ) {
@adrianorsouza
adrianorsouza / jQuery.scrollToElement.js
Last active August 29, 2015 14:08
jQuery scrollTo element effect
$("body,html").animate({
scrollTop : (
$('div.element:last').offset().top // get the offset of the last element to scrollTo
- $('header.navbar').outerHeight() // get the difference whether there is fixed header element
+ $('div.element:last').outerHeight() // get the element itself height to make scroolTo be exact under the fixed header
)
},1500);
@adrianorsouza
adrianorsouza / renames.sh
Created May 5, 2015 17:04
Rename list of files within a given directory
#!/bin/bash
# @autor: Adriano Rosa <http://adrianorosa.com>
# @file: renames.sh
# @description: basic file renamer
# @usage: ./renames.sh path/ .html .php
criteria=$1
re_match=$2
replace=$3
if [[ $criteria && $re_match && $replace ]]; then
@adrianorsouza
adrianorsouza / js-random-string.js
Created May 11, 2015 19:43
Create random string with Javascript
Math.floor(Math.random()*0xFFFFFFFFFFFFFFFF).toString(36);
@adrianorsouza
adrianorsouza / bootstrapSwitch.js
Created December 2, 2015 19:18 — forked from bjcull/bootstrapSwitch.js
Angular directive for bootstrap-switch | http://www.bootstrap-switch.org/
.directive('bootstrapSwitch', [
function() {
return {
restrict: 'A',
require: '?ngModel',
link: function(scope, element, attrs, ngModel) {
element.bootstrapSwitch();
element.on('switchChange.bootstrapSwitch', function(event, state) {
if (ngModel) {
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);