Skip to content

Instantly share code, notes, and snippets.

module NotMonkeyPatchable
def method_added(name)
@methods ||= {}
if @methods[name] and not @unpatching
@unpatching = true
method = @methods[name]
define_method(name) { |*args, &block|
method.bind(self).call(*args, &block)
}
module Gauss where
import Datatypes
import Extra
-- 3 point Gauss coeficients and nodes
c1 = 0.5555556
c2 = 0.8888889
c3 = 0.5555556
require 'rubygems'
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'varneckas.lt',
:user_name => '[email protected]',
:password => '',
:authentication => 'plain',
require 'rubygems'
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'varneckas.lt',
:user_name => '[email protected]',
:password => '',
:authentication => 'plain',
module Main where
import Control.Monad.Writer
import Control.Monad.Reader
rwt :: A Int
rwt = ask >>= \x -> tell ("Got " ++ show x) >> return (x * 2)
type A = ReaderT Int (WriterT String Maybe)
module Main where
omitElementAt :: Int -> [a] -> [a]
omitElementAt i list = let (left, right) = splitAt i list in left ++ (tail right)
jacobiProductSum :: Int -> [Double] -> [Double] -> Double
jacobiProductSum i a x = sum [ aj * xj | (aj, xj) <- aFiltered `zip` xFiltered ]
where
aFiltered = omitElementAt i a
xFiltered = omitElementAt i x
@tomasv
tomasv / gist:912242
Created April 10, 2011 10:50
xmonad config with a hack for floating windows
import XMonad
import Data.Monoid
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops