RobotsFuckYeah (all one word)

Page 2


Javascript object identities

When two things aren’t equal, but then sometimes are. This is javascript.

Easy start

Just to get us in the mood

key1 = 3
key2 = 3
key1 == key2 // obviously true

Equality of objects is a bit more unusual

key1 = [1,2,3]
key2 = [1,2,3]
key1 == key2 // false, which is weird

key1 and key2 are different objects. That’s why they aren’t equal even though it looks like they should be. Let’s see how this can cause subtle bugs.

Associative arrays

If the keys of an associative array are not equal, it’s normal to expect them to refer to different values. Illustrating this with a trivial example:

key1 = "home"
key2 = "work"
key1 == key2 // obviously false

phones = {}
phones[key1] = "99999999"
phones[key2] = "11111111"
phones[key1] == phones[key2] // also obviously false

So far nothing surprising.

But look at the unusual situation of keys being objects instead of strings:

key1 = [1,2,3]
...

Continue reading →


postfix and golang - sending emails

A quick list of steps to get a server up and running with postfix and a go script to send emails.

Install postscript

sudo apt-get install postscript

Select ‘local copy’ as the configuration and accept the defaults.

Configure postscript

vim /etc/postfix/main.cf

Change the bottom from

inet_interfaces = loopback-only
default_transport = error
relay_transport = error
inet_protocols = all

to

inet_interfaces = all
inet_protocols = all

A go script to send emails

package main

import (
    "fmt"
    "net/mail"
    "net/smtp"
    "strings"
)

var host = "127.0.0.1"
var port = "25"
var username = ""
var password = ""
var auth = smtp.PlainAuth("", username, password, host)
var addr = host + ":" + port

