Skip to content

Instantly share code, notes, and snippets.

View utgarda's full-sized avatar

Evgenii Tsvigun utgarda

View GitHub Profile
# Shouldn't they be colored somehow fancy?
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
#jQuery comes to the resque
containerWidth = $('#container2').width()
containsrHeight = $('#container2').height()
# Add polygons to a layer
addPolygon = (layer) ->
n = layer.getChildren().length + 1
@utgarda
utgarda / fb-publish-post.coffee
Created April 3, 2012 12:44
CoffeeScript + jQuery tutorials: Evil Twins hunt
window.publishPost = ->
userId = window.fbUserId
post =
caption: "Evil Twins Hunt"
message: "Found an app to check FB for presence of Evil
Twins from the Evil Parallel Universe. Be watchful, tovarisch!
( And yeah, I also learned how to access FB info and publish
feed items from code, which is cool. )"
link: "http://coffeequery.blogspot.com/2012/04/hunting-evil-twins.html"
FB.api "/me/feed", 'post', post
@utgarda
utgarda / LinkedInClient.coffee
Created March 3, 2012 16:42 — forked from brikis98/LinkedInClient.coffee
LinkedIn API Client in CoffeeScript
OAuth = require('oauth').OAuth
_ = require 'underscore'
class LinkedInClient
@baseUrl: 'https://api.linkedin.com'
@requestTokenUrl: "#{@baseUrl}/uas/oauth/requestToken"
@accessTokenUrl: "#{@baseUrl}/uas/oauth/accessToken"
@authorizeUrl: "#{@baseUrl}/uas/oauth/authorize"
@profileFields: ['id', 'headline', 'first-name', 'last-name', 'public-profile-url', 'picture-url', 'educations', 'positions', 'email-address']
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
<div id="palette" style="width: 510px; height: 80px;">
</div>
<script type="text/coffeescript">
colors = ['#CCDDBB', '#99CC66', '#88AA66', '#AADDCC', '#66AAAA', '#559999', '#FFFFDD', '#FF9922', '#DD8822', '#AACCDD', '#5599CC', '#4477AA']
next_square_html = (color) ->
"""
<div style="background: #{color};
border: 1px solid grey;
height: 30px;
@utgarda
utgarda / jquery_animation_1.coffee
Created January 2, 2012 20:55
CoffeeScript + jQuery animation example http://coffeequery.blogspot.com
#Using $j instead of just $ to be more specific
$j = jQuery
#Storing page elements to local variables
clickme = $j '#ani1_clickme'
restore = $j '#ani1_restore'
bar1 = $j '#ani1_bar1'
bar2 = $j '#ani1_bar2'
#Cool shortcut, instead of $j(document).ready(function(){
major, minor = `bison --version`.scan(/bison \(GNU Bison\) (\d+)\.(\d+)/)[0].map(&:to_i)
$?.exitstatus == 0 && ([major, minor] <=> [2,4]) >=0
@utgarda
utgarda / ring_benchmark.erl
Created December 8, 2010 16:51
Tutorial problem from "Programming Erlang" by Joe Armstrong , 8.11 Write a ring benchmark. Create N processes in a ring. Send a msage round the ring M times so that a total of N * M messages sent. Time how long this takes for different values of N and M.
-module(ring_benchmark).
-export([new/2]).
new(N, M) ->
spawn(fun() -> spawn_ring(N, M) end).
spawn_ring(N, M) ->
io:format("First process: ~p~n", [self()]),
NextPid = spawn_rest(self(), N),
%%% File : ahocorasik.erl
%%% Author : Fyodor Ustinov <ufm@ufm.su>
%%% Descrip.: Multiple search based on Aho-Corasick string matching algorithm
%%%
%%% License : GPL
%%%
%%% Usage:
%%% ahocorasik:match(["pat1", "pat2"], "pat1 pat2 pat1")
%%% or
%%% Tree = ahocorasick:tree(["pat1", "pat2"])
require 'bio'
reg= Bio::Registry.new
genbank = reg.get_database('genbank')
entry = genbank.get_by_id('AA2CG')
print entry
ff = Bio::FlatFile.new(Bio::GenBank, File.open("/home/etsvigun/devenv/biotech/seq/gbhtg86.seq", 'r'))