Skip to content

Instantly share code, notes, and snippets.

@lazyval
lazyval / output.md
Created January 23, 2012 03:24
Can't find out how to dealt with native-packager

> debian:package-bin
[error] Not a valid key: debian (similar: clean)
[error] debian:package-bin
[error]

@lazyval
lazyval / fizzbuzz.js
Created February 2, 2012 19:29
FizzBuzz in JS
for(var i=1; i < 21; i++) {
var message = "";
if(i % 3 === 0) {
message += "Fizz";
}
if( i % 5 === 0) {
message += "Buzz";
}
if(!message) {
message = i;
@lazyval
lazyval / lab.cpp
Created February 21, 2012 21:20
unholy c++
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
while(true) {
float x = 0.01, z, p = 1;
int c, n = 10, i = 1;
package com.github.omnomnom
import java.util.concurrent.Semaphore
import concurrent.Lock
object SleepingBarber extends App {
val NCustomers = 12
val NChairs = 5
val CutTime = 10
val VisitInterval = 5
@lazyval
lazyval / PictureLoader.scala
Created May 11, 2012 20:07
Casbah's GridFS upsert operation
private def upsert(filename: String, extension: String, is: InputStream) {
gridfs.findOne(filename) match {
case Some(_) => println(filename + " is already in database")
case None =>
gridfs(is) {
file =>
file.filename = filename
file.contentType = "image/" + extension
}
}
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void readFromFile() {
string line;
ifstream myfile ("tolstoy.txt");
CREATE OR REPLACE TRIGGER UPD_INF AFTER
UPDATE OF SALARY ON hr.employees FOR EACH ROW
DECLARE
dif NUMBER;
str VARCHAR2(3000);
e hr.employees%ROWTYPE;
BEGIN
dif := TRUNC((TRUNC(sysdate) - TRUNC(e.hire_date))/365,0);
e := :old;
str := 'Номер сотрудника:' || e.employee_id ||
@lazyval
lazyval / Build.scala
Created August 1, 2012 23:20
sbt config
// project/Build.scala
import sbt._
import Keys._
import AndroidKeys._
object General {
val settings = Defaults.defaultSettings ++ Seq(
scalaVersion := "2.9.2"
)
@lazyval
lazyval / dirwatcher.scala
Created August 15, 2012 16:16 — forked from eberle1080/dirwatcher.scala
Recursive directory watcher in Scala
/**
* dirwatcher.scala
*
* Uses the Java 7 WatchEvent filesystem API from within Scala.
* Adapted from:
* http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
*
* @author Chris Eberle <[email protected]>
* @version 0.1
*/
implicit val bdStringView = StringView.of[BigDecimal] as { _.toString }
def makeStringValue[T](implicit sv: StringView[T]) = new StringValue {
def getString(value: AnyRef) = sv(value.asInstanceOf[T])
}
bdStringValue = makeStringValue[BigDecimal]
strStringValue = makeStringValue[String]
qtyStringValue = makeStringValue[Long](StringView.of[Long] as { _.toString }