יום ראשון, 7 בפברואר 2016

PHP: Converting __toString when calling json_encode using JsonSerializable interface

JsonSerializable {
/* Methods */
abstract public mixed jsonSerialize ( void )
}

When calling a json_encode on an object:

See:

And:

יום חמישי, 24 בספטמבר 2015

תצוגה ייחודית לסטטיסטיקות ישראליות

אני ואחי יצרנו תצוגה מעניינת לראות אירועים יום יומיים ישראלים. כמה כסף עיריית תל-אביב עושה מדוחות על חניות ? - כמה כסף מרוויח בנק הפועלים בשניה ? - כל כמה זמן נולד ילד במדינה ? / מישהו מתגייס ? / כמה שקיות במבה מיוצרות בשנייה ? ... ועוד ועוד.

צריך לראות כדי להבין:


http://www.c2kb.com/israel-frequency/

תדירות ישראלית

יום שלישי, 15 בספטמבר 2015

Building a drawing robot in Geekcon 2015

On the last GeekCon 2015, me and my brother built a drawing robot.
Can draw on a large scale pages, basically working the same way Logo (Computer Language) Turtle is working. Can go forward, backward and turn around. Can raise the pen or lower it in order to start drawing.

Here are some pictures, explanations and code.

We used the Arduino Uno (actually Funduino Uno compatible) over a Maze car  rack bought in Deal Extreme. Using the Keyes L298 driver for the DC motors and a Servo motor using the original Servo.h library kit from Arduino.









Some external references helping us to go on:


Here is the code:
Also can be seen in Github:

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 11;
int in1 = 2;
int in2 = 3;
// motor two
int enB = 6;
int in3 = 4;
int in4 = 5;
// servo pen
int servoPin = 13;
int speed = 255;


//Include for servo
#include   // servo library
//Define Servo
Servo servo;  // servo control object

void set_speed(int pin, int speed)
{
  //if(pin == enA)
  //  analogWrite(pin, 200);
  //else
    digitalWrite(pin, HIGH);
}


void setup()
{
  Serial.begin (9600);

  servo.attach(servoPin);
 
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void forward(int duration)
{
  Serial.println("Forward");
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  set_speed(enA, speed);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  set_speed(enB, speed);
  delay(duration);
}
void right(int duration)
{
  Serial.println("Right");
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH); 
  set_speed(enA, speed);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  set_speed(enB, speed);
  delay(duration);
}
void left(int duration)
{
  Serial.println("Right");
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW); 
  set_speed(enA, speed);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  set_speed(enB, speed);
  delay(duration);
}
void sstop(int duration)
{
  // now turn off motors
  Serial.println("Off");
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
 
  delay(duration);
}
void drawSquare()
{
  Serial.println("drawSquare start");

  // malben - starts from the lower left corner
  forward(1100);
  right(270); 
  forward(800);
  right(270);
  forward(1100);
  right(270);
  forward(800);
  right(270); 
}
void drawZigzag()
{
  Serial.println("drawZigzag start");

  // forward zigzag
  right(100);
  forward(300);
  left(200);
  forward(300);
  right(200);
  forward(300);
  left(200);
  forward(300);
  right(100);
}

void penDown()
{
  servo.write(90);
  Serial.println("Pen Down");
}

void penUp()
{
  servo.write(180);
  Serial.println("Pen Up");
}

void loop()
{
  penUp();
  delay(7000);
 
  penDown();
  drawSquare();

  penUp();
  sstop(1000);
  right(200);
  forward(300);
  left(200);

  //sstop(1000);

  penDown();
  drawZigzag();

  sstop(1000);
}



יום שלישי, 8 בספטמבר 2015

Google Updated Their Logo but Ruined the Google Calendar Updating Favicon

On first of September (2015) a week ago, Google updated their logo, to a new one. They also updated the Favicon, but on the way looks like they have ruined the Google Calendar Updating Favicon.

Before the update, the Google Calendar Favicon was updating and showing today date (day of the month) - Very cool. Now it's just another tab with the same Google favicon logo as any other tab or window. 

Now - Bad:






Before - Good:




יום רביעי, 4 במרץ 2015

Looks like a bug in Google Charts for aria-label="A tabular representation of the data in the chart."

Looks like a bug in Google Charts Library.

It have a new feature adding a div with aria-label="A tabular representation of the data in the chart." that holds the data of your graph in a table.


But for me it created a bug in the css causing the whole screen to be very wide with a bottom scroll. After some investigations with Firebug I noticed the
aria-label="A tabular representation of the data in the chart." have a style="position: absolute; left: -10000px" causing this endless horizontal scroll.

The solution for me was to add in the css a "display:none":

.small_graph svg + div {display:none;}



יום רביעי, 28 בינואר 2015

פיצ' הסבר על אפליקציית Navi.do - סטארטאפ שאני שותף לו

לשם קבלה לתכנית האצה Accelerator של מיקרוסופט, ערכנו בזריזות סרטון הסבר קצר על אפליקציית Navi.do - סטארטאפ חדש שאני שותף לו:



http://youtu.be/JdRzZZce9ZE

יום רביעי, 7 בינואר 2015

Eclipse Crashing for No Good Reason - A few tips might help


Eclipse is currently a necessary evil. I'm using it only because I haven't found anything better yet. It is big, bloated, heavy, slow with many hidden windows and hard to configure. But, it have many plugins, like PHP (PDT), it works with Android and Java of course, have a decent intellisense and auto-complete. Eclipse is probably the most common IDE for open-source environment.

Yet, the biggest problem, and I am not the only one having it, is that eclipse suddenly crashes, open the splash screen and then close with no good reason. How to determine why does eclipse crashes and how to fix it ?

Here is a list of things that I have done in order to overcome it. Yet, I still don't know how to debug why eclipse crash.

Reinstall:
First of all, let's remove eclipse installation:
sudo apt-get autoremove eclipse* --purge

Remove eclipse plugins:
rm -rf  /usr/lib/eclipse

Delete the workspace:
rm -rf ./workspace

Delete each project and project settings:
rm -rf ./.settings .project .buildpath

Reinstall Eclipse (better use the eclipse fresh installation download from eclipse.org)

If problem still occurs:

Add to eclipse.ini :
-Dorg.eclipse.swt.browser.DefaultType=mozilla
-debug
-nosplash

Try adjusting your JDK (Use Orcale or OpenJDK):
Remove your JDK and reinstall it.
use command for setting the JDK:
sudo update-alternatives --list java
sudo update-alternatives --list javac
sudo update-alternatives --config java
sudo update-alternatives --config javac

Try running eclipse from command line with those parameters:
./eclipse -clean -clearPersistedState

To find eclipse logs:
[your-workspace-dir]/.metadata/.log


Hope it will help. If you have more ideas, please comment or send me.