Skip to content

Instantly share code, notes, and snippets.

@shitsyndrome
shitsyndrome / xmlparse.rb
Created October 3, 2012 08:00
sucksssssssssssssssssssss!!!!!!!!!!!!!!!!!!!!!!!!!!!
require_relative "untangle/version"
require "nokogiri"
require "stringio"
module Untangle
class Element
attr_accessor :is_root
def initialize(name=nil, attributes=nil)
@name = name
@attributes = attributes
# -*- coding: utf-8 -*-
require 'Qt4'
require 'qtwebkit'
class Foo < Qt::Object
signals 'mySignal()'
slots "int compute(int)"
def compute value
value * 2
@shitsyndrome
shitsyndrome / mc-pi.rb
Created July 30, 2012 13:02
compute pi by Monte-Carlo method.
=begin
Find pi by the Monte-Carlo method.
area of a circle = pi r^2
area of a square = (2r)^2 = 4 r^2
Perform random uniform sampling between -1 and 1.
The proportion of points in the unit circle is:
p = (pi r^2) / (4r^2)