Skip to content

Instantly share code, notes, and snippets.

View scvalex's full-sized avatar

Alexandru Scvorțov scvalex

View GitHub Profile
@scvalex
scvalex / otter.el
Created November 2, 2012 20:16
Emacs major mode for the Otter Automated Deduction System
;; See Section 4 (Syntax):
;;
;; http://www.mcs.anl.gov/research/projects/AR/otter/otter33.pdf
(require 'generic-x)
(define-generic-mode
'otter-mode
;; comments start with '%'
'("%")
@scvalex
scvalex / make.conf
Created September 3, 2012 00:30
The make.conf on my laptop
# Base options
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j4"
# Live on the cutting (but not bleeding) edge
ACCEPT_KEYWORDS="~amd64"
@scvalex
scvalex / README.md
Created August 3, 2012 01:35
Loop unrolling in sh

Loop Unrolling in sh

Works in:

  • bash
  • dash
  • zsh
  • BusyBox's sh
@scvalex
scvalex / MrBlotto.hs
Created July 5, 2012 03:56
Find a winning Blotto strategy with genetic algorithms!
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Monad ( forM_ )
import Data.Array.IO ( IOArray, newListArray, readArray, writeArray, getElems )
import Data.List ( sort )
import System.Random ( randomRIO )
import Text.Interpol ( (^-^) )
@scvalex
scvalex / gist:1603678
Created January 12, 2012 22:58
Chipmunk Hello World output
Time is 0.00. ballBody is at ( 0.00, 15.00). It's velocity is ( 0.00, 0.00)
Time is 0.02. ballBody is at ( 0.00, 15.00). It's velocity is ( 0.00, -1.67)
Time is 0.03. ballBody is at ( 0.00, 14.97). It's velocity is ( 0.00, -3.33)
Time is 0.05. ballBody is at ( 0.00, 14.92). It's velocity is ( 0.00, -5.00)
Time is 0.07. ballBody is at ( 0.00, 14.83). It's velocity is ( 0.00, -6.67)
Time is 0.08. ballBody is at ( 0.00, 14.72). It's velocity is ( 0.00, -8.33)
Time is 0.10. ballBody is at ( 0.00, 14.58). It's velocity is ( 0.00, -10.00)
Time is 0.12. ballBody is at ( 0.00, 14.42). It's velocity is ( 0.00, -11.67)
Time is 0.13. ballBody is at ( 0.00, 14.22). It's velocity is ( 0.00, -13.33)
Time is 0.15. ballBody is at ( 0.00, 14.00). It's velocity is ( 0.00, -15.00)
@scvalex
scvalex / LargePrime.hs
Created December 12, 2011 01:42
Generate large primes
module LargePrime where
import Control.Parallel ( par, pseq )
import GHC.Conc ( numCapabilities )
import System.Environment ( getArgs )
import System.Random ( newStdGen, randomRs )
primes :: [Integer]
primes = 2 : filter (go primes) [3, 5..]
where
@scvalex
scvalex / ql.erl
Created October 16, 2011 22:55
Test whether it's faster to merge a list into a queue, or covert it to a list, concat and sort the results.
-module(ql).
-compile(export_all).
run() ->
[begin
io:format("~p\t\t", [N]),
T = run(N),
io:format("~p~n", [T])
end || N <- [10, 100, 1000, 10000, 50000, 100000]],
ok.
@scvalex
scvalex / tc.erl
Created July 20, 2011 20:53
Monitor a consumer and close its channel cleanly
-module(tc).
-compile([export_all]).
-include("include/amqp_client.hrl").
run2() ->
%% Setup a connection with two channels and declare a queue
{ok, Connection} = amqp_connection:start(#'amqp_params_network'{}),
{ok, OtherChannel} = amqp_connection:open_channel(Connection),
%% Start a consumer in a separate thread that will exit(kaput)
@scvalex
scvalex / cat.sh
Created July 5, 2011 10:36
A cat that ls's directories
#!/bin/sh
if [ "$#" -eq "1" -a -d "$1" ]; then
ls $1
else
/bin/cat $@
fi
@scvalex
scvalex / BreakyMCM.java
Created June 6, 2011 19:28
A version of MulticastMain whose producers and consumers die erratically
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License
// at http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
// the License for the specific language governing rights and
// limitations under the License.
//