Skip to content

Instantly share code, notes, and snippets.

View scepion1d's full-sized avatar

Prokhor Mikhailov scepion1d

View GitHub Profile
@scepion1d
scepion1d / cross_resize.js
Last active January 14, 2016 12:20
Cross Browser JS Window Resizing
function doSomething() {
alert("I'm done resizing for the moment");
};
var resizeTimer;
$(window).resize(function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
@scepion1d
scepion1d / chauvinism.rb
Created March 19, 2012 15:17
Some Chauvinist Code
def generate_gender
return :M if rand(0..1) > 0
return :F
end
@scepion1d
scepion1d / Downloader.rb
Created January 20, 2012 09:15
Ruby class for download web page and translate it to UTF-8 encoding
require "net/http"
require "ensure"
class Downloader
# Expected encodings
ENCODINGS = Array['UTF-8', 'WINDOWS-1251', 'KOI-8']
def get_page(url)
response = Net::HTTP.get_response(URI.parse(url))
while response.kind_of?(Net::HTTPRedirection)
@scepion1d
scepion1d / Clusterizer.java
Created January 1, 2012 10:03
Realization of two clusterization algorithms
package clusterizer;
import java.util.ArrayList;
public abstract class Clusterizer {
protected class Pair {
public int x, y; // ID's of clusters
public Pair(int x, int y) {
this.x = x;