Skip to content

Instantly share code, notes, and snippets.

@hugodias
hugodias / database.php
Created July 20, 2012 13:58
CakePHP working with multiple environment databases
<?php
/**
* CakePHP 2.x
* This is a database sample file for use multiple environment in CakePHP
* To find out what the environment is being used at the time just check the configuration 'current_environment'.
* E.g: echo Configure::read('current_environment');
*/
class DATABASE_CONFIG
{
@hugodias
hugodias / gist:3170376
Created July 24, 2012 14:46
Basic Git Merge
git init
git add .
git commit -m 'Primeiro commit'
git checkout -b issue1
# Modify files
git add .
git commit -m 'Fixed issue1'
git checkout master
@hugodias
hugodias / gist:3176036
Created July 25, 2012 12:54
Mountain lion search in App Store
#!/bin/sh
URL='http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewMultiRoom?fcId=489264329&mt=12'
SEARCH_STRING="mountain"
echo "Mountain Lion Hunter v1.0"
echo "Press Ctrl-C to exit."
echo ""
while true ; do
@hugodias
hugodias / gist:3295080
Created August 8, 2012 13:37
Get page HASH with Javascript
function getHash() {
var hash = window.location.hash;
return hash.substring(1); // remove #
}
function getLinkTarget(link) {
return link.href.substring(link.href.indexOf('#')+1);
}
@hugodias
hugodias / sliderBoilerplate.js
Created August 15, 2012 12:49
Slider Boilerplate
/*
* Project: Slider Boilerplate
* Description: Slider simples feito em jQuery
* Author: Hugo Dias | [email protected]
* License:
*/
;(function ( $, window, undefined ) {
var pluginName = 'sliderBoilerplate',
@hugodias
hugodias / launch_sublime_from_terminal.markdown
Created September 28, 2012 14:44 — forked from artero/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@hugodias
hugodias / gist:3841119
Created October 5, 2012 17:19
Javascript prototype boilerplate
;(function() {
var App,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
App = (function() {
// Constructor
function App() {
this.initialize();
}
@hugodias
hugodias / gist:3841157
Created October 5, 2012 17:25
Easy manipulate ajax data with jquery
$('.btn').click(function(){
ajaxGET('http://my-url',function(data) {
// Manipulate your ajax data here
console.log( data )
});
})
function ajaxGET( url, callback ) {
return $.ajax({
@hugodias
hugodias / gist:3875247
Created October 11, 2012 20:24
Unlimited file size limit PHP download
function readfile_chunked ($filename) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
print $buffer;
@hugodias
hugodias / gist:3958416
Created October 26, 2012 12:08
Google maps como chegar
var maps;
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var infoWindow = new google.maps.InfoWindow({maxWidth: 460});
var markerOffice = new google.maps.Marker({
title: 'MARK_TITLE_HERE',
//icon: 'site/images/icon-feed.gif', // icon
position: new google.maps.LatLng('LAT_HERE', 'LONG_HERE')
});