Skip to content

Instantly share code, notes, and snippets.

View brunojppb's full-sized avatar
🌱
code gardening...

Bruno Paulino brunojppb

🌱
code gardening...
View GitHub Profile
@brunojppb
brunojppb / AppDelegate.m
Created January 23, 2017 15:24
Allow landscape mode in specific ViewControllers
/* Allow Landscape mode for specific ViewControllers */
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
UIViewController* topVC = [self topViewControllerWith: self.window.rootViewController];
if ([topVC respondsToSelector:@selector(canRotate)]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
return UIInterfaceOrientationMaskPortrait;
}
/* get the top ViewController */
fetch('/users', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content')},
credentials: 'same-origin',
body: JSON.stringify( { id: 1, name: 'some user' } )
})
.then(function(data) {
$(function() {
$('#id-do-form').submit(function() {
var valuesToSubmit = $(this).serialize();
$.ajax({
type: "POST",
url: $(this).attr('action'), //sumbits it to the given url of the form
data: valuesToSubmit,
dataType: "JSON" // you want a difference between normal and ajax-calls, and json is standard
}).success(function(json){
console.log("success", json);
require 'net/http'
require 'json'
def listar_usuarios(quantidade, my_proc)
uri = URI('http://jsonplaceholder.typicode.com/users')
response = Net::HTTP.get(uri)
JSON.parse(response)
my_proc.call(quantidade)
yield JSON.parse(response) if block_given?
puts "Finalizando listagem de usuarios"
require 'net/http'
require 'json'
def listar_usuarios
uri = URI('http://jsonplaceholder.typicode.com/users')
response = Net::HTTP.get(uri)
JSON.parse(response)
yield JSON.parse(response) if block_given?
puts "Finalizando listagem de usuarios"
end
class Automovel
def self.tipo_cambio
puts "Manual"
end
def acelera
puts "Acelerando automóvel..."
end
end
class Automovel
def acelera
# Aciona injeção eletrônica
# injeta combustível e etc...
puts "Acelerando automóvel..."
end
end
class Carro < Automovel
def acelera

Comandos Iniciais

sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Instalação do RBENV e Ruby

@brunojppb
brunojppb / introrx.md
Created February 2, 2016 13:32 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
var power = function(base, exponent) {
if (exponent == undefined)
exponent = 2;
var result = 1;
for (var count = 0; count < exponent; count++)
result *= base;
return result;
};
console.log(power(2, 10));