Skip to content

Instantly share code, notes, and snippets.

@brunopgalvao
brunopgalvao / uglyXmasSweater.js
Created December 6, 2019 04:16
ugly xmas sweater template for custom sweater :)
const ugly =
(x) => true
console.log(ugly(
{
name: 'sweater',
type: 'xmas'
}
) ?
'UGLY XMAS SWEATER'
@brunopgalvao
brunopgalvao / surge-deployment-instructions.md
Last active November 15, 2019 20:26
This is how you deploy a create-react-app to surge.sh

cd into your react app and do the following:

npm run build
cd build/
mv index.html 200.html
npx surge
@brunopgalvao
brunopgalvao / InstallingIssue.bash
Created February 13, 2019 21:23
solve Ruby issue
```
brew uninstall ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm install ruby-2.4
rvm use ruby-2.4
gem install bundler
bundle install
```
{
"workshops":[
{
"title":"INTRO TO PYTHON",
"description":"Explore the intersection of coding and data with General Assembly. During our Python-focused intro class, you’ll learn you’ll learn all about Python - including how to get started, advantages and disadvantages of Python, essentials of programming in Python, and tools available to build applications in Python.",
"instructor":"Terence Stone",
"date":"Monday, 4 February",
"time":"6:30 – 8:30 pm EST"
},
{
@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"
@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 / 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 / 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 / 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 / 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