Skip to content

Instantly share code, notes, and snippets.

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

Andre Goncalves andregoncalves

🏠
Working from home
View GitHub Profile
@andregoncalves
andregoncalves / trim.js
Last active November 18, 2017 12:01
trim string in javascript
var trimmed = str.replace(/^\s+|\s+$/g, '');
@andregoncalves
andregoncalves / scope_builder example
Created June 18, 2009 17:15
named scopes with dynamic find conditions
named_scope :active, :conditions => { :active => true }
named_scope :by_state, lambda { |state| { :conditions => { :active => state } } }
def self.search(params)
builder = Course.scope_builder
builder.by_state(params[:active]) if not params[:active].blank?
builder.all
end
@andregoncalves
andregoncalves / html5_template.html
Created July 18, 2009 15:53
html5 boilerplate
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>HTML 5 complete</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, dialog, figure, footer, header,
var sys = require('sys'),
http = require('http'),
ws = require("./vendor/ws"),
base64 = require('./vendor/base64'),
arrays = require('./vendor/arrays');
// Command line args
var USERNAME = process.ARGV[2];
var PASSWORD = process.ARGV[3];
var KEYWORD = process.ARGV[4] || "iphone";
@andregoncalves
andregoncalves / jquery.textchange.js
Created June 18, 2010 16:59 — forked from mkelly12/jquery.textchange.js
Added contenteditable support
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).bind('keyup.textchange', $.event.special.textchange.handler);
$(this).bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {
@andregoncalves
andregoncalves / mappeo.js
Last active February 25, 2018 09:43
[geovideo widget start code] #codecanyon
mappeo.initialize({
container: 'map',
filter: '', // Filter videos by keyword
geolocation: true, // Automatic center map on the user current location
latitude: 37.7749295,
longitude: -122.4194155,
zoom: 8,
gMapsApiKey: '<your google API key>',
youTubeApiKey: '<your google API key>',
markerClusterer: true, // Clusterer markers
@andregoncalves
andregoncalves / social_tracking.js
Created July 6, 2011 17:59
Google analytics social events tracking
trackSocialEvents: function() {
// Track Facebook
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
// Track Twitter
twttr.events.bind('tweet', function(event) {
if (event) {
@andregoncalves
andregoncalves / gist:1090367
Created July 18, 2011 19:13
Chrome Install Notification Bar
(function() {
// Configuration Parameters
var message_html = "<App> is now available in the Chrome Web Store"
// Webstore install page URL
var app_install_url = "https://chrome.google.com/webstore/detail/lnempicjilmahngopecohbcbldlijkib";
// 24x24 App icon
var app_icon = "";
var cookie = "_webstore_preference";
// URL for stylesheet
var stylesheet_url = "chrome-notification.css";
@andregoncalves
andregoncalves / gist:1090424
Created July 18, 2011 19:32
Check if Chrome Web Store App is installed
if (navigator && navigator.userAgent && navigator.userAgent.indexOf('Chrome') != -1) {
var isInstalled = window.chrome && window.chrome.app && window.chrome.app.isInstalled;
var isCancelled = document.cookie.indexOf(cookie + "=true") >= 0;
(...)
}
@andregoncalves
andregoncalves / geophoto.js
Created January 21, 2012 18:42
GeoPhoto widget initializer code
geoPhoto.initialize({
container: 'map',
filter: '',
geolocation: true,
latitude: 37.7749295,
longitude: -122.4194155,
zoom: 8,
maxSearchResults: 100
});
/* Other initialization parameters