Skip to content

Instantly share code, notes, and snippets.

View YoniTsafir's full-sized avatar

Yoni Tsafir YoniTsafir

View GitHub Profile
@YoniTsafir
YoniTsafir / TensorflowAndroidSample.java
Created March 29, 2017 11:35
TensorFlow Android Sample Code
import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
/** One time initialization: */
TensorFlowInferenceInterface tensorflow = new TensorFlowInferenceInterface();
tensorflow.initializeTensorFlow(getAssets(), "file:///android_asset/model.pb");
/** Continuous inference (floats used in example, can be any primitive): */
// loading new input
tensorflow.fillNodeFloat("input:0", INPUT_SHAPE, input); // INPUT_SHAPE is an int[] of expected shape, input is a float[] with the input data
@YoniTsafir
YoniTsafir / A.h
Created May 29, 2015 09:59
Importing Swift code from Objective-C in a Test Target - It's Possible!
@interface A : NSObject
- (int)foo;
@end
@YoniTsafir
YoniTsafir / appdir_alias.sh
Last active December 28, 2015 03:09
A bash function that takes you to the directory of an app running in iOS SImulator. Add to your bash aliases file. Usage: appdir <AppName>
appdir() {
dir=$(ps ax | grep $1.app | grep -v grep | grep -v AppCode | awk '{print "\""$5" "$6" "$7"\""} ' | sed "s/$1\.app\/$1//g")
eval cd "$dir"
}
@YoniTsafir
YoniTsafir / gist:4770019
Created February 12, 2013 13:52
A useful method to mask a view according to an alpha channel to an image. Example usage: place the masking image using IB (make it hidden), and dynamically create a view around it, that you mask using this method.
+ (void)maskView:(UIView *)targetView withImageView:(UIImageView *)maskingImageView {
CALayer *maskingLayer = [CALayer layer];
maskingLayer.frame = CGRectMake(maskingImageView.frame.origin.x - targetView.frame.origin.x,
maskingImageView.frame.origin.y - targetView.frame.origin.y,
maskingImageView.frame.size.width,
maskingImageView.frame.size.height);
maskingLayer.contents = (id)maskingImageView.image.CGImage;
targetView.layer.mask = maskingLayer;
}
@YoniTsafir
YoniTsafir / open_leaan.sh
Created November 6, 2012 17:55
A way to obtain a session to leaan.co.il when there's a derby sale :)
#!/bin/bash
while [ 1 == 1 ]; do
curl http://www.leaan.co.il | grep Lean-Logo.png 2>&1 > /dev/null
if [ $? == 0 ]; then
open http://www.leaan.co.il;
fi
sleep 1
done
@YoniTsafir
YoniTsafir / Q19.java
Created June 23, 2012 08:08
Does it compile? questions in Java III
public class Main {
public static void main(String[] args) {
doSomething(7);
}
private static void doSomething(int num) throws Exception {
if (num > 10) {
throw new Exception("abcd");
} else {
System.out.println(num);
@YoniTsafir
YoniTsafir / Q11.java
Created June 18, 2012 20:57
Does it compile? questions in java II
class A {
private int x;
public A() {
this(7);
}
public A(int x) {
setX(x);
}
@YoniTsafir
YoniTsafir / Q1.java
Created June 16, 2012 10:18
Does it compile? questions in java
public abstract class A {
private int x = 7;
public A(int x) {
this.x = x;
System.out.println("A::A, x=" + x);
}
public int getX() {
@YoniTsafir
YoniTsafir / sort.py
Created January 30, 2012 17:10
Code from TDD Workshop with Corey Haines
'''
Created on Jan 30, 2012
@author: yonits
'''
import unittest
def flip_indices(new_list, first_idx, second_idx):
@YoniTsafir
YoniTsafir / MyTest.h
Created December 11, 2011 14:59
Negative value SPTween bug
#import <SenTestingKit/SenTestingKit.h>
@interface MyTest : SenTestCase
@end