Skip to content

Instantly share code, notes, and snippets.

Yuval Itzchakov YuvalItzchakov

Block or report user

Report or block YuvalItzchakov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am yuvalitzchakov on github.
  • I am yuvalitzchakov (https://keybase.io/yuvalitzchakov) on keybase.
  • I have a public key ASCNpDl4BcEt30uHFcNQkS_p_aZKQ7q_1blOJq34f0XoSgo

To claim this, I am signing this object:

View HolyShitThisWorks.scala
package tests
import cats._
import cats.implicits._
import scala.collection.immutable.Stream
/**
* Created by Yuval.Itzchakov on 3/8/2017.
*/
object Test {
View gist:8922636e2fa8b5b0e060fb6f69adbd0e
scala> Array(1,2,3,4).sliding(2).forall {
| case Array(x, y) => x < y
| case _ => true
| }
res4: Boolean = true
View Animal.scala
object Yuval extends App {
class Animal {
this: Reflect =>
}
implicit def reflectOrdering: Ordering[Animal with Reflect] = Ordering.by(e => e.canReflect)
object Animal {
def isGreaterAnimal(first: Animal with Reflect, second: Animal with Reflect)(implicit ev: Ordering[Animal with Reflect]) = ev.gt(first, second)
}
View gist:ea489ab7a21f90865f60
[info] +-io.argonaut:argonaut_2.10:6.1
[info] | +-com.github.julien-truffaut:monocle-core_2.10:1.1.0 [S]
[info] | | +-org.scalaz:scalaz-core_2.10:7.1.1 [S] (evicted by: 7.2.0)
[info] | | +-org.scalaz:scalaz-core_2.10:7.2.0 [S]
[info] | |
[info] | +-com.github.julien-truffaut:monocle-macro_2.10:1.1.0 [S]
[info] | | +-com.github.julien-truffaut:monocle-core_2.10:1.1.0 [S]
[info] | | | +-org.scalaz:scalaz-core_2.10:7.1.1 [S] (evicted by: 7.2.0)
[info] | | | +-org.scalaz:scalaz-core_2.10:7.2.0 [S]
[info] | | |
View gist:9b404a63337f35b5dc7e
static void GetSize(string msg)
{
byte[] data = Encoding.ASCII.GetBytes(msg);
byte[] sizeinfo = new byte[4];
sizeinfo[0] = (byte)data.Length;
sizeinfo[1] = (byte)(data.Length >> 8);
sizeinfo[2] = (byte)(data.Length >> 16);
sizeinfo[3] = (byte)(data.Length >> 24);
}
View gist:5b728c1849dfa871ceb6
List<int> collection = GetCollection();
if ((collection?.Any(x => x > 5))
{
// Is the collection null, or isn't there any element?
}
else
{
// I want to access the list here, need to add a null check:
if (collection != null)
...
View gist:707275b73a54cb476609
public class Program
{
public static void Main(string[] args)
{
new BenchmarkRunner().RunCompetition(new IL_Loops());
}
}
public class IL_Loops
{
View mutable-structs-async-await.cs
public static void Main(string[] args)
{
var sInstance = new Structure(25);
sInstance.Change(35);
await sInstance.ChangeAsync(45);
}
public struct Structure
{
private int value;
@YuvalItzchakov
YuvalItzchakov / gist:c24c51747226e9a64f6a
Created Nov 12, 2014
generic vs non-generic state machine
View gist:c24c51747226e9a64f6a
C# code:
IEnumerable NonGenericEmptyEnumerable()
{
yield break;
}
IEnumerable<T> GenericEmptyEnumerable<T>()
{
yield break;
You can’t perform that action at this time.