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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Automovel | |
def self.tipo_cambio | |
puts "Manual" | |
end | |
def acelera | |
puts "Acelerando automóvel..." | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |