Skip to content

Instantly share code, notes, and snippets.

@bopm
bopm / ferrum.rb
Created February 17, 2024 14:00
format.pdf do
html = ApplicationController.new.render_to_string(
template: 'pdfs/test',
formats: [:pdf],
layout: 'layouts/pdf',
assigns: { user: @user },
encoding: 'UTF-8'
)
Ferrum::Browser.new(timeout: 7).tap do |browser|
browser.content = html
@bopm
bopm / Package.json
Created October 7, 2017 11:17
Dependencies part of package.json for uirouter error report.
"dependencies": {
"@angular/animations": "^4.4.4",
"@angular/cdk": "^2.0.0-beta.10",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/forms": "^4.4.4",
"@angular/http": "^4.4.4",
"@angular/material": "^2.0.0-beta.10",
"@angular/platform-browser": "^4.4.4",
@bopm
bopm / README.md
Last active December 29, 2015 15:39 — forked from mbostock/.block

A dendrogram is a node-link diagram that places leaf nodes of the tree at the same depth. In this example, the classes (leaf nodes) are aligned on the right edge, with the packages (internal nodes) to the left. Data shows the Flare class hierarchy, courtesy Jeff Heer.

Compare to this radial layout.

@bopm
bopm / bluepill.rb
Created April 5, 2012 12:54
bluepill unicorn pill
# http://devmull.net/articles/unicorn-resque-bluepill
# http://www.jamievandyke.com/want-some-campfire-with-that-bluepill
app_name = 'rails'
app_env = 'production'
Bluepill.application(app_name) do |app|
RAILS_ROOT = "/var/www/#{app_name}/"
app.uid = app.gid = "www-rails"
app.working_dir = RAILS_ROOT
worker_queues = %w[queue]
@bopm
bopm / jabber.rb
Created May 3, 2011 10:59
jabber simple script
#!/usr/bin/env ruby
require 'rubygems'
require 'xmpp4r-simple'
message = ""
to = ARGV.delete_at(0)
ARGV.each do |a|
message << "#{a}\n"
@bopm
bopm / book.rb
Created April 29, 2011 21:08
Batch processing in rails
class Book < ActiveRecord::Base
has_many :pages
belongs_to :p2fline
belongs_to :print_profile
belongs_to :publish_profile
acts_as_audited :except => [:name, :file_name]
include AASM
aasm_column :state
@bopm
bopm / server_info.rb
Created December 8, 2010 15:50
module for getting current "port" in mongrel/unicorn environment
module ServerInfo
def server_port
port = nil
if (defined?(::Mongrel) && defined?(::Mongrel::HttpServer))
ObjectSpace.each_object(Mongrel::HttpServer) do |mongrel|
@mongrel = mongrel
end
port = @mongrel.andand.port
end
if (defined?(::Unicorn) && defined?(::Unicorn::HttpServer))
@bopm
bopm / server_info.rb
Created December 8, 2010 15:50
module for getting current "port" in mongrel/unicorn environment
module ServerInfo
def server_port
port = nil
if (defined?(::Mongrel) && defined?(::Mongrel::HttpServer))
ObjectSpace.each_object(Mongrel::HttpServer) do |mongrel|
@mongrel = mongrel
end
port = @mongrel.andand.port
end
if (defined?(::Unicorn) && defined?(::Unicorn::HttpServer))
SELECT * FROM "books" WHERE ((books.id in (:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int,:
@bopm
bopm / mydomain.conf (192.168.1.1)
Created November 28, 2010 18:30
NGINX mongrel/unicorn configuration
server {
server_name mydomain.com;
access_log /var/log/nginx/mydomain.access.log;
error_log /var/log/nginx/mydomain.error.log;
root /var/www/rails_app/public;
location ~ /\.svn/ { # мы очень не хотим, чтобы у нас одолжили код :)
deny all;