Skip to content

Instantly share code, notes, and snippets.

View avsej's full-sized avatar
🛋️
On the couch

Sergey Avseyev avsej

🛋️
On the couch
View GitHub Profile
@avsej
avsej / fix_content_type.rb
Created March 26, 2010 17:49
This rack middleware can be used to detect content type of attachment
require 'shellwords'
class FixAttachmentContentType
def initialize(app)
@app = app
end
def call(env)
if form_hash = env["rack.request.form_hash"]
fix_tempfiles(form_hash)
#!/bin/sh
sudo route delete default
sudo route add default gw 192.168.0.199
ruby ~/script/gwwin_login.rb username password
@echo off
pause
net stop "wuauserv"
echo importing setup-wsus.reg
%windir%\regedit.exe /s setup-wsus.reg
echo setup-wsus.reg imported succesfully
net start "wuauserv"
echo forcing update detection
wuauclt /detectnow
pause
@avsej
avsej / vim-alternatives.sh
Created April 11, 2010 09:46
install alternatives for vim
#!/bin/sh
set -e
pkg=vim
mandir=/usr/share/man
bindir=/usr/local/bin
priority=30
update-alternatives --install /usr/bin/vim vim $bindir/vim $priority
update-alternatives --install /usr/bin/vimdiff vimdiff $bindir/vim $priority
def feedback(object)
setup_mail(object)
@body[:object] = object
@subject = truncate(object.title, :lenght => 64)
unless object.attachments.empty?
content_type "multipart/mixed"
part :content_type => "text/plain", :body => render_message("feedback", @body)
object.attachments.each do |item|
require 'rubygems'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
require 'irb/completion'
require 'hirb'
# Hirb::View.enable
def change_log(stream)
ActiveRecord::Base.logger = Logger.new(stream)
@avsej
avsej / README
Created May 27, 2010 18:15
Google sitemap generator scripts
These files describes how to configure automatic google sitemap
generation.
1. In your models you should define class method which will be generate
array or urls with last modified timestamp.
2. In 'lib/tasks/google_sitemap.rb' you should update 'sources' and
'host' variables for your site.
3. You should configure cron tasks to periodically regenerate sitemap
and ping google. You could use nice gem whenever and sample schedule
in 'config/schedule.rb'
@avsej
avsej / gist:416876
Created May 28, 2010 07:28
My font config. I like DejaVu fonts
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font" >
<edit mode="assign" name="rgba" >
<const>rgb</const>
</edit>
</match>
<match target="font" >
<edit mode="assign" name="hinting" >
# set up the databases
rake "db:create", :env => 'development'
rake "db:create", :env => 'test'
# install required gems
gem "haml"
run "haml --rails ."
# run nifty generators
generate :nifty_layout, "--haml"
./guile_filter_doc_snarfage --filter-snarfage) > regex-posix.doc || { rm regex-posix.doc; false; }
cat alist.doc arbiters.doc array-handle.doc array-map.doc arrays.doc async.doc backtrace.doc boolean.doc bitvectors.doc bytevectors.doc chars.doc control.doc continuations.doc debug.doc deprecated.doc deprecation.doc discouraged.doc dynl.doc dynwind.doc eq.doc error.doc eval.doc evalext.doc expand.doc extensions.doc feature.doc fluids.doc foreign.doc fports.doc gc-malloc.doc gc.doc gettext.doc generalized-arrays.doc generalized-vectors.doc goops.doc gsubr.doc guardians.doc hash.doc hashtab.doc hooks.doc i18n.doc init.doc ioext.doc keywords.doc list.doc load.doc macros.doc mallocs.doc memoize.doc modules.doc numbers.doc objprop.doc options.doc pairs.doc ports.doc print.doc procprop.doc procs.doc promises.doc properties.doc r6rs-ports.doc random.doc rdelim.doc read.doc root.doc rw.doc scmsigs.doc script.doc simpos.doc smob.doc sort.doc srcprop.doc srfi-13.doc srfi-14.doc srfi-4.doc stackchk.doc stacks.doc stime.d