Skip to content

Instantly share code, notes, and snippets.

@mrkplt
mrkplt / gist:2715219
Created May 17, 2012 00:39
Rails App init with test framework
$ rails new <app_name> --skip-test-unit
$ cd <app_name>/
$ git init
$ git add .
$ git commit -m 'first commit'
$ git remote add origin <git repo>
$ git push -u origin master
$ mate .
/**
@mrkplt
mrkplt / com.mrkplt.sockfix.plist
Created October 19, 2011 03:51
Startup script that allows you to use the built in mysql server with Snow Leopard Server and Liip PHP (http://php-osx.liip.ch/) by symlinking the mysql.sock location to where php expects it to be. Goes in /Library/LaunchDaemons. Restart the server.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mrkplt.sockfix</string>
<key>Program</key>
<string>/bin/ln</string>
<key>ProgramArguments</key>
<array>
package main
import (
"net/http"
"github.com/mrkplt/end_point/models"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
### Keybase proof
I hereby claim:
* I am mrkplt on github.
* I am mrkplt (https://keybase.io/mrkplt) on keybase.
* I have a public key whose fingerprint is B63F B8E1 BE81 FBAF E770 6DB7 2D7F 0EBC 0074 AC2E
To claim this, I am signing this object:
@mrkplt
mrkplt / environment_check.rb
Last active August 29, 2015 14:22
Environment check for safer rake tasks.
module EnvironmentCheck
MESSAGE = "This action is destructive. Proceed?"
def self.execute(message = MESSAGE)
return command_line_output unless inquiry(message) == 'y'
yield if block_given?
end
private
@mrkplt
mrkplt / gist:7fb65807e60e9ce8aec2
Last active August 29, 2015 14:17
Awful coupling, Demeter violation
class A
attr_reader :b
def initialize
@b = B.new
end
end
class B
attr_reader :c
class BadDemeter
# this is an example that abuses LoD. I am not saying that your code
# can't look like this for other reasons.
def thinger
useless_abstraction_three.last
end
private
@mrkplt
mrkplt / gist:0b06015b4ecd00a55ce8
Last active August 29, 2015 14:17
Playing with Go channels
package main
import "fmt"
func main() {
messages := make(chan string)
return_messages := make(chan string)
go func() { return_messages <- "ping" }()
@mrkplt
mrkplt / gist:b114d2525a03cfb95acd
Created March 22, 2015 13:34
composition example
# https://www.youtube.com/watch?v=gRpUfjTwSOo&utm_source=golangweekly&utm_medium=email
package main
import "fmt"
type user struct {
name string
email string
}
# http://www.brianstorti.com/implementing-a-priority-queue-in-ruby
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
end
def <<(element)
@elements << element