Skip to content

Instantly share code, notes, and snippets.

@janjiss
janjiss / test.rb
Last active August 29, 2015 14:20
require "virtus"
require "rspec"
class Test
include Virtus.model(:nullify_blank => true)
attribute :name, String
end
RSpec.describe Test do
it "should be nil" do
test = Test.new(name: "")
Generated elixir_stream_phoenix.app
[info] Running ElixirStreamPhoenix.Endpoint with Cowboy on port 4000 (http)
21 Apr 00:10:12 - info: compiled 26 files into 2 files in 894ms
[info] GET /
[info] Processing by ElixirStreamPhoenix.PageController.index/2
Parameters: %{"format" => "html"}
Pipelines: [:browser]
[info] Sent 200 in 27ms
[info] GET /
[info] Processing by ElixirStreamPhoenix.PageController.index/2
require 'classifier'
require 'simple-rss'
require 'open-uri'
require "pry"
b = Classifier::Bayes.new 'artur', 'janis'
janis_rss = SimpleRSS.parse open('http://codingwithaxe.com/rss')
janis_rss.items.take(5).each do |i|
➜ phoenix_pubsub mix test
Compiled lib/phoenix_pubsub.ex
Compiled lib/pubsub/pg2.ex
Compiled lib/pubsub/redis.ex
Compiled lib/pubsub/redis_conn.ex
Compiled lib/pubsub/pg2_server.ex
Compiled lib/pubsub/redis_server.ex
Compiled lib/pubsub/local.ex
Compiled lib/pubsub.ex
Generated phoenix_pubsub.app
defmodule Hello do
def start do
hello = function_1
function_2(hello)
function_1 |>
function_2
end
@janjiss
janjiss / gist:9039034
Last active August 29, 2015 13:56
Example 1, updated
require "json"
require "rspec"
require "date"
json_data = <<-JSON
{"activities": [
{
"captured_at": 1392366463,
"distance": "1.12",
"duration": 12,
@janjiss
janjiss / gist:9023711
Created February 15, 2014 19:06
Example 1
require "json"
require "rspec"
json_data = <<-JSON
{"activities": [
{
"captured_at": 1392366463,
"distance": "1.12",
"duration": 12,
"calories": 100
nmap <Up> :!x-www-browser "http://www.youtube.com/watch?v=dQw4w9WgXcQ"<CR>
nmap <Down> :!x-www-browser "http://www.youtube.com/watch?v=dQw4w9WgXcQ"<CR>
nmap <Left> :!x-www-browser "http://www.youtube.com/watch?v=dQw4w9WgXcQ"<CR>
nmap <Right> :!x-www-browser "http://www.youtube.com/watch?v=dQw4w9WgXcQ"<CR>
@janjiss
janjiss / gist:8362251
Created January 10, 2014 20:47
Failing tests on mix
==> mix (exunit)
.......................................................
1) test prints list of dependencies and their lock status (Mix.Tasks.DepsTest)
** (MatchError) no match of right hand side value: [""]
stacktrace:
lib/mix/scm/git.ex:132: Mix.SCM.Git.get_rev_info/0
lib/mix/scm/git.ex:32: Mix.SCM.Git."-lock_status/1-fun-0-"/4
/home/janjiss/elixir/lib/elixir/lib/file.ex:913: File.cd!/2
lib/mix/deps.ex:273: Mix.Deps.check_lock/2