Skip to content

Instantly share code, notes, and snippets.

View krukid's full-sized avatar

Viktors Buls krukid

  • Juro
  • Riga, Latvia
View GitHub Profile
@krukid
krukid / ROR for virtualized ubuntu
Created February 24, 2010 02:12
Ruby on Rails for virtualized Ubuntu
PURPOSE
-------
The following is a walkthrough of Ruby on Rails installation on a VirtualBox'ed Ubuntu and some related tricks.
NOTES
-----
* Most of the commands below require superuser privileges, so with that in mind we proceed.
@krukid
krukid / gist:756726
Created December 28, 2010 00:18
Anchor: selective underline CSS
<!DOCTYPE html>
<html>
<head>
<title>Anchor: selective underline CSS</title>
<style type="text/css">
.a {
text-decoration:none;
font-size: 40px;
}
.w {
@krukid
krukid / css3 cycled table row highlighting.html
Created March 29, 2011 21:11
how to preserve correct row highlighting when dynamically manipulating table structure (with css3); useful for ajaxed tables
<!-- CSS3 ROW STYLE CYCLING
* alternative pseudo-class notation:
:nth-child(2n) == :nth_child(even)
:nth-child(2n+1) == :nth_child(odd)
-->
<style type="text/css">
table.css-cycle tr:nth-child(2n) {
background: silver;
}
@krukid
krukid / gist:927150
Created April 19, 2011 11:16
safari5 dialog z-index bug minimal test case
<!DOCTYPE html>
<html>
<head>
<title>Safari5 Dialog Z-Index Bug</title>
<style type="text/css">
#overlay {
position: absolute;
left: 0;
top: 0;
width: 100%;
@krukid
krukid / timer.rb
Created August 17, 2011 01:20
simple timer with dynamic average
class Timer
attr_reader :diff, :sum, :step
def initialize
reset!
end
def mark!
new_mark = now
@krukid
krukid / streaming_echoed_image_service.rb
Created March 12, 2012 14:22
goliath server that echoes embedded html image (jpeg)
require 'goliath'
require 'base64'
class StreamingEchoedImageService < Goliath::API
def on_headers(env, headers)
env.logger.info "#{env['REQUEST_METHOD']} #{env['REQUEST_URI']}"
env.logger.info 'received headers: ' + headers.inspect
env['async-headers'] = headers
end
@krukid
krukid / em_http.rb
Created March 12, 2012 14:25
em-http-request streaming upload
#
# requires:
# a) run https://gist.github.com/2022231 on localhost:3001
# b) provide a streamed.jpg at script location
#
# result:
# this fails for em-http-request v1.0.1
#
require "rubygems"
@krukid
krukid / dom_mutation_observer.js
Created September 9, 2012 15:19
Chrome mutation observer for dynamic element handling (removing popups by id and such)
(function (window, checkNode){
var p = {};
var m = {
registerObserver: function() {
if (typeof(window.WebKitMutationObserver) == "undefined") return;
p.observer = new window.WebKitMutationObserver(function(mutationRecords) {
mutationRecords.forEach(function(mutationRecord) {
for (var i = 0; i < mutationRecord.addedNodes.length; ++i)
@krukid
krukid / server.rb
Created October 11, 2012 15:15
GoViral "Syndicated Player" Sinatra test server
require 'sinatra'
get '/' do
erb :index
end
get '/iframe' do
erb :iframe
end
@krukid
krukid / gfx.js
Created September 3, 2013 01:26
js fiddling - canvas, trigonometry, chaining
Gfx = (function(window) {
var document = window.document;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var helpers = {
hyp: function(x0, y0, x1, y1) {
return Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2));
},
sign: function(value) {