Skip to content

Instantly share code, notes, and snippets.

View rssh's full-sized avatar

Ruslan Shevchenko rssh

View GitHub Profile
@rssh
rssh / OSDN2013_9_nemerle
Created October 10, 2013 10:33
Definition of do/while in Nemerle
macro dowhile (cond, body)
syntax ("do", body, "while", "(", cond, ")")
{
def loop = Nemerle.Macros.Symbol (Util.tmpname ("do_while"))
<[
(($("_N_break" : global) : {
def $(loop : name) () : void {
($("_N_continue" : global) : { $body }) : void;
when ($cond)
$(loop : name) ();
@rssh
rssh / gist:a761b926335b98d84987
Last active August 29, 2015 14:04
example of thrift definition
struct ProfileInfo
{
1: required string uid;
2: optional string firstName;
3: optional string middleName;
4: optional string lastName;
5: optional string email;
6: optional string phone;
7: optional string addrPostal;
}
@rssh
rssh / gist:506ae586157b03cbf0ef
Created July 21, 2014 16:23
Unreactive pseudocode 1
def listUsers(r: Request): RequestResult = listForm.bind(request){
success(form) => Ok (ToJson(
users.filter(_.name contains form.q).page(form.offset,form.limit)
) )
failure(f,message, ex) => Error(403, message)
}
package x
import akka.actor._
import scala.concurrent._
import scala.concurrent.duration._
import ExecutionContext.Implicits.global
object X
{
@rssh
rssh / gist:5511ea89caee72a35861
Created September 15, 2014 04:31
jdlv_article_1
case class Person(firstName:String, lastName:String)
@rssh
rssh / gist:82fc8a3f6196b616add3
Created September 15, 2014 04:36
jdv_article_2
public class Person
{
private String firstName;
private String lastName;
String getFirstName() { return firstName; }
void setFirstName(String firstName) { this.firstName = firstName; }
String getLastName() { return lastName; }
void setLastName(String lastName) { this.lastName = lastName; }
@rssh
rssh / gist:7baef0ef33054f0daf1d
Created September 15, 2014 04:38
jdv_article3
public class Person extends DTOBase
{
public String firstName;
public String lastName;
}
@rssh
rssh / gist:f766e6783af08403ae8a
Created September 15, 2014 21:16
jdv_article_4 (simple lambda-expression in java)
list.sort((x,y)-> {
int cmp = x.lastName.compareTo(y.lastName);
return cmp!=0 ? cmp : x.firstName.compareTo(y.firstName)
}
@rssh
rssh / gist:8a4375719ca1622a0580
Created September 15, 2014 21:17
jdv_article5 (simple lambda expression in scala)
list.sort((x,y) => {
val cmp = x.lastName.compareTo(y.lastName)
if (cmp!=0) cmp else x.firstName.compareTo(y.lastName)
}
@rssh
rssh / gist:b7a4c9ec9790295b69f9
Last active August 29, 2015 14:06
jdv_article6 (scala lambda expression with modification of context)
var (maxFirstLen, maxSecondLen) = (0,0)
list.foreach{
x => maxFirstLen = max(maxFirstLen, x.firstName.length)
maxSecondLen = max(maxSecondLen, x.secondName.lenght)
}