Skip to content

Instantly share code, notes, and snippets.

View DemitryT's full-sized avatar

Demitry Toumilovich DemitryT

View GitHub Profile
@DemitryT
DemitryT / walkscore.rb
Created January 4, 2012 22:10
walkscore.rb
require 'httparty'
class Walkscore
include HTTParty
attr_accessor :api_key, :property
def initialize(api_key, property)
self.api_key = api_key
self.property = property
@DemitryT
DemitryT / _coupon_block.html.haml
Created August 18, 2011 22:01
"Re-send a gift coupon" feature I implemented on a Ruby on Rails application at my last job
# only including what I helped write below
.coupon_list
- array_of_coupons.each do |coupon|
%div
- if redeemed
%span.cross_out
= "#" + coupon.uid
%span.green
= link_to (coupon.user_redeemed ? "Mark as New" : "Mark as Used"), '#', :class => 'user_redeemed', :rel => toggle_user_redeemed_coupon_path(coupon)
@DemitryT
DemitryT / application.js
Created August 18, 2011 21:52
AJAX feature to retrieve user information (from my personal website, which I'm writing in PHP)
jQuery(document).ready(function()
{
var hideDelay = 500;
var userID;
var hideTimer = null;
// One instance that's reused to show info for the current person
var container = jQuery('<div id="personPopupContainer">'
+ '<table width="" border="0" cellspacing="0" cellpadding="0" align="center" class="personPopupPopup">'
+ '<tr>'
@DemitryT
DemitryT / HowEasy.java
Created August 18, 2011 21:42
Simple problem I solved using Java, on www.topcoder.com, which was to evaluate the difficulty of a problem based on its word length.
import java.util.*;
import java.util.Arrays;
public class HowEasy{
public int pointVal(String problemstatement){
//problemstatement is a string containing between 1 - 50 letters, numbers, spaces or periods
String[] words = problemstatement.split(" "); //seperates all words from problem statement with space as seperator
int totalWords = words.length;
@DemitryT
DemitryT / mechanize.rb
Created August 16, 2011 19:20
Ruby program to scrape specific information of a web page
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we’re interested in...
url = 'http://www.groupon.com/denver/deals/next-door-lounge'
doc = Nokogiri::HTML(open(url)) #do |config|
doc.at_css("ul#counter li.ended").text
# config.noerror
@DemitryT
DemitryT / crawler.rb
Created August 16, 2011 19:19
Simple ruby program to crawl a specific page for links
require 'rubygems'
require 'anemone'
#!/usr/bin/env ruby
# To use the anemone gem to crawl website make sure these are installed:
# 1) Redis (>= 2.0.0)
# 2) MongoDB
# 3) TokyoCabinet
# 4) PStore
# crawl website for specific info for Hazzo marketing purposes