Skip to content

Instantly share code, notes, and snippets.

View andreydeineko's full-sized avatar

Andrey Deineko andreydeineko

View GitHub Profile
@andreydeineko
andreydeineko / rails_switch_branch.py
Created December 1, 2016 15:56 — forked from skyriverbend/rails_switch_branch.py
Rails: Switch branches and run migrations
#!/usr/local/bin/python
"""
To use this script, you must be in the root directory of a Rails project that
is using git. You should also make sure that your directory does not contain any
uncommitted changes. Then run:
$ python rails_switch_branch.py name_of_another_branch
Running the above will do the following:
{
"settings": {
"analysis": {
"analyzer": {
"tags_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": "lowercase"
}
}
{
'settings': {
'index': {
'analysis': {
'analyzer': {
'tags_analyzer': {
'type': 'custom',
'tokenizer': 'keyword', # https://www.elastic.co/guide/en/elasticsearch/reference/1.5/analysis-keyword-analyzer.html
'filter': 'lowercase'
}
@andreydeineko
andreydeineko / README.md
Created February 5, 2016 21:38 — forked from wvengen/README.md
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
This is an example how to perform multi-select faceting in ElasticSearch.
Selecting multiple values from the same facet will result in an OR filter between each of the values:
(facet1.value1 OR facet1.value2)
Faceting on more than one facet will result in an AND filter between each facet:
(facet1.value1 OR facet1.value2) AND (facet2.value1)
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (filter0.sh).
# Private vs Protected
# Private methods can not be called with explicit receiver
# To make method hidden from public access and still accessible by class instances make it protected.
_____________________________________________________________________
# Extend vs Include
# In class:
# Include exposes module's methods as instance methods
http://www.thinkster.io/pick/GtaQ0oMGIl/a-better-way-to-learn-angularjs
http://www.thinkster.io/pick/GUIDJbpIie/angularjs-tutorial-learn-to-build-modern-web-apps?utm_source=buffer&utm_campaign=Buffer&utm_content=bufferf62d6&utm_medium=facebook
http://coderberry.me/blog/2013/04/22/angularjs-on-rails-4-part-1/
http://railscasts.com/episodes/405-angularjs
https://shellycloud.com/blog/2013/10/how-to-integrate-angularjs-with-rails-4
http://toddmotto.com/ultimate-guide-to-learning-angular-js-in-one-day/
http://jeff.konowit.ch/posts/yeoman-rails-angular/
http://staunchrobots.com/blog/blog/2013/10/14/up-and-running-with-angularjs-and-rails/
http://andyshora.com/promises-angularjs-explained-as-cartoon.html
http://www.rtorr.com/an-angular-workflow-part-1/