Skip to content

Instantly share code, notes, and snippets.

@orbanbotond
orbanbotond / chewy usage
Last active August 29, 2015 14:16
chewy usage
[["Cseva", ["csevapcsicse"]], ["Cseva", ["masik", "cseva"]], ["Masik", ["harmadik"]], ["Egyik", ["masik"]]]
SearchIndex.delete!
SearchIndex.reset!
SearchIndex.purge!
res = SearchIndex.filter(term: {account_id: 1}).query( multi_match: { query: 'masik', fields: ['name', 'descriptions']})
res.to_a
a = Subscribem::Account.find 1
r = Recipe.scoped_to(a).first
t = r.tasks.first
@orbanbotond
orbanbotond / erb2slim
Created February 17, 2015 14:36
erb2slim
gem install haml
gem install hpricot
gem install ruby_parser
gem install haml2slim
gem install html2slim
erb2slim -h
@orbanbotond
orbanbotond / Rspec noun-phrase
Created January 23, 2015 12:26
Rspec noun-phrase
be_odd
be_an
be_done
be_an_ufo calls ufo?
an_object_eq_to
an_object_having_attributes
a_string_starting_with
a_string_ending_with
a_string_matching
a_value
@orbanbotond
orbanbotond / double_spy_mocks.rb
Created January 22, 2015 14:36
Doubles Spies Mocks
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.pragmaticprogrammer.com/titles/nrtest2 for more book information.
#---
require 'rails_helper'
@orbanbotond
orbanbotond / LeanKit Popular Ruby Book Sort
Created January 6, 2015 14:31
Leankit Popular Book Sort
@orbanbotond
orbanbotond / logger
Created December 29, 2014 12:16
logger and rails logger snippets
<snippet>
<content><![CDATA[logger.${1:debug} "${2:your debug info}"]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>log</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.ruby</scope>
</snippet>
<snippet>
<content><![CDATA[Rails.logger.${1:debug} "${2:your debug info}"]]></content>
@orbanbotond
orbanbotond / Google API Calls
Created August 15, 2014 14:09
Google Api calls
Retrieve token from refresh Google:
curl -v -F refresh_token=1/947yjadmRUOuFcg9EKsIPt_A1z3hklTR1F_wnP7NIbw -F client_id=633713095109-t1d7unbqb8rjc9e88rtngi4fkpietaot.apps.googleusercontent.com -F client_secret=Be9G1-cA7-kCOm8nRAsCCPAB -F grant_type=refresh_token https://accounts.google.com/o/oauth2/token
@orbanbotond
orbanbotond / Usefull Tricky Unix Commands
Last active January 4, 2016 15:42
Usefull tricky Unix commands
Ok:
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: 2c84ba63636d9555ee4dba8a610e704b5d1f8a1133179dec6ba9450f6ee4457ee0ae450672d3c7e6fcdce00a84ba73f4d5a403adb7677e9750ba68e5f00450d9" \
--data-binary "{ \"token\": \"522aa06304052ff5a98cb482fb3a089a97c217fc3298d43146ebe65c2f8b65ac\", \"location\": \"New York\", \"participants\": [ {\"id\": 4} ], \"guests\": [ {\"email\": \"johny_cage@gmail.com\", \"first_name\": \"Johny\", \"last_name\": \"Cage\" } ]}" \
'http://localhost:3000/api/v1/meetings/xx'
Ok:
curl -v \
@orbanbotond
orbanbotond / polo1_spec.rb
Created December 2, 2013 09:59
ruby_spec.rb
describe 'ruby' do
context 'spiritual' do
specify do
expect(:ruby).to provide_happyness(:huge)
end
end
context 'material' do
specify do
expect(:good_salary).to be_present(:always)
end
@orbanbotond
orbanbotond / tree for named route
Created November 7, 2013 08:53
tree for named route...
Utils.build_path(["q"], ["organization","format"],
[2,
[2,
[2,
[2,
[1,
[2,
[2,
[2,