This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'date' | |
| date = DateTime.now.strftime("%Y%m%d%H%M") | |
| $homedir = Dir.home | |
| $dotfiles = [ '.bash_profile', '.bashrc', '.gitconfig', '.kshrc', '.profile', '.tmux.conf', '.vimrc' ] | |
| desc "backup dotfiles" | |
| task :backup do |t| | |
| backupdir = File.join($homedir,"/",t.name) | |
| backupfile = "dotfiles-home.#{date}.tar" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'io/console' | |
| class Cursor | |
| class << self | |
| def pos | |
| res = '' | |
| $stdin.raw do |stdin| | |
| $stdout << "\e[6n" | |
| $stdout.flush | |
| while (c = stdin.getc) != 'R' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ModelForm | |
| extend ActiveSupport::Concern | |
| included do | |
| class_attribute :model_class | |
| self.model_class = self.superclass | |
| end | |
| module ClassMethods | |
| def model_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationHelper | |
| def cache_key_for(model) | |
| prefix = model.to_s.downcase.pluralize | |
| count = model.count | |
| max_updated_at = model.maximum(:updated_at).try(:utc).try(:to_s, :number) | |
| "#{prefix}/all-#{count}-#{max_updated_at}" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'shellwords' | |
| def main | |
| loop do | |
| $stdout.print ENV['PROMPT'] | |
| line = $stdin.gets | |
| if line | |
| line.strip! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Uid | |
| extend ActiveSupport::Concern | |
| included do | |
| before_create :generate_uid | |
| end | |
| def to_param | |
| self.uid | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Admin::SizesController < Admin::AdminController | |
| include OrderableController | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Exceptions | |
| extend ActiveSupport::Concern | |
| included do | |
| unless Rails.application.config.consider_all_requests_local | |
| rescue_from Exception, with: :render_error | |
| rescue_from ActiveRecord::RecordNotFound, with: :render_not_found | |
| rescue_from ActionController::RoutingError, with: :render_not_found | |
| rescue_from ActionController::UnknownController, with: :render_not_found | |
| rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'socket' | |
| require 'gosu' | |
| class GameWindow < Gosu::Window | |
| def initialize | |
| super 640, 480, false | |
| self.caption = "Client" | |
| @image = Gosu::Image.new(self,"headcrab.bmp",false) | |
| @x, @y = get("x"), get("y") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'yaml' | |
| require 'erb' | |
| require 'ostruct' | |
| class Settings < OpenStruct | |
| # Settings.new(:google_analytics) | |
| def initialize(config_file_base_name) | |
| super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env]) | |
| end |