Skip to content

Instantly share code, notes, and snippets.

Avatar

Dmitry Mozzherin dimus

  • University of Illinois
  • Champaign, IL, US
View GitHub Profile
View test_neti_neti_server.rb
#!/usr/bin/env ruby
# encoding: utf-8
require 'rest_client'
HOST = "localhost"
res = RestClient.get("http://#{HOST}:6384")
puts "GET request"
puts res
@dimus
dimus / .bashrc
Created Sep 25, 2011
Example of .bashrc
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
@dimus
dimus / .gemrc
Created Sep 24, 2011
Gemrc file
View .gemrc
---
gem: --no-ri --no-rdoc
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com
:update_sources: true
:verbose: true
@dimus
dimus / .git_colors
Created Sep 24, 2011
command line promt for git
View .git_colors
#!/bin/bash
#
# Set our bash prompt according to the branch/status of the current git
# repository.
#
# Forked from http://gist.github.com/31934
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
View gist:1239278
[user]
name=Your Name
email=your_email@example.org
[github]
user = your_github
[color]
branch=auto
diff=auto
status=auto
[color "branch"]
@dimus
dimus / Hash.from_xml using Nokogiri
Created Mar 17, 2010
Adding Hash.from_xml method using Nokogiri
View Hash.from_xml using Nokogiri
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
@dimus
dimus / damerau_levenshtein distance for ruby
Created Jul 14, 2009
Damerau-Levenshtein distance for ruby in C
View damerau_levenshtein distance for ruby
#!/usr/bin/env ruby1.9
# encoding: UTF-8
require 'rubygems'
require 'inline'
require 'time'
class DamerauLevenshtein
def distance(str1, str2, block_size=2, max_distance=10)
res = distance_utf(str1.unpack("U*"), str2.unpack("U*"), block_size, max_distance)
(res > max_distance) ? nil : res
You can’t perform that action at this time.