func main() {
    fromName := "Fred"
    fromEmail := "fred@example.com"
    toNames := []string{"Ted"}
    toEmails := []string{"ted@example.com"}
    subject := "This is the subject
...

Continue reading →


JavaEE Simple Web App with GlassFish

This is a guide to starting a basic web project for JavaEE. It’s assumed that JavaEE is set up and ready to go.

Download Eclipse for JavaEE. It’s here: https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr2

Extract the contents and open Eclipse

tar -xvf eclipse-jee*
rm eclipse-jee*
./eclipse/eclipse

Install the GlassFish plugin

Help > Install New Software

In the ‘Work With’ field, set:
http://download.oracle.com/otn_software/oepe/12.1.3.6/luna/repository

Let it load

Select

Tools > GlassFish tools
Tools > Oracle Java EE tools

Press Next / Finish / Agree etc

Start a new project

File > New > Dynamic Web Project

Select the Target Runtime to be GlassFish. If GlassFish is not listed, you need to install it by pressing the New Runtime button and then Download additional server adapters link and selecting GlassFish. Press Next. You need to specify a...

Continue reading →


JavaEE Setup on Ubuntu 14.04

Guide for n00bs, which I am when it comes to JavaEE.

Assuming a fresh and up-to-date installation of Ubuntu 14.04

Install Java - this is the runtime environment so your java application can be executed. I tried using openjdk from the repos but it’s only java7 and java8 is required, so use the ppa to install Oracle java8.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Install Glassfish - this is basically an app that runs on your server and manages / exposes the various different JavaEE applications you’re going to write. I think of GlassFish as a container or a gateway or a wrapper or an os-in-an-os or an admin panel.

Go to the site at https://glassfish.java.net/download.html which will give instructions to download the file. The download and extraction is outlined below

wget
...

Continue reading →


Debian on Kobo Mini

Installation instructions at https://sites.google.com/site/gibekm/hardware/kobo/kobo-as-tablet

General discussions that provided a lot of the info in this post are at
http://www.mobileread.com/forums/showthread.php?t=220350
and
http://www.mobileread.com/forums/showthread.php?t=222123

Download image files from https://www.dropbox.com/sh/snsdg1c5cg21kws/3LfelXgbGe

Copy the image to a new 8GB or larger microsd card

BE CAREFUL - dd can cause irreversible damage, particularly ensure the of= value is set correctly. It may not be mmcblk0 in your case.

dd if=/home/you/path/to/image/2013-08-17_kobo_debian.img of=/dev/mmcblk0 bs=32M
sync

It probably won’t boot, but will just show a flashing green LED and a blank white screen. To fix this, copy part of the original image (source). Be very careful to use the correct if= and of= values

 insert the original microsd
sudo dd if=/dev/mmcblk0
...

Continue reading →


Global Proxy in Android

Android 4.2.2

  • Open settings
  • Select Wi-Fi
  • Long press on the wifi you’re connected to
  • Modify Network
  • Show advanced options
  • Scroll down
  • Change Proxy Settings from None to Manual
  • Enter your proxy details
  • Press save

You are now using a proxy for all network activity.

View →


Nginx with Accept-Language support

Utilizing the Accept-Language header in nginx requires a module. This is documentation about how to make it work.

I wanted to use this header to server different files for different languages. You might easily imagine having a set of static files like index_en.html, index_es.html and index_ja.html and wanting to serve one of these depending on the preferences in the Accept-Language header.

This was done on a brand-spanking-new Ubuntu 14.04 Server Edition VM.

Installing

Get the source for nginx

mkdir nginx_src
cd nginx_src
wget http://nginx.org/download/nginx-1.6.0.tar.gz

Extract it

tar -xvf nginx-1.6.0.tar.gz

Get the accept_language_module

cd ~
git clone https://github.com/giom/nginx_accept_language_module.git

or

wget https://github.com/giom/nginx_accept_language_module/archive/master.zip
unzip master.zip
mv nginx_accept_language_module{-master,}

Install the dependencies

...

Continue reading →


GUI as an adjective

I’m lucky to currently be working in an office with no other programmers and only graphic designers.

I’m used to working with other software developers, which I enjoy because we have a lot of crossover in our day-to-day work. But working with people outside my normal experience is really interesting.

One of the designers said something I’d probably never hear a programmer say. They used the word GUI as an adjective. Funnily enough, the subject was about a GUI for a web application, but their phrasing was something like ‘We need it to be really GUI’.

Programmers know GUI as a noun - a Graphical User Interface. A GUI is a thing with a specific form and purpose, it has properties and functions.

But to this designer, GUI was a description, a concept, a sense, an emotion. Imagine living in a GUI house, working in a GUI office, having GUI friends, making your meetings more GUI, living a...

Continue reading →


Fuji Xerox Printers on 64 bit linux

Printing and Linux is (at least to me) often like an Office Space frustration. I was pleasantly surprised when the printer at work (Fuji Xerox ApeosPort-IV C2270 - a name of pure marketing genius) worked with barely any pain on Ubuntu 13.10 64 bit.

When I upgraded to 14.04 it was a sad story that the old drivers I was using no longer worked.

Here is my recollection of the rabbit-hole and eventual compromise/solution.

1) Drivers come from
http://www.fujixerox.co.jp/download/apeosport/download/c4300series/linux/
at the bottom of the page work - they’re a .rpm file but will open with archive manager and can be extracted to the appropriate locations easily (you’ll have to be root). The main thing is to get the filters in the right spot.

2) Add the printer via the settings panel, but manually select the ppd file just extracted rather than automatically look for drivers.

3) Print...

Continue reading →


Social Movements

Culture / society : two interesting and related words.

There have been some significant and well-documented periods of time that correlate with a particular type of cultural growth (primarily in the western world)

Periods of cultural growth:

  • enlightenment was about using reason
  • modernism was about being new
  • postmodernism was about being cynical

There are some competing words for what term will be applied to the cultural ‘post-postmodern’ movement. Altermodernism is the one that has most piqued my interest. I think whatever name is applied, the post-postmodern period will be remembered for being about acceptance.

Cultures will accept each other. They will be better connected so information will flow between cultures better. Cultures will take the parts that resonate most between each other (dare I say it, the 'good’ parts from each), and merge them into an altermodern culture.

...

Continue reading →