This file contains hidden or 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 UeberTest.AuthController do | |
use UeberTest.Web, :controller | |
plug Ueberauth | |
alias Ueberauth.Strategy.Helpers | |
def request(conn, _params) do | |
render(conn, "request.html", callback_url: Helpers.callback_url(conn)) | |
end | |
def callback(%{assigns: %{ueberauth_failure: _fails}} = conn, _params) do |
This file contains hidden or 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
def compare(conn, params) do | |
first = params["code"]["first_snippet"] | |
second = params["code"]["second_snippet"] | |
code = """ | |
defmodule Sample do | |
def benchee do | |
Benchee.init(%{time: 3}) | |
|> Benchee.benchmark('first snippet', fn -> #{first} end) | |
|> Benchee.benchmark('second snippet', fn -> #{second} end) |
This file contains hidden or 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
def compare(conn, params) do | |
first = params["code"]["first_snippet"] | |
second = params["code"]["second_snippet"] | |
{val, _} = Code.eval_string("Benchee.init(%{time: 3}) | |
|> Benchee.benchmark('First', fn -> #{first} end) | |
|> Benchee.benchmark('Second', fn -> #{second} end) | |
|> Benchee.measure | |
|> Benchee.statistics | |
|> BencheeWeb.Formatter.to_map") |
This file contains hidden or 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 MyMacros do | |
defmacro benchee(suite, name, function) do | |
quote do | |
benchee.benchmark(unquote(suite), unquote(name), unquote(function)) | |
end | |
end | |
end |
This file contains hidden or 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
Path.join("#{:code.priv_dir(:random_tweets)}", filename) | |
|> RandomTweets.File.get_line | |
|> ExTwitter.update | |
This file contains hidden or 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
def get_line(path) do | |
path | |
|> File.read! | |
|> String.split(~r{\n}) | |
|> Enum.map(&String.strip/1) | |
|> Enum.filter(fn x -> String.length(x) <= 140 end) | |
|> Enum.random | |
end |
This file contains hidden or 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
using UnsignedInteger = System.UInt16; // Sorry, I can't unabbreviate it on the RHS | |
// https://twitter.com/taylonr/status/712277308363542530 | |
namespace FizzBuzz | |
{ | |
class Program | |
{ | |
static void Main(System.String[] args) | |
{ |
This file contains hidden or 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
$scope.isBalancePositive = function(){ | |
if($scope.balance > 0){ | |
return true; | |
} | |
} |
This file contains hidden or 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
describe('User Service...', function(){ | |
var userService, | |
customerService, | |
scope; | |
beforeEach(inject(function(testHelper){ | |
userService = testHelper.setUpMocksWithSpies('UserService'); | |
customerService = testHelper.setUpMocksWithSpies('CustomerService'); | |
This file contains hidden or 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 _ = require('lodash'), | |
ActivityController = require('../../../controllers/activity.controller'), | |
FakeDatabase = [ | |
{userId: '123', Name: 'First Activity', Records: [{Date: new Date(2014, 1, 1)}]}, | |
{userId: '123', Name: 'Second Activity', Records: [{Date: new Date(2014, 2, 1)}]}]; | |
require('underscore-query')(_); | |
ActivityController.Activity.find = function(findObject, callback){ | |
var activities = _.query(FakeDatabase, findObject); |
NewerOlder