Skip to content

Instantly share code, notes, and snippets.

View artofhuman's full-sized avatar
💭
I use vim, btw

Semyon Pupkov artofhuman

💭
I use vim, btw
View GitHub Profile
require 'spec_helper'
require 'ostruct'
class FakePostRepo
attr_reader :posts
def initialize
@posts = []
end
@artofhuman
artofhuman / authentication.rb
Created January 27, 2017 17:36 — forked from adhrinae/authentication.rb
Hanami User Authentication with session
# web/controllers/authentication.rb
module Web
module Authentication
module Skip
def authenticate!
end
end
def self.included(action)
action.class_eval do
@artofhuman
artofhuman / unused_routes.rb
Created May 15, 2016 05:15 — forked from strzibny/unused_routes.rb
Find unused routes in Rails
#!/usr/bin/env ruby
# Extracted from traceroute gem + checking the presence of views as well
require_relative './config/environment.rb'
class Traceroute
def initialize(app)
@app = app
end
bgkey = ::BgExecutor::Configuration[:redis][:namespace] + ':bg_executor:jobs_queue'
job_name = 'map_coord'
# Test:
result = []
($redis.llen bgkey).times { |idx| val = ($redis.lindex bgkey, idx).to_s; result << val if val.include?(job_name) }
# And Run:
# ($redis.llen bgkey).times { |idx| val = ($redis.lindex bgkey, idx); $redis.lrem bgkey, 0, val if val.include?(job_name) }
#!/bin/bash
# Update and upgrade packages
sudo apt-get update && sudo apt-get upgrade
# Install postgres 9.3
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
# Having Postgres 9.2 already, this will create database instance configured to run on port 5433
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@import "active_admin/mixins"
@import "active_admin/components/links"
body
@include global-reset
@import "active_admin/typography"
@import "active_admin/header"
@import "active_admin/forms"
@import "active_admin/components/comments"
@import "active_admin/components/flash_messages"
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@artofhuman
artofhuman / vim.rb
Created December 27, 2012 18:36 — forked from voldmar/vim.rb
# To use this recipe you have to:
# $ brew install python --framework
# $ mkdir ~/Frameworks
# $ ln -s "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework" ~/Frameworks
# $ brew install ./vim.rb
require 'formula'
require 'open-uri'
class Vim < Formula