Skip to content

Instantly share code, notes, and snippets.

View viniciusalonso's full-sized avatar

Vinícius Alonso viniciusalonso

View GitHub Profile
# Using pure SQL
SELECT name FROM students WHERE name LIKE 'input_text%'
# Or you can use activerecored query
Student.select(:name).where("name LIKE '#{params[:input_text]}%'")
sudo apt-get update
sudo apt-get install curl nodejs
# Para instalar o rvm
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
# Escrever isso no arquivo ~/.bashrc
@viniciusalonso
viniciusalonso / gist:94eb146cfc88598a9aa2
Created June 14, 2015 17:45
Example of simple table in latex
\begin{tabular}{l p{10cm}}
API & Application Programming Interface \\
DOM & Document Object Model \\
DRY & Don't Repeat Yourself \\
HTML & Hypertext Markup Language \\
IHC & Interação Humano Computador \\
JSON & Javascript Object Notation \\
ORM & Object Relational Mapper \\
QR Code & Quick Response Code \\
SPA & Single Page Application \\
Hi, I'm writing a follow api
https://github.com/viniciusalonso/droid_doctor_api
I'm trying doing a POST to '/api/v1/patients' with a json below:
"{patient: {\"name\":\"Test\",\"age\":\"24\",\"sex\":\"m\",\"phone\":\"99000099\"}}" .
The api returned an error 400 bad request.
curl -i -X POST -H "Content-Type: application/json" -d "{'doctor': {'name':'xablau', 'crm': '123478', 'specialty': 'Pediatra'} }" http://localhost:3000/api/v1/doctors
curl -i -X POST POST -H "Content-Type: application/json" -d "{'doctor': {'name':'xablau', 'crm': '123478', 'specialty': 'Pediatra'} }"
curl -i -X POST -H "Content-Type: application/json" -d "{'doctor': {'name':'xablau', 'crm': '123478', 'specialty': 'Pediatra'} }" http://localhost:3000/api/v1/doctors
curl -i -X POST -H "Content-Type: application/json" -d "'doctor': {'name': 'xablau', 'crm': '123478', 'specialty': 'Pediatra'} }" http://localhost:3000/api/v1/doctors
curl -i -X POST -H "Content-Type: application/json" -d '"doctor": {"name": "xablau", "crm": "123478", "specialty": "Pediatra"} }' http://localhost:3000/api/v1/doctors
curl -i -X POST -H "Content-Type: application/json" -d ' 'doctor: {"name": "xablau", "crm": "123478", "specialty": "Pediatra"} }' http://localhost:3000/api/v1/doctors
curl -X POST -H "Content-Type: application
$('#tag-pai-dos-botoes').on('click', '.remove_emprego',function(){
alert('teste');
$('.'+$(this).attr('value')).remove();
n = parseInt($('#contador_emprego').val())-1;
$('#contador_emprego').val(n);
});
# Método do controller
def update_state
@order = Order.includes(:table).find(params[:id])
@order.update({state: params[:state]})
if @order.ready? or @order.being_prepared?
# Faz uma publicação no canal waiter
# Dentro do canal tem uma "subseção" chamada update_waiter_screen
WebsocketRails[:waiter].trigger(:update_waiter_screen, @order.to_json(include: :table))
@viniciusalonso
viniciusalonso / product_bad_code_demeter_law.php
Created December 17, 2016 11:53
Código errado, lei de demeter
<?php
class Product {
private $value;
private $name;
public function __construct($name, $value) {
$this->name = $name;
$this->value = $value;
}
<?php
class Item {
private $product;
private $quantity;
public function __construct($product, $quantity) {
$this->product = $product;
$this->quantity = $quantity;
}
<?php
class Cart {
private $owner;
private $items;
public function __construct($owner, $items) {
$this->owner = $owner;
$this->items = $items;
}