Set up VNC on Ubuntu 14.04

Set up VNC on Ubuntu 14.04

Setting up VNC on Ubuntu used to be pretty painless. But recent changes in Ubuntu and X have left it kind of a mess. It took me way longer to set up VNC than it should have, and finding the documentation wasn’t super-easy either. There were lots of broken guides. So, here’s what you need to do:

  • Follow these setup instructions first:
    https://www.howtoforge.com/how-to-install-vnc-server-on-ubuntu-14.04
  • When completed, however, a known issue means the screen will come up blue-grey and have few desktop controls if you try to connect to it. This is because (near as I can tell) the X manager currently used for Ubuntu doesn’t work over VNC anymore. You need to set VNC up to use an older desktop manager that
  • To fix that problem, you need to fix things according to this guide:
    http://onkea.com/ubuntu-vnc-grey-screen/
  • On your client, start the vncserver and connect to it by matching the final digit of the port number to the :X number you used to create it.
    • Example:
      host: vncserver :4 –geometry 800×600 (to create the server)
      client should use the ip: 10.23.47.150:5904
  • If you get an error starting the vncserver, increment the :2 to :3 or :4 and so forth until you find one not in use by some other user on the server.

OpenGL ES 2.0/3.0 Offscreen rendering with glRenderbuffer

OpenGL ES 2.0/3.0 Offscreen rendering with glRenderbuffer

Rendering to offscreen surfaces is a key component to any graphics pipeline. Post-processing effects, deferred rendering, and newer global illumination strategies all use it. Unfortunately, implementing offscreen rendering on OpenGL ES is not well documented. OpenGL ES is often used on embedded/mobile devices, and until recently, these devices haven’t typically had the graphics bandwidth to keep up with new rendering techniques. Compound this with the fact that many mobile games have simple gameplay/small screens that do not need such complex lighting models, many people now use off the shelf engines for their games, and that there is still a good amount of mobile hardware out there that doesn’t even support render to offscreen surfaces, and it is no surprise that few people use the technique and it’s not well discussed.

In implementing offscreen rendering for OpenGL ES, I turned to the very good OpenGL ES Programming book as it has a whole chapter on framebuffer objects. When I tried the samples in the book, however, I was having a lot of difficulty getting it working on my linux-based mobile device. A lot of the implementation examples use a technique of creating framebuffer objects using textures, but you can also use framebuffer objects via something called render buffers. One reason this is good to know is because many hardware vendors support very few render-to-texture formats. You can often find yourself struggling with your implementation not working because the output formats aren’t supported.

Thankfully, I found this article and thought I’d copy the information here since it’s the only place I’ve seen working code that demonstrated the technique. It also includes the very important step of reading the output format and uses glReadPixels() so you can validate that you were writing correctly to the offscreen renderbuffer surface.

