Skip to content

Instantly share code, notes, and snippets.

View paveltyk's full-sized avatar

Pavel Tsiukhtsiayeu paveltyk

  • BILL
  • North Carolina, US
  • 06:12 (UTC -04:00)
View GitHub Profile
@paveltyk
paveltyk / tabs.js
Created April 20, 2011 13:13
jQuery simple tabs
$('ul.tab-controls li').bind('click', function() {
$(this).addClass('active').siblings().removeClass('active')
.parents('#funbox').find('ul.tab').hide().eq($(this).index()).fadeIn(500);
return false;
});
// HTML:
// <div id="funbox">
// <ul class="tab-controls">
// <li class="active"><a href="#">Featured</a></li>
@paveltyk
paveltyk / jquery.twit_char_counter.js
Created March 10, 2011 11:27
TwitCharCounter jQuery plugin
/*!
* jQuery TwitCharCounter Plugin
* version: 1.0 (10-MAR-2011)
* created by: PavelTyk
*
* This is a simple char counter plugin (like the Twitter one). It has flexible
* settings and allows minimize configuration settings.
*
* Examples and documentation at: https://gist.github.com/863967
letters = 'satire'
dictionary = {}
results = []
File.open("/usr/share/dict/words", "r") do |infile|
while line = infile.gets
word = line.chomp.downcase
next if word.size != 7
key = word.chars.sort.join
output_file = File.open 'activemerchant_gateway_output.rb', 'w'
output_file.puts "PAYMENT_GATEWAYS = {"
File.open 'activemerchant_gateway_input.txt' do |input_file|
input_file.each_line do |line|
match = line.match /^.*?(\w*).rb:.*class (\w*)Gateway.*$/
next unless match
output_file.puts " \"#{match[1]}\" => {"
output_file.puts " :name => \"#{match[2]}\","
output_file.puts " :class => ActiveMerchant::Billing::#{match[2]}Gateway"
output_file.puts " },"
output_file = File.open 'gem_remote_output.txt', 'w'
File.open 'gem_remote_input.txt' do |input_file|
input_file.each_line do |line|
match = line.match /^([^_\-][\-\w\.]*) \(([\d\.]*).*\)$/
output_file.puts "gem install #{match[1]} -v #{match[2]}" if match
end
end
@paveltyk
paveltyk / gist:668919
Created November 9, 2010 09:57
Mail Chimp Test Task
# Mail Chimp Test Task
API_KEY = 'api-key'
LIST_NAME = 'list name'
require 'rubygems'
require 'xmlrpc/client'
require 'active_record'
# === Database Setup