Skip to content

Instantly share code, notes, and snippets.

View pjbelo's full-sized avatar

Paulo Belo pjbelo

View GitHub Profile
@pjbelo
pjbelo / my3DProject.js
Created August 24, 2020 16:34
my3DProject.js
// my3DProject.js
var camera, scene, renderer;
var geometry, material, box;
init();
animate();
function init() {
@pjbelo
pjbelo / autocomplete-ex.html
Created May 19, 2020 17:03
Autocomplete Example - HTML Javascript CSS (no dependencies)
<!DOCTYPE html>
<html lang="en"></html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Autocomplete Example</title>
<style>
* {
box-sizing: border-box;
@pjbelo
pjbelo / jquery-ui-autocomplete.html
Last active May 19, 2020 17:05
jQuery UI Autocomplete - Custom data and display
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Custom data and display</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style>
#project-label {
display: block;
@pjbelo
pjbelo / bootstrap4-navbar-examples
Last active May 2, 2020 23:08
Bootstrap 4 Navbar Examples
<!-- example 1 - using absolute position for center -->
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<a class="navbar-brand abs" href="#">Navbar 1</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="collapsingNavbar">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Link</a>
@pjbelo
pjbelo / python_http_server
Created April 27, 2020 15:07
Python3 launch http server
Python3 launch http server
python3 -m http.server
@pjbelo
pjbelo / python_cheatsheet.txt
Created October 16, 2019 10:43
Pyton Cheatsheet
# from Jupyter Notebook
### 1.1 Elementary Data Types
x = 4 # integer
print(x, type(x))
y = True # boolean (True, False)
print(y, type(y))
@pjbelo
pjbelo / google-cloud-storage-cors-config.md
Last active August 19, 2022 11:32
Google Cloud Storage CORS configuration

Use the gsutil cors command to configure CORS on a bucket:

gsutil cors set cors-json-file.json gs://example

Where cors-json-file.json contains:

@pjbelo
pjbelo / add_flash_types.md
Last active June 9, 2022 12:34
[Rails] Flash Types

In rails 5 you can use add_flash_types method. Just add it to ApplicationController and include the types you want:

# application_controller.rb
...
  add_flash_types :success, :warning, :danger, :info

on your controller use the appropriate type instead of 'notice':

@pjbelo
pjbelo / troubleshooting.md
Created October 22, 2018 22:41
Troubleshooting that worked for me...

Error

ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) Errno::ECONNRESET: Connection reset by peer - SSL_connect

Solution

turn off IPv6 on wifi

networksetup -setv6off Wi-Fi

@pjbelo
pjbelo / load_environment_variables.rb
Last active October 17, 2018 17:20
[Rails] Load environment variables from file `config/local_env.yml`. Place file in `config/initializers/`
# Loads environment variables from file config/local_env.yml
# access vars using ENV['VAR_NAME']
env_file = File.join(Rails.root, 'config', 'local_env.yml')
if File.exists?(env_file)
YAML.load(File.open(env_file)).each do |key, value|
ENV[key.to_s] = value
end
end