In my case, on an Intel graphics part, I found that the format (which is also the most recommended one) that worked  was GL_RGB/GL_UNSIGNED_SHORT_5_6_5. Steps 1-8 is standard OpenGL ES setup code that is included so you can verify your setup. Step 9 is where the glFrameBuffer and glRenderBuffer objects are created.

 

    #define CONTEXT_ES20

    #ifdef CONTEXT_ES20
        EGLint ai32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
    #endif

    // Step 1 - Get the default display.
    EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)0);

    // Step 2 - Initialize EGL.
    eglInitialize(eglDisplay, 0, 0);

    #ifdef CONTEXT_ES20
    // Step 3 - Make OpenGL ES the current API.
    eglBindAPI(EGL_OPENGL_ES_API);

    // Step 4 - Specify the required configuration attributes.
    EGLint pi32ConfigAttribs[5];
    pi32ConfigAttribs[0] = EGL_SURFACE_TYPE;
    pi32ConfigAttribs[1] = EGL_WINDOW_BIT;
    pi32ConfigAttribs[2] = EGL_RENDERABLE_TYPE;
    pi32ConfigAttribs[3] = EGL_OPENGL_ES2_BIT;
    pi32ConfigAttribs[4] = EGL_NONE;
    #else
    EGLint pi32ConfigAttribs[3];
    pi32ConfigAttribs[0] = EGL_SURFACE_TYPE;
    pi32ConfigAttribs[1] = EGL_WINDOW_BIT;
    pi32ConfigAttribs[2] = EGL_NONE;
    #endif

    // Step 5 - Find a config that matches all requirements.
    int iConfigs;
    EGLConfig eglConfig;
    eglChooseConfig(eglDisplay, pi32ConfigAttribs, &eglConfig, 1,
                                                    &iConfigs);

    if (iConfigs != 1) {
        printf("Error: eglChooseConfig(): config not found.n");
        exit(-1);
    }

    // Step 6 - Create a surface to draw to.
    EGLSurface eglSurface;
    eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig,
                                  (EGLNativeWindowType)NULL, NULL);

    // Step 7 - Create a context.
    EGLContext eglContext;
    #ifdef CONTEXT_ES20
        eglContext = eglCreateContext(eglDisplay, eglConfig, NULL,
                                               ai32ContextAttribs);
    #else
        eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);
    #endif

    // Step 8 - Bind the context to the current thread
    eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
    // end of standard gl context setup

    // Step 9 - create framebuffer object
    GLuint fboId = 0;
    GLuint renderBufferWidth = 1280;
    GLuint renderBufferHeight = 720;

    // create a framebuffer object
    glGenFramebuffers(1, &fboId);
    glBindFramebuffer(GL_FRAMEBUFFER, fboId);

    // create a texture object
    // note that this is commented out/not used in this case but is
    // included for completeness/as example
    /*  GLuint textureId;
     glGenTextures(1, &textureId);
     glBindTexture(GL_TEXTURE_2D, textureId);
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);                             
     //GL_LINEAR_MIPMAP_LINEAR
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_HINT, GL_TRUE); // automatic mipmap
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, renderBufferWidth, renderBufferHeight, 0,
                  GL_RGB, GL_UNSIGNED_BYTE, 0);
     glBindTexture(GL_TEXTURE_2D, 0);
     // attach the texture to FBO color attachment point
     glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                         GL_TEXTURE_2D, textureId, 0);
     */
     qDebug() << glGetError();
     GLuint renderBuffer;
     glGenRenderbuffers(1, &renderBuffer);
     glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
     qDebug() << glGetError();
     glRenderbufferStorage(GL_RENDERBUFFER,
                           GL_RGB565,
                           renderBufferWidth,
                           renderBufferHeight);
     qDebug() << glGetError();
     glFramebufferRenderbuffer(GL_FRAMEBUFFER,
                               GL_COLOR_ATTACHMENT0,
                               GL_RENDERBUFFER,
                               renderBuffer);

      qDebug() << glGetError();
      GLuint depthRenderbuffer;
      glGenRenderbuffers(1, &depthRenderbuffer);
      glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
      glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,     renderBufferWidth, renderBufferHeight);
      glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);

      // check FBO status
      GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
      if(status != GL_FRAMEBUFFER_COMPLETE) {
          printf("Problem with OpenGL framebuffer after specifying color render buffer: n%xn", status);
      } else {
          printf("FBO creation succeddedn");
  }

  // check the output format
  // This is critical to knowing what surface format just got created
  // ES only supports 5-6-5 and other limited formats and the driver
  // might have picked another format
  GLint format = 0, type = 0;
  glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
  glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);

  // clear the offscreen buffer
  glClearColor(1.0,0.0,1.0,1.0);
  glClear(GL_COLOR_BUFFER_BIT);

  // commit the clear to the offscreen surface
  eglSwapBuffers(eglDisplay, eglSurface);

  // You should put your own calculation code here based on format/type
  // you discovered above
  int size = 2 * renderBufferHeight * renderBufferWidth;
  unsigned char *data = new unsigned char[size];
  printf("size %d", size);

  // in my case, I got back a buffer that was RGB565
  glReadPixels(0,0,renderBufferWidth,renderBufferHeight,GL_RGB, GL_RGB565, data);

  // Check output buffer to make sure you cleared it properly.
  // In 5-6-5 format, clearing to clearcolor=(1, 0, 1, 1)
  // you get 1111100000011111b = 0xF81F in hex
  if( (data[0] != 0x1F) || (data[1] != 0xF8))
      printf("Error rendering to offscreen buffern");

  QImage image(data2, renderBufferWidth,  renderBufferHeight,renderBufferWidth*2, QImage::Format_RGB16);
  image.save("result.png");
