Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am dimad on github.
* I am dzema (https://keybase.io/dzema) on keybase.
* I have a public key ASAWG9L4Mtmo-BeMEKeJMtVyICzh_WamDxQl_765iEtxsgo
To claim this, I am signing this object:
;; "Normal" operation order
(->> [1 2 3]
(map inc)
(map #(* 2 %)
(reduce +))
@DimaD
DimaD / gist:af22dcce3f56ae4bf45c
Created July 31, 2014 17:14
ACM-please-join-us-and-get-a-calculator
Dear Dmitriy,
We have an exciting offer for you to join ACM, including a complimentary gift,
if you act today by visiting:
<LINK>
As a Professional Member of ACM, the Association for Computing Machinery, you will
have access to a host of career-enhancing benefits including:
Prelude> :m Control.Monad
Prelude Control.Monad> join (,) 1
(1,1)
-- So it produces pairs somehow. Let's look at type signatures
Prelude Control.Monad> :t join
join :: Monad m => m (m a) -> m a
Prelude Control.Monad> :t (,)
@DimaD
DimaD / Vagrantfile
Created March 22, 2014 11:21
Example of vagrant config which picks up a box depending on used provider.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This config uses new syntax for box names which was introduced in vagrant 1.5
Vagrant.require_version ">= 1.5"
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
-- Modified tests. Scroll down for original version
import Test.HUnit (Assertion, (@=?), runTestTT, Test(..))
import Control.Monad (void)
import Bob (responseFor)
data Reaction = Indifference | Chill | Agreement | Harm
expectedTextFor Indifference = "Whatever."
expectedTextFor Chill = "Woah, chill out!"
require "virtus"
class FinancialDocumentStatus
def initialize(status_string)
@status_string = status_string
end
def settled?
true
end
@DimaD
DimaD / how-to-write-better-code.textile
Last active December 14, 2015 02:08
For the past year I dealt a lot with novice programmers so I summarized some of my thoughts on how to help them to become better team-players and better programmers. I plan to review and expand it in the future

How to write better code

Q: How do you eat an elephant?
A: One bite at a time.

Purpose of this guide is to help you write code which is easier to use, easier to test and easier to understand by your fellows. All code examples in this guide are written in Ruby but the language does not matter because they illustrate generic problems, not Ruby-specific constructions.

The guide itself is written in English because mastering English is a very important step on a way to improve as an IT specialist.

Learn English

@DimaD
DimaD / gist:1852541
Created February 17, 2012 10:35
Redmine SettingsController#edit
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
settings = (params[:settings] || {}).dup.symbolize_keys
end
module Sunspot #:nodoc:
module Rails #:nodoc:
#
# This module provides Sunspot Adapter implementations for Mongoid
# models.
#
module Adapters
class MongoidDocumentInstanceAdapter < Sunspot::Adapters::InstanceAdapter
#
# Return the primary key for the adapted instance