Skip to content

Instantly share code, notes, and snippets.

View cristianoliveira's full-sized avatar
😁
Foo bar

Cristian Oliveira cristianoliveira

😁
Foo bar
View GitHub Profile
@cristianoliveira
cristianoliveira / CountryAddressForm.js
Last active April 5, 2018 05:57
country address form
// CountryAddressForm.js
// Common most used address format
// ...
render() {
return (
<form action="#"
onSubmit={this.handleSubmit.bind(this)}
onChange={this.handleChange.bind(this)}>
@cristianoliveira
cristianoliveira / CountryAddressForm.js
Last active April 5, 2018 05:58
Same same but different - post
// CountryAddressForm.js
render() {
return (
<form action="#"
onSubmit={this.handleSubmit.bind(this)}
onChange={this.handleChange.bind(this)}>
<CountrySelector name="country" countries={countries} />
<AddressLineInput name="address_line" value={this.state.address_line} />
@cristianoliveira
cristianoliveira / CountryAddressForm.js
Last active April 5, 2018 06:00
Same same but different - post
// CountryAddressForm.js
const COUNTRY_REGIONS = { IE:[], SP:[], IT:[] };
render() {
return(
<form action="#"
onSubmit={this.handleSubmit.bind(this)}
onChange={this.handleChange.bind(this)}>
<CountrySelector name="country" countries={countries} />
function fibCreate() {
return function fibonacci(num) {
if (num <= 1) return 1;
return fibonacci(num - 1) + fibonacci(num - 2);
};
}
for (var i = 0, len = 40; i < len; i++) {
fibCreate()(i);
@cristianoliveira
cristianoliveira / jenkins.sh
Last active June 4, 2018 14:39
jenkins-deploy-command.sh
#!/bin/bash -l
set -e # fail on error
set -u # do not allow unset variables
# use the correct exit code, when piping commands, e.g.
# here you use curl ... | python... so if curl fails, python will still
# continure working
set -o pipefail
@cristianoliveira
cristianoliveira / example.js
Last active July 25, 2018 12:29
Example event use
// Use case
// Render things based on the experiment variant
class FooTest extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string
};
constructor(props) {
@cristianoliveira
cristianoliveira / karabiner.json
Created August 5, 2019 14:39
My keyboard configs
{
"global": {
"check_for_updates_on_startup": false,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@cristianoliveira
cristianoliveira / optimize-img.sh
Created August 28, 2019 11:42
Small script to optimize images
#!/usr/bin/env bash
FILEPATH="$1"
FILENAME="${2?"No file name provided"}"
if hash optipng 2>/dev/null; then
echo "Optmizing image"
cp "$FILEPATH" "$FILEPATH-bkp.png"
optipng -o5 "$FILEPATH"
else
pub trait Command {
fn execute(&self) -> String;
}
struct AddCmd;
struct DeleteCmd;
impl Command for AddCmd {
fn execute(&self) -> String { "It add".into() }
}
@cristianoliveira
cristianoliveira / collatz.rs
Last active March 28, 2021 22:08
Collatz Conjecture in Rust
// Responsible for calcule Collatz Conjecture
// n -> n/2 (if n is pair) n -> 3n + 1 (if n is odd)
//
fn calcule(num: u64) -> u64 {
if num <= 1 { return 1; };
if num % 2 == 0 {
num / 2
} else{
3 * num + 1