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 'json' | |
require 'open-uri' | |
require 'uri' | |
class GoogleProductsSearch | |
def self.find_all_by_query(query) | |
file = open("https://www.googleapis.com/shopping/search/v1/public/products?key=#{ENV["GOOGLE_PRODUCTS_API_KEY"]}&country=US&q=#{URI.escape(query)}") | |
JSON.load(file.read)["items"] || [] | |
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
# Node A: | |
# iex --sname "nodea" | |
Process.register self, :iex | |
# Blocking | |
receive do | |
{ :hello, pid } -> | |
IO.puts "Hello from #{inspect(pid)}" | |
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
require 'csv' | |
require 'twitter' | |
def twitter_client | |
@twitter_client ||= Twitter::REST::Client.new do |config| | |
config.consumer_key = 'XXXXXX' | |
config.consumer_secret = 'XXXXXX' | |
config.access_token = 'XXXXXX' | |
config.access_token_secret = 'XXXXXX' | |
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
defmodule Future do | |
def new(fun) do | |
fn(x) -> | |
spawn_link fn -> | |
value = try do | |
{ :ok, fun.(x) } | |
rescue | |
e -> { :error, e } | |
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
# app/controllers/users/password_controller.rb | |
class Users::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(:user).permit(:email, :password, :password_confirmation, :reset_password_token) | |
end | |
private :resource_params | |
end |
OlderNewer