Skip to content

Instantly share code, notes, and snippets.

View brunopgalvao's full-sized avatar
🚀

Bruno Galvao brunopgalvao

🚀
View GitHub Profile
@brunopgalvao
brunopgalvao / StackTack_Test.js
Created October 28, 2011 22:26
Testing gist
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://app.stacktack.com/jquery.stacktack.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(document).stacktack();
});
</script>
</head>
@brunopgalvao
brunopgalvao / DeveloperAssignment.vb
Created November 13, 2011 01:07
Developer Assignment
' Bruno Galvao
' 11/12/11
'
' Given an array of integers between 1 and 1,000,000.
' One integer is in the array twice. Find the duplicate.
Module Module1
Sub Main()
@brunopgalvao
brunopgalvao / index.html
Created December 12, 2011 18:38
Recent Earthquakes
<!DOCTYPE html>
<!--
-- Bruno Galvao
-- 12/11/11
-- Bluewolf Coding Assignment
-->
<html>
<head>
@brunopgalvao
brunopgalvao / _form.html.erb
Last active December 23, 2022 02:32
HTML5 Datalist using Ruby on Rails form_for
<%= form_for @person do |f| %>
<%= f.label :first_name, "First Name" %>:
<%= f.text_field :first_name, list: 'first-name' %>
<datalist id="first-name">
<% Person.all.each do |person| %>
<option value="<%= person.first_name %>"></option>
<% end %>
</datalist>
<%= f.submit %>
<% end %>
@brunopgalvao
brunopgalvao / change_due.rb
Created August 16, 2014 01:37
When given change how much of each denomination to give back!
def change_due(input)
quarters= (input/25)
dimes=((input%25)/10)
nickles=(((input%25)%10)/5)
pennies=(input%5)
puts "#{quarters} quarters, #{dimes} dimes, #{nickles} nickles, and #{pennies} pennies"
end
@brunopgalvao
brunopgalvao / foursquare.rb
Created September 11, 2014 22:39
Query foursquare for businesses.
namespace :populate do
desc "Populate data from Foursqaure API"
task :foursquare => :environment do
client = Foursquare2::Client.new(:client_id => 'CLIENT_ID', :client_secret => 'CLIENT_SECRET', :api_version => '20140904')
Cities.data_path = "lib/tasks/cities"
cities = Cities.cities_in_country('US')
limit = 5000 # Foursqaure rate limit up to 5,000 userless requests per hour to venues/* endpoints.
@brunopgalvao
brunopgalvao / GitHubHosting.md
Created May 20, 2016 04:14
GitHub Hosting - the -poor +rich man's hosting provider.

GitHub Hosting - the -poor +rich man's hosting provider.

@brunopgalvao
brunopgalvao / adjacentElementsProduct.js
Last active August 29, 2018 20:42
Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.
function adjacentElementsProduct(inputArray) {
let previousElement;
let largestProduct = inputArray[0]*inputArray[1];
inputArray.forEach(function(currentElement, index){
if (index === 0) {
previousElement = currentElement;
return;
}
else if (previousElement*currentElement > largestProduct) {
largestProduct = previousElement*currentElement
@brunopgalvao
brunopgalvao / dups.rb
Last active October 3, 2018 16:24
account dups
def check_for_existing_membership
accounts = Account.where(email_address: email)
accounts.each do |account|
if account.portals.pluck(:id) == portal.id
errors.add(:duplicate, 'The email is already associated with members of this organization')
return false
end
end
@brunopgalvao
brunopgalvao / server.js
Created January 28, 2019 14:20
a server using node and http module
// Load HTTP module
const http = require("http");
// Create HTTP server and listen on port 8000 for requests
http.createServer(function(request, response) {
// Set the response HTTP header with HTTP status and Content type
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body "Hello World"