Skip to content

Instantly share code, notes, and snippets.

@t0d0r
t0d0r / gist:4117441
Created November 20, 2012 11:40
sample ruby class using Stuct
# TODO: finish this
class Colors
attr_accessor :color
ColorAttr = Struct.new(:name, :hex)
{
:silver => ColorAttr.new("silver", "ff0000"),
:blue => ColorAttr.new("blue", "ff0000"),
:black => ColorAttr.new("black", "ff0000"),
:white => ColorAttr.new("white", "ff0000"),
:red => ColorAttr.new("red", "ff0000"),
@t0d0r
t0d0r / gist:3415094
Created August 21, 2012 12:47
bash script from mail.interbild.net
#!/bin/sh
# script name: mkmailuser
# part of freebsd helpers
# author todor dragnev aka t0d0r
## get command line
user1=$1
password=$2
ip=$3
email=$4
@t0d0r
t0d0r / groovy-daemon
Created February 9, 2012 08:12 — forked from thekindofme/groovy-daemon
bash script to run java app as a daemon
#!/bin/bash
#
# Derived from -
# Joshua Davis
# http://shrubbery.mynetgear.net/c/display/W/Java+Daemon+Startup+Script
#
# This is a modification of the original script (which lets you run a java program as a deamon.
# look bellow for more information) that lets you run a groovy script as a deamon.
#
# ============== OLD SCRIPT TEXT ==============
// ==UserScript==
// @name remote.bank.allianz.bg
// @author Todor Dragnev aka t0d0r http://twitter.com/t0d0r
// @namespace allianz.usersript.org.bstconsult.com
// @description fix forms in web interface, just click on left or right side on the page to increase/decrease input widht
// @include https://remote.bank.allianz.bg/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// ==/UserScript==
at = s.attributes
at["approxtime"] = Time.now # must have value
["id", "created_at", "updated_at"].each { |e| at.delete(e) }
fm = ForthManeuver.create( at )
@t0d0r
t0d0r / .hgignore
Created December 23, 2011 16:44
.hgignore
# rails hgignore
syntax: glob
*~
.bundle
.*swp
db/*.sqlite3
doc/app/*
log/*.log
tmp/**/*
.git
# custom generators in rails
# for example using haml instead of pure html in r g scaffold
git clone git://github.com/pjb3/rails3-generators.git lib/generators
# config/application.rb
config.generators do |g|
g.template_engine :haml
g.test_framework :rspec, :fixture => true, :views => false
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
# using VestalVersions
# gem 'vestal_versions', :git => 'git://github.com/adamcooper/vestal_versions' # don't work with rails 3.1
gem 'vestal_versions', :git => 'git://github.com/jodosha/vestal_versions' # this work with 3.1
VestalVersions::Version.where(:versioned_type => "Place")
snippet rip
.rest-in-place{'data-attribute' => '${1}'}
require 'open-uri'
require 'nokogiri'
require 'erb'
include ERB::Util
q=url_encode("site:shipspotting.com 7811032 IMO")
doc = Nokogiri::HTML(open("http://www.google.com/search?q=#{q}"))
link = doc.css("h3.r > a").first