Fedora scp: connection refused

Fedora scp: connection refused

I was trying to scp some files and kept getting this:

scp: connect to host 134.xxx.xxx.xxx port 22: Connection refused

Some linux distros, like the ancient Fedora 21, have ssh daemon turned off by default. So, turn it on:

sudo service sshd start
A lost opportunity

A lost opportunity

I put this question to you when you are fearful of letting in the foreigner, immigrant, or refugee. Is it violence or the faith of one person or family you fear – or is it more that you are afraid your charity, compassion, or love are not up to the task of touching the heart of a stranger? Perhaps you lack faith that God is powerful enough to use your life and example to touch the hearts of even those that might wish you harm? Or perhaps you’re afraid of your own laziness or unwillingness to let Him use you at all – for fear of what it will cost you? Are you too prideful to turn the other cheek if you do find yourself struck for doing what is right for another?

These words accused me as I reflected on Pope Francis’ request every parish in Europe (but really is a call to all countries) to open their doors to shelter at least 1 refugee family. (http://wgntv.com/2015/09/06/pope-francis-encourages-catholics-to-shelter-refugees/) This call was picked up by some but was also ignored and even denounced by others.

I realize now how much of a lost opportunity this has been. Even if you are not of a faith background. Why? Several reasons.

In traveling the world,I have learned that our governments may be very opposed, but the daily people you meet rarely are. Even old enemies are best won over in 1 to 1 interactions. There are countless stories in which a simple act of kindness have created bonds of friendship during WW 2 that last to this day. I personally have made friends in countries that were once our enemies by simple, daily acts of respect and compassion. That has helped me realize the power each of us has in the smallest acts and that they are often more powerful than all the laws of governments.

Isolation affects the host countries too. Without contact to others of different backgrounds we become increasingly afraid of our ability to connect. Both sides become easy targets for those leaders that wish to scapegoat and blame others for problems.

The Pope’s call to host a family was also wise because it does not throw all these new arrivals into one large camp or neighborhood. On a practical level, even if those we bring over turn out to disagree with our culture, our 1 on 1 interactions can change hearts and minds.By having each member in a loving, supportive community – they can integrate faster and learn the truth of who we are. It also ‘breaks up’ groups that suffer from poverty, joblessness, and fear. Some of the Paris attackers appear to have been radicalized after they arrived as they were isolated in small districts without jobs, legal status, or much hope in a foreign land with strange customs. So instead of concentrating refugees into neighborhoods and camps that fester, in a holding pattern of government bureaucracy, they are introduced into a welcoming community that helps them do what we all want to do: be independent and feel proud of themselves and their work.

Instead, we have erected walls. Walls that separate these individual acts of kindness and relationship from reaching each other. Further, what is a person that is facing death every day to think of a people who live in extravagance and luxuriously – who do not lift a finger to help them? Perhaps they even claim to follow a loving God who helps the foreigner, the orphan, and widow? I do not think it would not make me think very highly of them. As a believer, it makes me a hypocrite.

Jim Rohn is famous for his quote, “You are the average of the five people you spend the most time with.”. Psychologists would clarify a bit and say our peer groups are some of the most powerful influences in our lives. If we surround those in these desperate straits, even those who feel on the verge of radicalizing,with love, compassion, and respect, we can change hearts and minds more than laws likely ever will.

So lets follow our call to action. Go and encounter the refugee and the foreigner. It is not enough to let them in and stuff them in a corner and ignore them under a burden of red tape that simply radicalize them. We must risk a relationship. We must trust that Christ is powerful enough to use us – and then through humility, struggles, and learning to adapt – we must be willing to let go and let Him guide us.

 

Portland woman gets snake stuck in her earlobe

Portland woman gets snake stuck in her earlobe

Yet another reason for your 17-year old goth kid to not to get gauge piercings and a ball python at the same time.

Bart was hanging out on her shoulders when Glawe thought he started attacking her head. “I like froze instantly,” she told CNN. The snake wasn’t attacking but “pythons just like hiding in holes.”
She tried to get him out by herself but couldn’t. So she said the fire department came. The fire department was unable to remove BART so instead, Glawe said she went to the emergency room, where doctors numbed her ear and lubed her and Bart up and were able to get the snake out of the hole.

http://www.oregonlive.com/trending/2017/02/portland_woman_gets_snake_stuc.html

New AI just ‘decisively’ beat pro poker players in 7 day tourney and demonstrates mastery of imperfect information games

New AI just ‘decisively’ beat pro poker players in 7 day tourney and demonstrates mastery of imperfect information games

Developed by Carnegie Mellon University, a new AI called Libratus won the “Brains Vs. Artificial Intelligence” tournament against four poker pros by $1,766,250 in chips over 120,000 hands (games). Researchers can now say that the victory margin was large enough to count as a statistically significant win, meaning that they could be at least 99.7 percent sure that the AI victory was not due to chance.

The four human poker pros who participated in the recent tournament spent many extra hours each day on trying to puzzle out Libratus. They teamed up at the start of the tournament with a collective plan of each trying different ranges of bet sizes to probe for weaknesses in the Libratus AI’s strategy that they could exploit. During each night of the tournament, they gathered together back in their hotel rooms to analyze the day’s worth of plays and talk strategy.

The AI took a lead that was never lost. It see-sawed close to even mid-week and even shrunk to $50,000 on the 6th day. But on the 7th day ‘the wheels came off’. By the end, Jimmy Chou, became convinced that Libratus had tailored its strategy to each individual player. Dong Kim, who performed the best among the four by only losing $85,649 in chips to Libratus, believed that the humans were playing slightly different versions of the AI each day.

After Kim finished playing on the final day, he helped answer some questions for online viewers watching the poker tournament through the live-streaming service Twitch. He congratulated the Carnegie Mellon researchers on a “decisive victory.” But when asked about what went well for the poker pros, he hesitated: “I think what went well was… shit. It’s hard to say. We took such a beating.”

The victory demonstrates the AI has likely surpassed the best humans at doing strategic reasoning in “imperfect information” games such as poker. But more than that, Libratus algorithms can take the “rules” of any imperfect-information game or scenario and then come up with its own strategy. For example, the Carnegie Mellon team hopes its AI could design drugs to counter viruses that evolve resistance to certain treatments, or perform automated business negotiations. It could also power applications in cybersecurity, military robotic systems or finance.

http://spectrum.ieee.org/automaton/robotics/artificial-intelligence/ai-learns-from-mistakes-to-defeat-human-poker-players

Hong Kong In The 1950s Captured By Teenager Ho Fan

Hong Kong In The 1950s Captured By Teenager Ho Fan

Ho Fan was a teenager when he moved from Shanghai to Hong Kong in the 1950’s. He started taking street photography when everyone else was taking studio shots. He developed them in the family bathtub.

His results are astounding and humbling. He has a better eye than 9/10th of current professional photographers. His work has been published in 2 separate books – one in its 5th edition.

Hong Kong In The 1950s Captured By A Teenager

Fingerprints are not security

Fingerprints are not security

Jan Krissler, known in hacker circles as Starbug, was already known for his high-profile stunt of cracking Apple TouchID sensors within 24 hours of the iPhone 5S release. In this case, he used several easily taken close-range photos of German defense minister Ursula von der Leyen, including one gleaned from a press release issued by her own office and another he took himself from three meters away, to reverse-engineer her fingerprint and pass biometric scans.

The same conference also demonstrated a “corneal keylogger”. The idea behind the attack is simple. A hacker may have access to a user’s phone camera, but not anything else. How to go from there to stealing all their passwords?

One way, demonstrated on stage, is to read what they’re typing by analyzing photographs of the reflections in their eyes. Smartphone cameras, even front-facing ones, are now high-resolution enough that such an attack is possible.

“Biometrics are not secrets… Ideally, they’re unique to each individual, but that’s not the same thing as being a secret.”

https://www.theguardian.com/technology/2014/dec/30/hacker-fakes-german-ministers-fingerprints-using-photos-of-her-hands