Skip to content

Instantly share code, notes, and snippets.

View Lackoftactics's full-sized avatar

Przemyslaw Mroczek Lackoftactics

  • Warsaw, Poland
  • 16:19 (UTC +02:00)
View GitHub Profile
context "Validates presence of either start time or open time" do
setup do
@user = FactoryGirl.create(:user)
@account = FactoryGirl.create(:account, user: @user)
@location = FactoryGirl.create(:location, account: @account)
end
should "not be valid without open time or start time " do
event = FactoryGirl.build(:event, fb_id: '12345', account: @account, location: @location, start_at: nil, open_at: nil, end_at: Time.now + 1.hour)
assert !event.valid?
context "Validates presence of either start time or open time" do
setup do
@user = FactoryGirl.create(:user)
@account = FactoryGirl.create(:account, user: @user)
@location = FactoryGirl.create(:location, account: @account)
end
should "not be valid without open time or start time " do
event = FactoryGirl.build(:event, fb_id: '12345', account: @account, location: @location, start_at: nil, open_at: nil, end_at: Time.now + 1.hour)
assert !event.valid?
{"first_name":"Tomek","last_name":"K","avatar_url":null,"short_address":"Brandenburg, Germany","user_url":"/users/user5-el","pending_friendships":[{"agripoints":0,"avatar_content_type":null,"avatar_file_name":null,"avatar_file_size":null,"avatar_updated_at":null,"confirmation_reminder":false,"created_at":"2013-06-11T14:17:51Z","deals_newsletter":false,"email":"user5@agricircle.com","first_name":"User5","id":20,"language":"English","last_name":"El","newsletter":false,"slug":"user5-el","terms_of_service":true,"title":"Mr","updated_at":"2013-06-11T14:17:51Z","user_type":"Farmer","website":"http:\\codequest.com"}]}
#encoding: utf-8
def fetch_job_links
job_links = []
if next_page_selector
index_doc = Nokogiri::HTML(open(url))
base_url = parse_base_url(url, index_doc)
pagination = index_doc.at_xpath(next_page_selector)
next_page_link = URI.join(base_url, pagination['href']).to_s rescue nil
##przed tą pętlą ustawia mi się next_page_link na nila, wiesz może dlaczego?
@Lackoftactics
Lackoftactics / gist:f04fc1b4fe03b8492e29
Last active August 29, 2015 14:11
Pry rescue rails s
$ rescue rails s
@Lackoftactics
Lackoftactics / gist:dcfba348c9b3ff9b4ea0
Created December 9, 2014 17:43
pry rescue rake spec
$ rescue rspec
From: /home/przemek/Projects/dirble/spec/station_spec.rb @ line 20 :
15: station = Dirble::Station.by_continent('Asia').first
16: expect(station.name).to eq('Lounge Beats')
17: end
18:
19: it 'returns station filtered by country using iso code' do
=> 20: station = Dirble::Station.by_country_code('us').first
21: expect(station.country).to eq('US')
22: end
@Lackoftactics
Lackoftactics / elasticearch.txt
Last active June 26, 2017 10:29
Elasticsearch
curl -X PUT localhost:9200/books -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"autocomplete_analyzer" : {
"type" : "custom",
"tokenizer" : "lowercase",
@Lackoftactics
Lackoftactics / el
Last active February 9, 2018 15:07
elastic normalizers hell
curl -XGET 'localhost:9200/events/_analyze?pretty' -H 'Content-Type: application/json' -d'
{
"normalizer" : "sortable",
"text" : "Triathlon race "
}
'
curl -XPUT 'localhost:9200/events/' -H 'Content-Type: application/json' -d'
{
"settings": {"analysis":{"filter":{"ngram_small_filter":{"type":"nGram","min_gram":2,"max_gram":5},"ngram_medium_filter":{"type":"nGram","min_gram":3,"max_gram":20}},"analyzer":{"index_ngram_small_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","ngram_small_filter"]},"index_ngram_medium_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","ngram_medium_filter"]},"search_standard_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase"]}},"normalizer":{"sortable":{"type":"custom","char_filter":[],"filter":["lowercase"]}}}},
@Lackoftactics
Lackoftactics / launctl.sh
Last active February 9, 2018 15:48
Unload launchtl (program starters
launchctl unload /Users/przemyslawmroczek/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
launchctl remove /Users/przemyslawmroczek/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
rm /Users/przemyslawmroczek/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
brew services stop elasticsearch
brew uninstall elasticsearch