Skip to content

Instantly share code, notes, and snippets.

View chemikadze's full-sized avatar

Nikolay Sokolov chemikadze

  • Google
  • Fremont, CA
View GitHub Profile
@chemikadze
chemikadze / gist:2634455
Created May 8, 2012 11:58
Trying to make OpenCL behave like scala collection library
package openclscala;
import com.chemikadze.scalacl._
import java.lang.Float
object addOne extends JavaCLFunction11Impl[Float, Float](
"addOne",
"""
__kernel void addOne(__global const float* in, __global float* out, int n)
@chemikadze
chemikadze / gist:3709707
Created September 12, 2012 20:35
Как поднять штангу (пособие для хаскелистов)
data LegHealth = Healthy | Broken deriving (Show)
data HumanLegs a = Legs a deriving (Show)
instance Functor HumanLegs where
fmap f (Legs st) = Legs $ f st
barbell :: LegHealth -> LegHealth
barbell _ = Broken -- playing with iron always ends very bad
case class Foo(id: Key = genKey)
case class Bar(x: String, foo: Key = null, id: Key = genKey)
// in tests
Bar(testData, testFoo.id, testBarId)
// somewhere in logic
Bar(sensitiveData, foo.id)
@chemikadze
chemikadze / WithNull.class
Last active December 14, 2015 04:49
What is the difference between `var x = null` and `var x = _`?
public initializing.WithNull();
Code:
0: aload_0
1: invokespecial #19; //Method java/lang/Object."<init>":()V
4: aload_0
5: aconst_null
6: pop
7: aconst_null
8: putfield #11; //Field x:Ljava/lang/Object;
11: return
@chemikadze
chemikadze / C.class
Created February 26, 2013 15:36
Structural type argument
public class structural.C extends java.lang.Object implements scala.ScalaObject{
public static {};
Code:
0: iconst_0
1: anewarray #8; //class java/lang/Class
4: putstatic #14; //Field reflParams$Cache1:[Ljava/lang/Class;
7: new #16; //class java/lang/ref/SoftReference
10: dup
11: new #18; //class scala/runtime/EmptyMethodCache
14: dup
trait Test {
trait A
trait B
implicit def a2b(a: A): B
trait X[T]
trait Y[+T]
implicit def rewrapX[U, T <% U](x: X[T]): X[U]
implicit def rewrapY[U, T <% U](x: Y[T]): Y[U]
@chemikadze
chemikadze / sbtproject.scala
Created June 21, 2013 13:32
SBT snippets
// create new task
lazy val myPlugin = TaskKey[Unit]("my-plugin")
lazy val myPluginTask = Seq(
myPlugin := (),
myPlugin <<= myPlugin.dependsOn(someTask in someProject),
)
// depend one task on another
xxx
.settings(
# Simple hierarchical application
# Here we accept parameter, pass it through genesis component and return back
application:
interfaces:
input:
in: bind(child_app#input.in)
result:
out: bind(child_app#result.out)
# Simple hierarchical application
# Here we accept parameter, pass it through genesis component and return back
application:
interfaces:
child_in:
app_input: bind(child_app#input.in)
child_out:
app_output: bind(child_app#result.out)
child_output: bind(child_app#result.own)
chemikadze ~/programming/java $ javac unicode.java
unicode.java:4: unclosed string literal
private static String s = "\u000d";
^
unicode.java:4: unclosed string literal
private static String s = "\u000d";
^
unicode.java:4: <identifier> expected
private static String s = "\u000d";
^