Skip to content

Instantly share code, notes, and snippets.

View scvalex's full-sized avatar

Alexandru Scvorțov scvalex

View GitHub Profile
@scvalex
scvalex / stacks.py
Created May 15, 2010 15:47
Solution sketch for an ACM problem
V = [-1]
def pushWhat(S, Op):
"""what should I push on S if I'm at operation Op"""
return S + Op
def push(I):
print(pushWhat(I, len(V)))
V.append(I)
@scvalex
scvalex / .emacs
Created May 21, 2010 09:57
My .emacs
(require 'site-gentoo)
;; usability
;;(cua-mode)
(transient-mark-mode nil) ; disable
(setq backup-directory-alist '(("." . "~/.emacs-backups")))
(setq gdb-many-windows t)
;; iswitchb
@scvalex
scvalex / bleah.pl
Created May 28, 2010 14:28
Lab assignament: generator of good species policy
:- ensure_loaded('iconics.pl').
:- ensure_loaded('utilities.pl').
:- ensure_loaded('simulator2.pl').
gen(_, [], 0) :- !.
gen([P|Ps], [(P, w)|T], N) :- N1 is N-1, gen(Ps, T, N1).
gen([P|Ps], [(P, dr)|T], N) :- N1 is N-1, gen(Ps, T, N1).
gen([P|Ps], [(P, gr)|T], N) :- N1 is N-1, gen(Ps, T, N1).
% Check that for a policy:
@scvalex
scvalex / choices.pl
Created May 28, 2010 14:43
Prolog choices
%
% ----------------------------------------------------------------------------
% Prolog term 3 course: agents exercise
% SKELETON: choices.pl
% ----------------------------------------------------------------------------
%
:- ensure_loaded('iconics.pl').
:- ensure_loaded('utilities.pl').
@scvalex
scvalex / evaluator.pl
Created May 29, 2010 17:37
Policy value calculator for Prolog agents
%
% ----------------------------------------------------------------------------
% Prolog term 3 course: Agents exercise - Part Deux!
% ----------------------------------------------------------------------------
%
% ----------------------------------------------------------------------------
% Imports, etc.
:- ensure_loaded('iterator.pl').
@scvalex
scvalex / pull_contacts.py
Created July 15, 2010 23:25
Pull data from Google Contacts
#!/usr/bin/python
"""Module for pulling contacts out of Google and storing them to disk
(or something).
See the official guide for a more in-depth look at GData Python
http://code.google.com/apis/contacts/docs/1.0/developers_guide_python.html
"""
import atom
@scvalex
scvalex / .zshrc
Created July 30, 2010 11:07
My rather messy .zshrc
# Source Gentoo env variables
source /etc/zsh/zprofile
# next lets set some enviromental/shell pref stuff up
# setopt NOHUP
#setopt NOTIFY
#setopt NO_FLOW_CONTROL
setopt INC_APPEND_HISTORY SHARE_HISTORY
setopt APPEND_HISTORY
# setopt AUTO_LIST # these two should be turned off
@scvalex
scvalex / re.c
Created September 29, 2010 16:35
Simple Capturing Regular Expressions
/* Copyright (C) 2010 Alexandru Scvortov <scvalex@gmail.com>
* http://github.com/scvalex
* http://abstractbinary.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Memory related */
@scvalex
scvalex / collatz.c
Created September 29, 2010 20:58
Collatz Conjecture with Corutines in C (alliterative!)
#include <stdio.h>
#include <setjmp.h>
void even(int);
void odd(int);
int main(int argc, char *argv[]) {
even(7);
return 0;
}
@scvalex
scvalex / TxDontLoseMessages.java
Created October 6, 2010 10:43
Don't lose messages with RabbitMQ Transactions
// 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.
//