Skip to content

Instantly share code, notes, and snippets.

View crmaxx's full-sized avatar

Maxim Zhukov crmaxx

  • Russia, Vladimir
View GitHub Profile
@crmaxx
crmaxx / open_stuct.rb
Created July 9, 2014 12:20
monkey patch for OpenStruct
class OpenStruct
# Insert/update hash data on the fly.
#
# o = OpenStruct.new
# o.merge!(:a => 2)
# o.a #=> 2
#
def merge!(other)
fails TypeError, "can't modify frozen #{self.class}", caller(1) if self.frozen?
other.each { |k, v| @table[k.to_sym] = v }
My quick notes on what I did to install Elixir on the Raspberry Pi.
All the info is here, but it's a self guided tour.
# Get Raspbian
http://www.raspberrypi.org/downloads
http://downloads.raspberrypi.org/raspbian_latest
# Copy raspbian.img file to th SD Card
diskutils unmountDisk /dev/disk<numberhere>
@crmaxx
crmaxx / pg_upgrade.markdown
Last active August 29, 2015 14:12
Upgrade PostgresSQL to 9.4.0

from http://stackoverflow.com/a/27624397

Assuming you've used home-brew to install and upgrade Postgres, you can perform the following steps.

Stop current Postgres server:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Initialize a new 9.4 database:

@crmaxx
crmaxx / pg_fix.sh
Created January 16, 2015 08:18
Fix role "postgres" does not exist
/usr/local/Cellar/postgresql/9.4.0/bin/createuser -s postgres
@crmaxx
crmaxx / SocketClientActor.scala
Created January 28, 2015 07:48
Как готовить Akka.IO от Шниперсона Александра
import akka.actor.{Props, ActorLogging, Actor, ActorRef}
import akka.io.Tcp
import ProtoMessages.MessageRequestBase.MessageRequest
import ProtoMessages.MessageResponseBase.MessageResponse
import net.orionlab.brr.utils.CoreSystem
import net.orionlab.brr.CommunicationMessage.BinarySerializer
import akka.util.ByteString
case class IncomingMessage(message: MessageRequest)
@crmaxx
crmaxx / .rubocop.yml
Last active August 29, 2015 14:15
Current rubocop config
Style/IfUnlessModifier:
MaxLineLength: 120
Style/WhileUntilModifier:
MaxLineLength: 120
Style/AsciiComments:
Enabled: false
Style/DotPosition:
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits._
import scala.util.{ Success, Failure }
import akka.actor._
import akka.pattern.{ after, ask, pipe }
import akka.util.Timeout
object LogSearch extends App {
@crmaxx
crmaxx / .rubocop.yml
Created March 6, 2015 08:19
My rubocop rules
Style/IfUnlessModifier:
MaxLineLength: 120
Style/WhileUntilModifier:
MaxLineLength: 120
Style/AsciiComments:
Enabled: false
Style/DotPosition:
def takeUpToNot[T](pred: (T) => Boolean): Iteratee[T, Seq[T]] = {
def step(ok: Boolean, result: Seq[T])(i: Input[T]): Iteratee[T, Seq[T]] = i match {
case Input.EOF | Input.Empty => Done(result, Input.EOF)
case Input.El(e) =>
if (ok) Cont[T, Seq[T]](i => step(pred(e), result :+ e)(i))
else Done(result, Input.EOF)
}
Cont[T, Seq[T]](i => step(ok = true, Vector())(i))
}
@crmaxx
crmaxx / .psqlrc
Created April 18, 2015 11:18
~/.psqlrc
\set QUIET 1
\timing
\set ON_ERROR_ROLLBACK interactive
\set VERBOSITY verbose
\x auto
\set PROMPT1 '%[%033[1m%]%M %n@%/%R%[%033[0m%]%# '
\set PROMPT2 ''
\set HISTFILE ~/.psql_history- :DBNAME
\set HISTCONTROL ignoredups
\set COMP_KEYWORD_CASE upper