Skip to content

Instantly share code, notes, and snippets.

launch_super_query('foo', <<-SQL, <<-TEXT)
drop table user;
SQL
I'm so sorry.
TEXT
p DATA.read # => "wait what?\n"
__END__
wait what?
@tomasv
tomasv / gist:59f914e9c30be0c5b9b2
Last active August 29, 2015 14:05
Find a cross of zeroes in a sea of pluses.
(ns zero-island.core)
(def problem "+++0++\n++000+\n+++0++\n++++++")
(def ^:private value-encoding {\0 :zero \+ :plus})
(defn- split-lines [problem]
(clojure.string/split problem #"\s+"))
(defn- indexed-seq [s]
Company's quest for world domination has prompted us to open a convenience store - we sell only three products:
Product code | Name | Price
GR1 | Green tea | £3.11
SR1 | Strawberries | £5.00
CF1 | Coffee | £11.23
@tomasv
tomasv / profile
Last active August 29, 2015 14:15
function git-mode() {
alias gst='git status'
alias st='git status'
alias gco='git checkout'
alias co='git checkout'
alias gbr='git branch'
alias br='git branch'
alias gcommit='git commit'
alias commit='git commit'
alias gdiff='git diff'
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
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)
require 'rubygems'
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'varneckas.lt',
:user_name => 'tomas@varneckas.lt',
:password => '',
:authentication => 'plain',
require 'rubygems'
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'varneckas.lt',
:user_name => 'tomas@varneckas.lt',
:password => '',
:authentication => 'plain',
module Gauss where
import Datatypes
import Extra
-- 3 point Gauss coeficients and nodes
c1 = 0.5555556
c2 = 0.8888889
c3 = 0.5555556