Mohammad AbuShady2021-02-02T11:23:42+02:00http://blog.abushady.comMohammad AbuShadyblog@abushady.comUsing the null object pattern2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/05/09/using_null_objects_pattern
<p>This is a common problem, you have an object, and that object does some logic,
and then you find that at some point this logic needs a special condition,
because the object is null, or somet variable inside it that holds another
variable is null, here’s a small example
<a href='/2015/05/09/using_null_objects_pattern.html?ref=rss'>Continue reading</a><hr />
Some rails console tips and tricks2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/05/03/rails_console_tips_and_tricks
<p>Any rails developer probably uses rails console every day, when testing methods,
when debugging, or doing some database modifications, knowing some convenient
tips will make you save some time, and on the long run you’ll become more
productive with these simple tricks.</p>
<a href='/2015/05/03/rails_console_tips_and_tricks.html?ref=rss'>Continue reading</a><hr />
How to stop ActiveRecord logs temporarily in heavy queries2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/04/25/stop-active-record-logs-temporarily
<p>When I’m writing a heavy query rake task or just running something in the
console that does a lot of updates, and i want to output something it gets lost
in all the query logs output.
<a href='/2015/04/25/stop-active-record-logs-temporarily.html?ref=rss'>Continue reading</a><hr />
Using rails low level caching2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/04/02/using_rails_low_level_caching
<p>Some times we find our selves having a time expensive method or in some cases
using an API that costs money per request, or a slow one, I had that issue once
when using twitter API, I was fetching the last tweet for a website, and
sometimes that request took a second or two to return, which was annoying.
<a href='/2015/04/02/using_rails_low_level_caching.html?ref=rss'>Continue reading</a><hr />
Installing and running elasticsearch on debian jessie2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/03/12/installing-elasticsearch-on-debian-jessie
<p>Recently I needed to install elasticsearch on my debian jessie laptop, first I
found it in the repos so I installed it normally, it installed a bunch of stuff
with it that I didn’t actually need but I thought like fine w/e it needs, I need
it to work to finish my task, and at the end it didn’t really work anyways.
<a href='/2015/03/12/installing-elasticsearch-on-debian-jessie.html?ref=rss'>Continue reading</a><hr />
Maintaining database atomicity using ActiveRecord transactions2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/03/10/maintaining-database-atomicity
<p><a href="https://en.wikipedia.org/wiki/Atomicity_%28database_systems">Atomicity</a> comes from the greek word ‘a-tomos’ which means
undevidable, atomic database transactions means that we want either all the
database operations to happen together, or none of them at all, which means that
we want them as a single undevidable operation, we would want that because not
doing any of the changes at all would be much less harmful than doing the a
part of the change.
<a href='/2015/03/10/maintaining-database-atomicity.html?ref=rss'>Continue reading</a><hr />
Using active record's #merge to separate concerns2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/03/02/using-active-records-merge-to-separate-concerns
<p>We’ve all written this kind of code at some point of our lives, a query that
requires a join, and adding a condition to the joined table to limit the
returned results, but then by doing that you’re adding a dependency, and you are
coupling the two models together.
<a href='/2015/03/02/using-active-records-merge-to-separate-concerns.html?ref=rss'>Continue reading</a><hr />
Added an RSS feed for the blog2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/03/01/added-an-rss-feed-to-the-blog
<p>I’ve added an RSS feed for the blog to make it easier for people who are reading
this blog - if any - be able to keep track of my posts and find out when the new
posts come out, you can access the rss feed <a href="atom.xml">from this link</a> or you
can just hit the feed button on your browser.</p>
Wrote my first ruby gem2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/02/28/wrote-my-first-gem
<p>I was helping a fellow developer on his rails project, and I found something
interesting in his code, it was a query on how to find if two date intervals are
intersecting or not.
<a href='/2015/02/28/wrote-my-first-gem.html?ref=rss'>Continue reading</a><hr />
Law of demeter and rails delegation2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/02/23/law-of-demeter-using-rails-delegation
<h2 id="defining-law-of-demeter">Defining law of demeter</h2>
<p>The <a href="https://en.wikipedia.org/wiki/Law_of_Demeter">law of demeter</a> simply states that objects should
only talk to them selves or objects directly associated to them selves, because
otherwise this is considered a dependency and would reduce maintainability and
cause tight coupling between objects.
<a href='/2015/02/23/law-of-demeter-using-rails-delegation.html?ref=rss'>Continue reading</a><hr />
Built my very own vimrc from scratch2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/02/02/built-my-very-own-vimrc
<p>I’ve been writing using IDE’s since a long time, when I started using linux about 5 years ago, I thought people
who use vim are some crazy people who like to do things the hard way, until one day I decided to read about vim myself,
<a href='/2015/02/02/built-my-very-own-vimrc.html?ref=rss'>Continue reading</a><hr />
Routing all dev domains to localhost2021-02-02T11:23:42+02:00http://blog.abushady.com/2015/01/20/routing-all-dev-domains-to-local-host
<p>When developing locally, you might find your self that you often need to route
some domain to localhost, for example <code class="language-plaintext highlighter-rouge">my-amazing-website.dev</code><br />
<a href='/2015/01/20/routing-all-dev-domains-to-local-host.html?ref=rss'>Continue reading</a><hr />
Using different ssh keys for different hosts2021-02-02T11:23:42+02:00http://blog.abushady.com/2014/10/27/using-different-ssh-keys-for-different-hosts
<p>By default the SSH private key is given the name <code class="language-plaintext highlighter-rouge">id_rsa</code> or <code class="language-plaintext highlighter-rouge">id_dsa</code> and if you try to use a different key and give it another name it wont be detected by SSH command,
you could use the <code class="language-plaintext highlighter-rouge">ssh -i</code>, but there’s a better way -in my opinion at least- to do that
<a href='/2014/10/27/using-different-ssh-keys-for-different-hosts.html?ref=rss'>Continue reading</a><hr />
Select, Reject, Collect, Detect, Inject2021-02-02T11:23:42+02:00http://blog.abushady.com/2014/08/27/select-reject-collect-detect-inject
<p>I’ve recently learned those convenient functions that apply on any array, or
just basically any enumerable, all these functions take a block and according
to this block’s output the return is decided, those methods are select, reject,
collect, detect, inject.</p>
<a href='/2014/08/27/select-reject-collect-detect-inject.html?ref=rss'>Continue reading</a><hr />