Skip to content

Instantly share code, notes, and snippets.

@lazyval
lazyval / toGraphML.xml
Created May 22, 2011 14:57
XSL template that converts xml formatted tree into GraphML language representation
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/root" >
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
@lazyval
lazyval / PLAB01.cs
Created September 14, 2011 20:31
Parallel programming. First lab.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace PLAB_01
johny@johny-X51RL:~$ mongo
"MongoDB shell version: 1.6.3"
"Thu Sep 22 21:28:06 *** warning: spider monkey build without utf8 support. consider rebuilding with utf8 support"
"connecting to: test"
var student = {name:'Alex',surname:'Astrouski', age:'20', courses:['math','databases','physics']}
var student2 = {name:'Some',surname:'Body', age:'200', courses:['math','databases','physics']}
var student3 = {name:'Hare',surname:'Krishna', age:'600', courses:['math','databases','physics']}
"Создал пару студентов (документов), теперь записываю в коллекцию:"
db.students.save(student)
db.students.save(student2)
@lazyval
lazyval / fizzbuzz.scala
Created November 20, 2011 20:51
Fizzbuzz in scala
object FizzBuzz extends App {
def fizzbuzz(line: String) = {
val Array(a,b,n) = line.split(" ").map(_.toInt)
(1 to n).map(x =>
(x%a,x%b) match {
case (0,0) => "FB"
case (0,_) => "F"
case (_,0) => "B"
case _ => x
}
@lazyval
lazyval / test.h
Created November 27, 2011 13:18
bridj fails at processing this
#include <iostream>
void printSome(int argc, int xs[]);
int intTest(int arg);
@lazyval
lazyval / Huffman.scala
Created November 28, 2011 03:46
Proof-of-concept of Huffman coding algorithm in Scala
package com.github.omnomnom
import scala.collection.mutable._
// 28 nov 2011
// Golikov Konstantine
// johnysilver7@gmail.com
abstract class Node extends Ordered[Node] {
val w: Double
@lazyval
lazyval / a.cpp
Created December 16, 2011 21:13
cycles
#include <stdio.h>
#include <math.h>
// Условия из задания. Не могут изменяться в ходе работы программы
// Значения определенные здесь видны во всей программе
const int N = 12,
a = 10,
xs = 2,
xe = 6;
@lazyval
lazyval / RTS.cpp
Created December 21, 2011 21:11
Processing code file for Arduino (real-time system's lab)
#include <Servo.h> // библиотека по работе с сервоприводом
Servo myservo;
const int ledPin = 13;
const int IRPIN = 0;
int pos = 0;
void setup() {
Serial.begin(9600); // Открываем соединение (в скобках -- скорость в бодах)
@lazyval
lazyval / after.cs
Created January 15, 2012 19:53
rewrite w/ lambdas of 5th lab. Parallel programming
using System;
namespace Lab05
{
class Program
{
static void Main()
{
MultiplyMatrix.InitMatrix();
@lazyval
lazyval / ThreadExtension.cs
Created January 22, 2012 22:30
An example of extension methods in C#
using System;
using System.Collections.Concurrent;
using System.Threading;
namespace ReadWriteBuffer
{
public static class ThreadExtension
{
private const LocalDataStoreSlot PRIORITY_SLOT = Thread.GetNamedDataSlot("prioritySlot");
public static ThreadPriority GetPriority(this Thread t)