class ContentSuggestionEnqueuer
def self.enqueue
User.where(subscribed: true).pluck(:id).each do |user_id|
ContentSuggestionWorker.perform_async(user_id)
end
end
end
To count objects in current thread you can use this approach.
class OtherKlass
end
OtherKlass.new
OtherKlass.new
ObjectSpace.each_object(OtherKlass){} # => 2
⇐ back to the gist-blog at jrw.fi
Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.
I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.
This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso
In the controller action
image_file = change_img_params(params[:avatar]) #params[:avatar] - base64 string
def change_img_params(img)
begin
Base64.decode64(img) #To check if thats a base64 string
if img
img = file_decode(img.split(',')[1],"some file name") #getting only the string leaving out the data/<format>
end
apt-cache policy MY_PACKAGE
- get list of available version or like this apt-cache madison MY_PACKAGE
The purpose of this document is to make recommendations on how to browse in a privacy and security conscious manner. This information is compiled from a number of sources, which are referenced throughout the document, as well as my own experiences with the described technologies.
I welcome contributions and comments on the information contained. Please see the How to Contribute section for information on contributing your own knowledge.
class FlatArray
attr_reader :nested_array, :result
def initialize(nested_array = [])
@nested_array = nested_array
@result = []
end
def call
As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.
All the complexity is handled by ActiveRecord::Transactions
. Any model class or instance has a method named .transaction
. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.
Cucumber step with dynamic the end:
When(/^I enter (\d+)(?:st|nd|rd|th) record/) do |n|
# my interations
end
I was having the same problem. Ubuntu 14,04 here. I found this answer in a forum that solved the problem for me.
After struggling a bit, I found some useful commands. You can type these in any skype chat window.
/dumpmsnp
- show details about your connection
/showplaces
- show where you are currently connected
What was happening was that /dumpmsnp command was showing "LoggedOut", but I was online and talking almost normally (except group chats).