Returns a collection of the most recent articles written by a user (as defined by the :user parameter).
https://api.awesomesite.com/articles/user_articles.json
---------- | ---------:
| # When we're working with validations in AR, remember that most of them are accepting hashes as arguments. | |
| # For example, we could re-write | |
| validates :email, { :uniqueness => true } | |
| # as | |
| validates(:email, { :uniqueness => true }) | |
| # which pretty clearly shows that we have two arguments for the validates method, a symbol and a hash |
| $(document).ready(function() { | |
| navigator.geolocation.getCurrentPosition(successCallback,errorCallback,options); | |
| }); | |
| var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | |
| var dayOfWeekIndex = (new Date()).getDay(); |
Returns a collection of the most recent articles written by a user (as defined by the :user parameter).
https://api.awesomesite.com/articles/user_articles.json
---------- | ---------:
| begin | |
| require 'bundler/inline' | |
| rescue LoadError => e | |
| $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
| raise e | |
| end | |
| gemfile(true) do | |
| source 'https://rubygems.org' | |
| gem 'rails', '~> 4.2.3' |
| iex(1)> defmodule Tester do | |
| ...(1)> defstruct [:first, :second] | |
| ...(1)> def foo_to_bar(struct = %{__struct__: struct_module}) do | |
| ...(1)> updated_list = struct | |
| ...(1)> |> Map.from_struct | |
| ...(1)> |> Enum.map(fn({key, value}) -> | |
| ...(1)> if value == :foo do | |
| ...(1)> {key, :bar} | |
| ...(1)> else | |
| ...(1)> {key, value} |
| require 'twitter' | |
| client = Twitter::REST::Client.new do |config| | |
| config.consumer_key = "" | |
| config.consumer_secret = "" | |
| config.access_token = "" | |
| config.access_token_secret = "" | |
| end | |
| def collect_with_max_id(collection=[], max_id=nil, &block) |
| import Header from './header.jsx'; | |
| function headerFun(input) { | |
| <h1>{input.name}</h1> | |
| } | |
| function DesktopHeader(input) { | |
| <Header {...{input, headerFun}} /> | |
| } |
| defmodule SendAfter do | |
| def send_after(pid, message, nanoseconds) do | |
| {_, os_name} = :os.type() | |
| increment = | |
| if os_name == :Windows do | |
| # monotonic time for Windows in miliseconds, in Linux and MacOS it's nanoseconds | |
| # so we'll need to convert to miliseconds for windows | |
| nanoseconds / 1_000_000 | |
| else | |
| nanoseconds |
| #!/usr/bin/env escript | |
| %% -*- erlang -*- | |
| %%! -smp enable -sname wtf | |
| main(_) -> | |
| process_flag(trap_exit, true), | |
| ToMap = lists:seq(1, 50), | |
| MapFun = fun() -> | |
| lists:map(fun(N) -> N end, ToMap) | |
| end, | |
| start_runner(MapFun), |
| for num <- [1, 2, 3], num < 3, do: num * 2 |