[jug.bg] Adopt a JSR (CDI 2.0 with Antoine Sabot-Durant) 

Antoine spent a while day with us explaining CDI 1.2 and the upcoming 2.0. We discussed CDI extensions and he wrote some live code.

Links:

These are the slides from the last session. The most interesting part.

[jug.bg] jProfessionals 3.0 Venkat Subramaniam

Usually I do the review of what we do in our JUG, but Dmitry did quite a good job and he has the best pictures.

Some minor additions from me:

Venkat Subramaniam also known simply as Venkat was here. Venkat is a rockstar (JavaOne Rockstar is someone who did an amazing session at JavaOne. Venkat is 16 (sixteen!!!) times J1 Rockstar in just 4 years).

14590108_10209666223585737_642560942851602417_o-1

Venkat did two sessions and a workshop. The two sessions (one on lambdas and one soft-code session on bad code) were highly popular, probably 150-200 people came.

Then there was a workshop that turned into a discussion on lambdas and quality code in general. Which was awesome.

More info on the event page in facebook and on our jProfessionals social page. Photo album.

Some highlights:

14572767_10211127009798939_2903683900575372082_n

14590067_10209666230545911_2854270441218995292_o-1

14525157_10154174348204811_3398045179896873701_o

14691280_1715325688789631_4489935881640852493_o

14692160_1715325678789632_7790867019126340358_o

 

Buying a new openwrt-compatible router. Howto

I need a new router, because the time machine I have been using for so long is finally giving up. It was a pretty strong machine. God bless her soul. Now I'd like to have something like this as a router:
solid run
https://www.solid-run.com/product/clearfog-pro/ But that's pricey and needlessly powerful, it costs extra to add wifi, box, power and so on.

OpenWRT

Since I found out OpenWRT exists I have continuously rooted my routers. OpenWrt is minimalistic linux made especially for routers. I don't like the fact that it's not a full-fledged linux - they had to minimize the footprint and some packages are incomplete/different. But it does its jobs perfectly.

There is a hardware compatibility list which now features devices with 1gb ram and 4gb flash. Unfortunately they either have no wifi, or not enough lan ports. Even the Bulgarian producer Olimex is featured close to the top.

Starting from top to bottom, here's how I chose my router:
(I skip all that have no wifi)

  • FLASH MB/RAM MB/NAME/Reasons
  • 256/1024/Gateworks Ventana GW5xxx/only two GbE ports;hard to buy
  • 16/128/EnGenius ECB1750/no GbE
  • 16/128/Belkin F9K1115/hard to buy
  • 32/128/WZR-HP-AG300H/no ac
  • 32/128/Meraki Z1/no ac
  • 16/128/EnGenius ECB1750/no GbE

Possibilities (all of them are available in local shops):
(all of them support some type of ac on 5Ghz)

  • FLASH MB/RAM MB/NAME/PRICE
  • 128/512/Linksys WRT1900AC/€235
  • 128/128/Cisco-Linksys EA6300/€106
  • 128/256/Buffalo WZR-600DHP2-EU/€100
  • 128/128/Netgear R6100/€100
  • 16/128/ZyXEL NBG6616/€85
  • 16/128/TP-LINK Archer C7/€98
  • 16/128/TP-LINK Archer C5/€75
  • 16/128/D-Link DIR-860L/€53

In the table I didn't put CPU type and whether they have USB 2/3 ports.

Poor guy's monitor emulator

Some mainboards won't boot without an active graphics chip which in turn won't start without a monitor connected.

This hack works with 3 resistors (75 ohm (50-150 is fine), 0.25 watt (0.125-0.500 watt is fine)).


Putt them like this

vga_dummy_electronic_schema

Resources:

https://www.techpowerup.com/forums/threads/how-to-make-a-dummy-vga-dongle.86507/
http://www.geeks3d.com/20091230/vga-hack-how-to-make-a-vga-dummy-plug/
http://www.electronics-lab.com/how-to-make-a-vga-dummy-plug/

[jug.bg] Speaking at Riga Dev Day

So I'll do a talk about Http/2.0 at Riga Dev Day Conference. I'll be there representing the jug.bg. I'm pretty psyched to check out Latvia.

My session is on the first day

speaking-at-rdd16-2

Update: my talk didn't go too well, because of projector issues. 15 min gone, flickering screen and me nervous ... overshot my time.

And to top it all of they recorded it and said it will go to youtube in a couple of months. 🙁

Not that it matters, but all my demos worked, kind of a Pyrrhic victory.

Update2: Riga is awesome and very beautiful.

IMG_6612 IMG_6616 IMG_6641

[jug.bg] "Everything you need to know about Java Classloaders" by Oleg Shelajev

IMG_6594

Today Oleg presented a very interesting session about how class loaders work. He even remotely loaded classes from images (I imagine steganography).

Oleg works for Zero Turnaround, the company behind jRebel. Code examples here. The presentation is here.

One of the most interesting sessions so far IMHO.

[jug.bg] jProfessionals 2.0

Today was the second edition of the jProfessionals format we started 5 months ago.

IMG_6574

jProfessionals is a one-day free conf. Smaller than jPrime (our star yearly event).

In the first version we invited Koshuke Kawaguchi. (the creator of Jenkins CI).

 

Today the first presenter was Richard Warburton.

IMG_6573

The session was about java 8 lambdas and even though it started as a very introductory session it turned out to be quite interesting. We discussed currying, Optional and the elvis operator.

What I learned is that Optional with value types is going to be fast (all in stack, no heap). Elvis is going in another direction - just a simple !=null check. Optional is kind of an explicit contract (preferred despite the verbosity and the extra object).

 

The second speaker was Vlado Tsanev aka tsachev.

IMG_6575

He talked about Spring REST Docs. The talk was one big live demo. REST Docs is a way to document a rest api automatically by extracting the info from the tests - it creates cURL commands, headers, params as so called snippets, and it allows the use of a adoc files with links to the REST Docs snippets.

 

After a tasty lunch it was time for "The Seven Deadly Sins of Microservices" by Daniel Bryant.

IMG_6576

It was a soft session with a lot of links and cool ideas of what microservices are good for and what they are not. There was a discussion on where people fail mostly using them. Very interesting and engaging - I bookmarked a lot of books that I'm never going to read.

 

Doychin Bondzev talked about Firebird (an alternative to postgres) - free, has triggers and is embeddable with nice tools and binary backup that is fast enough on windows.

 

Richard Warburton was next with another session for the future of Generics which was really fun.

IMG_6577

I finally understood why enums are defined recursively (Enum<E extends Enum<E>>).

 

Next was a talk about Jenkins Builds with Docker Containers by Petar Velikov from e-card.bg.

IMG_6578

It was quite interesting especially the docker part (he even used dockviz).

 

Finally there were two lightning talks. Martin Toshev talked about RxJava and RxJS.

Another guy - Teodor Tunev talked about Activiti - a java BPM platform far better than jBPM in his words.

IMG_6578

 

Finally some beer was due.

IMG_6580

(has not arrived yet)

Fosdem 2016

My first fosdem this year. I found a lot of interesting things mostly on the opensource tracks. The "free java" track IMHO was a bit unpopular even though Stephen Chin and Mark Reinhold were there.

I guess I'm used to a better treatment on a conference (I go mostly as a speaker). Here it was rainy and cold and even though the french fries were awesome, I'm used to better food.

IMG_6498 IMG_6499 IMG_6500

[jug.bg] Dockerize Spring Boot Application

Antoan presented a session about Spring Boot running on Docker and how to use the docker maven plugin inside a Spring Boot application.

Actually we talked mostly about running Docker and application from the ecosystem. There was a statement that uninstalling Kitematic requires payment, which started a discussion about this model.

IMG_6532

Explaining to young female students that an IT career doesn't suck (that much)

IMG_2305

It was a surprise to me, but I got invited to a forum organized by HP to explain to young women that a career in IT is not scary, doesn't suck at all and why it might be something that they may enjoy.

There were around 50 guests.

I was invited as an example of a "young" "successful" person. It was an honor sitting next to the Iravan Hira (CEO of HP Bulgaria), Preslav Pavlov (Global Deliveries Director for HP), Rumyana Trencheva (CEO of SAP Bulgaria), Zornica Iankova (HP's HR Director), Kristina Stoitsova (R&D at VMware).

Modrator was webcafe.bg's owner Sibina Grigorova.

IMG_2321

The event was highly entertaining for me. The public initially wasn't keen on asking too many questions. But the discussion afterwards proved interesting. I was happy to hear that female CEOs didn't feel male colleagues treated them differently. Still there are far more males than females in IT.

IMG_2348

Of course I wore a @bgjug t-shirt.

[jug.bg] pi4j on RaspberryPi

IMG_5872

Jug.mk's leader Pance Cavkovski is talking today about how to put java on a raspberry pi and then automate your home.

There is also a slide about NodeMCU that helps you distribute GPIO around your home and control different devices. NodeMCU is a wifi-to-GPIO for $5 basically, which is awesome:

nodemcu

Today was a busy day, the beer was over in seconds and that sucks because Ivan and I only had a beer.

IMG_5873

I brought a Odroid C1. But pi4j doesn't work, so I used jOdro.

We have a new banner that we didn't forget to bring today, so there it is:

fb232f01376e5b1d7ac122e88a72766e3830a5576fe8c0b28a2866eaa10dbe13

[jug.bg] A hackaton showcasing JSR 371 (MVC) 2015.09.30

 

On 30.09.2015 we did a workshop that showcased the very beta of MVC 1.0 implemented in ozark.

We had to use glassfish, which I somehow dislike, because I don't understand it and it didn't run very smooth, but in glassfish's defense I have to say that reloading the application without restarting worked like a charm. That is awesome.

MVC is promising and I like how simple it is.

The code is here: https://github.com/bgjug/mvc10-workshop.

spring.mvc

[jug.bg] RabbitMQ session

Today we had a BGJUG event.

Martin presented RabbitMQ - Spring Framework's default message broker.
IMG_4964 IMG_4966

 

I followed the presentation and using Docker's GUI for OSX called Kitematic, easily created a rabbitmq server and a client in a maven project:

Screen Shot 2015-06-29 at 20.51.51Screen Shot 2015-06-29 at 21.07.04

Again there was a lot of beer, but since we have been accused of advertising beer brands, there will be no pics.

 

[jprime.io] Feedback

So, jprime.io is over, let's see how well we did:

Screen Shot 2015-05-28 at 17.15.33

Screen Shot 2015-05-28 at 17.18.33
Translation: A huge BRAVO. The organization was well done.
Screen Shot 2015-05-28 at 17.19.08
Translation: the event is exceptionally interesting. I learned a lot and I was inspired.
Screen Shot 2015-05-28 at 17.19.25
Translation: I liked it a lot. Please inform me if you plan to do anything again soon. The day was not wasted. Learned a lot.

---

Screen Shot 2015-05-28 at 17.23.25 Screen Shot 2015-05-28 at 17.25.20 Screen Shot 2015-05-28 at 17.25.33 Screen Shot 2015-05-28 at 17.25.48 Screen Shot 2015-05-28 at 17.26.02 Screen Shot 2015-05-28 at 17.29.57

---

Also in my inbox:

Tова което вчера казвах на Найден, че още от първата конференция бяхте много добри.

Поздрави,
—Филип

Translation: Basically Phillip is saying we are the best java conf here.

---

Another one:

Здрасти,
Браво за конфа. Получи се доста добре.
Готиното беше, че хората наистина се събираха и си говореха.
Аз трябваше да тръгна по-рано, че имах малко лични ангажименти,
и изпуснах всичко след предпоследната лекция, но това на което бях,
наистина беше готино и се усещаше приятелската атмосфера 🙂
Браво,

Стеф


From: "Stefan Vartolomeev"

Translation: Stef is saying it was nice that people communicated and that the atmosphere was friendly and the feeling altogether was cool.

---

Screen Shot 2015-05-28 at 17.48.27Screen Shot 2015-05-28 at 18.02.35 Screen Shot 2015-05-28 at 18.03.31 Screen Shot 2015-05-28 at 18.03.43 Screen Shot 2015-05-28 at 18.04.03 Screen Shot 2015-05-28 at 18.04.22 Screen Shot 2015-05-28 at 18.05.49 Screen Shot 2015-05-28 at 18.06.09

 Update:

 ...

I think we did well.

jprime: Why would someone organize a conference?

Every morning I wake up to this: Screen Shot 2015-05-20 at 23.09.29and this: Screen Shot 2015-05-20 at 22.21.30. Every day I wage a fruitless war to go down to zero on both fronts and I fail miserably. But I'm getting better.

Recently we managed to "inject" a company as a gold sponsor after all the deadlines have passed. We did it in 20 minutes after 6 phone calls.

The server firewall failed. Someone fixed it on a Saturday morning.

Our invoicing architecture after so many patches fails to follow all the complex branches of the process of issuing an invoice. We somehow manage to still use it fruitfully. And I have big plans for rewriting most of it.

ePay integration was a pain it the ass. Very bad documentation, different undocumented services, support could be better. But it was fun encrypting and decrypting a ton of messages until we stabilized it. We even "support" credit cards (in a way).

Our Turkish speaker delayed his visa application. I called the Bulgarian embassy in Ankara. They were nice, didn't forget to call me back. Actually they kept me updated the whole time. And they issued the visa in less than a day. So kudos to them.

We fight less, work more, plan better, became team players and learned a lot. Organizing a conference is fun.

Go buy a ticket at jprime.io.

[jug.bg] Simon Scholz presented Eclipse E4 in a bgjug event

Simon Scholz from Vogella presented Eclipse RCP development, the new Eclipse Mars (to be published in a month) and tips and tricks on migrating from eclipse 3 to eclipse 4.

IMG_4413

 

There were also examples on Maven Tycho, SWTBot UI testing. Simon bragged about fixing issues on the dark theme of Eclipse, which I adore, so now it's even better.

IMG_4414

Pretty funny, I had to pick Simon from the airport, so I had to have a sign:

Photo on 5-12-15 at 00.28

 

Adding another email to a primary gmail address

I use one central email address: stephen@gmail.com (email anonymized). I want to add my work address stephen@fake.company.com to my primary address so I can control it from there.

Receiving

option1: gmail's pop3 importer

Gmail cannot use IMAP to download messages (or I haven't found out how) from other mail servers. It can use POP3:

 

option2: forwarding

What i prefer is to make the mail server at fake.company.com to forward all the messages to stephen@gmail.com. This depends from server to server.

Sending

If you want to pose as stephen@fake.company.com from stephen@gmail.com, you have to use fake.company's email servers, here's how it's done:

On stephen@gmail.com's settings, do:

Gmail -> settings -> accounts -> Add another email address you own

Screen Shot 2015-03-10 at 5.56.12 PM

Then add the info of stephen@fake.company.com:

NOTE: Uncheck "Treat as an alias"

Then add the server info:

Then an email with a code will be sent to stephen@fake.company.com

Give the code to gmail:

Now we're ready, compose a new email and put a different FROM address:

Now when you receive an email to stephen@gmail.com designated for stephen@fake.company.com and you click reply, gmail will automatically put stephen@fake.company.com as the FROM address.

NOTE: People on the other side will never know you use stephen@gmail.com.

[jug.bg] Building Valhalla and using primitives as generic arguments

Project Valhalla will probably be part of Java 10 (expected 2018). Among other things it allows using primitives as generic arguments.

Building Valhalla

On a linux/unix/osx box we start with:

hg clone http://hg.openjdk.java.net/valhalla/valhalla
cd valhalla
bash get_source.sh  #this one takes some time
bash configure
make clean images # this one takes some cpu

Box<int>

We can have a class like this:

public class Program  {
	public static void main(String[] args) {
		// this one still doesn't work, List not updated to List
//		List l = new ArrayList();
//		l.add(5);
//		System.out.println(l.get(0));
 
		Box b = new Box(6);
		System.out.println(b.get());
	}
}
 
class Box {
    private final T t;
    public Box(T t) { this.t = t; }
    public T get() { return t; }
}

javap

Running javap gives

$ javap -c Program.class gives:
[openjdk@localhost bin]$ ./javap -c Program.class 
Compiled from "Program.java"
public class Program {
  public Program();
    Code:
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."":()V
       4: return
 
  public static void main(java.lang.String[]);
    Code:
       0: new           #2                  // class "Box${0=I}"
       3: dup
       4: bipush        6
       6: invokespecial #3                  // Method "Box${0=I}"."":(I)V
       9: astore_1
      10: getstatic     #4                  // Field java/lang/System.out:Ljava/io/PrintStream;
      13: aload_1
      14: invokevirtual #5                  // Method "Box${0=I}".get:()I
      17: invokevirtual #6                  // Method java/io/PrintStream.println:(I)V
      20: return
}

Running our pretty simple app gives:

[openjdk@localhost bin]$ ./java Program
Specializing Box${0=I}; searching for Box.class (not found)
Specializing Box${0=I}; searching for Box.class (found)
6
[openjdk@localhost bin]$

Notes: List is still not parameterized with because ... issues.

Building OpenJDK and submitting a solution on a feature request with the Bulgarian Java User Group

So yesterday was a memorable day.

We gathered the Bulgarian Java User Group and, as a hands-on-lab, in 3 hours we created a pretty complex patch on a open issue in the JDK Bug System. We plan to submit a webrev patch after we polish the code and supply better tests.

We've been playing with the OpenJDK code for quite some time. We have setup an easily distributable virtual machine (actually two virtual machines - fedora and ubuntu) that can be found here:
http://bgjug.sty.bz
They have everything in there with clear instructions on how to build the code and start IntelliJ IDEA as the IDE.

The issue is this one:
https://bugs.openjdk.java.net/browse/JDK-5050783
That has been a request for quite some time. Apache Commons Lang even has an utility method.

Here are the slides of the hackaton:
http://www.slideshare.net/IvanIvanov138/first-adoption-hackathon
And here are the instructions:
http://bgjug.sty.bz/bgjug/OpenJDK-hol.pdf

We even had some beer:
IMG_20141211_203819

The patch included a pretty heated discussion on whether we should use the Apache's Commons Lang approach:

public static String getStackTrace(Throwable throwable) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw, true);
    throwable.printStackTrace(pw);
    return sw.getBuffer().toString();
}

or we should rewrite some private classes inside java.lang.Throwable.

Here's the updated Throwable code:
First we added a method:

/**
 * Returns string representation of this throwable and it's backtrace.
 *
 * @return string representation of this {@code Throwable} and it's backtrace
 */
public String getStackTraceString() {
    final StringBuilder sb = new StringBuilder();
    printStackTrace(new WrappedStringBuilder(sb));
 
    return sb.toString();
}

We renamed the ill-named PrintStreamOrWriter to StackTraceFacade and added another implementation:

private static class WrappedStringBuilder extends  StackTraceFacade {
    private static final String NEW_LINE = System.getProperty("line.separator");
    private final StringBuilder builder;
 
    WrappedStringBuilder(StringBuilder builder) {
        this.builder = builder;
    }
 
    @Override
    Object lock() {
        return builder;
    }
 
    @Override
    void println(Object o) {
        builder.append(o).append(NEW_LINE);
    }
}

We decided to reimplement and change the private inner class, because the Commons Lang uses StringWriter that internally uses the StringBuffer which is synchronized and we don't want that, since we sync on an upper level.
Here's a small JTREG test we created:

import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import java.lang.Throwable;
/*
 * @test
 * @bug 5050783
 * @summary Basic test of serialization of stack trace information
 * @author Bulgarian JUG
 * @run testng java.lang.Throwable.GetStackTraceString
 */
public class GetStackTraceString {
    @Test
    public void doTest() {
        try{
            double a =100/0;
        }catch (Throwable t){
            assertTrue(t.getStackTraceString().length()&gt;0);
        }
    }
}

USB over IP - connect directly to a remote usb device

Problem1: My printer's scanner does not work over the wire with OSX. So the scanner part works by cable only. Well what if I put the usb cable over the wi-fi? Well, now I have a wireless scanner.

Problem2: I have a remote backup drive that I want to keep bootable and encrypted. Was it possible before this? I couldn't make it work. Is it possible now? I think so.

VirtualHere is a commercial software. For free it allows one simultaneous device, if you disconnect the first, you can use the second. It works flawlessly.

Its server has builds for most linuxes plus OpenWrt. The client is very simple, builds for osx, win, linux.

There are FOSS alternatives. If anyone has tried them, please share some info.

macports vs. homebrew

&gt;sudo port install imagemagick

Goes for 40 min, still not done, I got bored and stopped. And my laptop was overheating.

&gt;brew install imagemagick

Done in 15 seconds.

The reason is that macports compiles everything and the ports are very granularized, while with homebrew most items are less granularized and are precompiled.

Talk smtp to gmail with openssl s_client

Here are the basic commands to talk smtp to gmail.

We will send email from sender@gmail.com to recepient@gmail.com
The gmail password of sender@gmail.com is "my secret password".

Preparation:

To authenticate, we need our user/pass in base64 format:
base64("sender@gmail.com") = c2VuZGVyQGdtYWlsLmNvbQ0K
base64("my secret password") = bXkgc2VjcmV0IHBhc3N3b3Jk

To get the base64 encoded string, google "base64 online encoder" and click on any of the online encoder/decoders.

If you're using Gmail's two-step authentication

Go to https://security.google.com/settings/security/apppasswords and get a one-time password.

Ending the DATA of the email.

To end the DATA part, we need to press dot (".") and then Enter (which should send CRLF).

Important NOTE: I'm on a macbook, and the terminal client sends LF when I press enter. When I want to send CRLF, I press Ctrl+V, Enter. If you don't know what I'm talking about, after the dot (".") if it doesn't work with dot and Enter, press [dot, Ctrl+V, Enter].

The commands

We will use S_client which is like telnet, but supports SSL (encrypted telnet). You will need OpenSSL for that purpose.

[mihail@arch ~]# openssl s_client -connect smtp.gmail.com:587 -starttls smtp
[a lot of text will be printed - ssl info. For simplicity ignore it.]
---
250 SMTPUTF8
auth login
334 VXNlcm5hbWU6
c2VuZGVyQGdtYWlsLmNvbQ0K
334 UGFzc3dvcmQ6
bXkgc2VjcmV0IHBhc3N3b3Jk
235 2.7.0 Accepted
helo
250 mx.google.com at your service
mail from:<sender@gmail.com>
250 2.1.0 OK dc8smxxxxwib.7 - gsmtp
rcpt to:<recepient@gmail.com>
250 2.1.5 OK dc8smxxxxwib.7 - gsmtp
data
354 Go ahead dc8smxxxxwib.7 - gsmtp
from:<sender@gmail.com>
to:<recepient@gmail.com>
subject:manual smtp with gmail
some text as the body of the email
more lines of text

.
250 2.0.0 OK 1414600919 dc8smxxxxwib.7 - gsmtp
quit
221 2.0.0 closing connection dc8smxxxxwib.7 - gsmtp
read:errno=0
[mihail@arch ~]#

 

 

Update1:

If you want to use SSL 465, the command is:
#openssl s_client -connect smtp.gmail.com:465 -tls1

(here you need to start with HELO, and then AUTH LOGIN - I don't know why)

Update2:

Also, some accounts fail with:

3073894076:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:

I don't know why. It seems like it wants to fall back to ssl3.

TRIM suppport in OS X Maverics

Check System Information on TRIM support, should say No

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
sudo perl -pi -e 's|(^\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
sudo touch /System/Library/Extensions/

reboot

Check System Information on TRIM support, should say Yes

Source: http://www.return1.at/trim-enabler-for-osx/

Update: my writes went from ~333mb/sec to 400-475 mb/sec on blackmagic disk speed test

Simple and light bootable flash to change NT password (I tested on Windows Vista)

I recently had to fix a changed Administrator password on a Windows Vista (most probably by malware, it disabled all admin users and changed passwords).

One can only use the Ubuntu Desktop installer with chntpw, but it is large and it's pointless to use it for this task. I found a very simple distro to use for the same task.

There is one tool I would not recommend: Ophcrack. It is supposed to "hack" (actually an unoptimized bruteforcer). I couldn't find a way to just "change" the pass. It didn't have chntpw bundled.

Here's a link: http://pogostick.net/~pnh/ntpasswd/ (it is very small, AFAIR only 3-10mb).

Make a bootable USB from ISO on OS X Mountain Lion 10.8 without any extra apps

Plugin the USB, then:

Screen Shot 2013-02-17 at 3.28.33 PM

 

 

Then

mf$ hdiutil convert -format UDRW -o BT5R2-GNOME-64.img BT5R2-GNOME-64.iso
mf$ diskutil list /dev/disk2 #(careful here)
mf$ dd if=./BT5R2-GNOME-64.img.dmg of=/dev/rdisk2 bs=1m

 

Note: that bs=1m (without it the speed is going to be less than 1mb/sec, with it it's 10mb/sec)

Note2: we're using rdisk2 instead of disk2, again this way it's faster.

Iodined - how to use free internet on airports

How to get internet connectivity on an open wi-fi access point that requires a credit card without actually paying:

Prerequisites

  • OpenWRT router
    • public ip, not necessarily static
  • account on dns.he.net
  • OS X laptop

Iodine on OpenWRT and installation on a OS X

On the OpenWRT:

  • opkg install iodined
  • update /etc/init.d/iodined to:

[dropdown_box expand_text="code" show_more="Show" show_less="Hide" start="hide"]

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=50

start_instance () {
local section="$1"
config_get address  "$section" 'address'
config_get password "$section" 'password'
config_get tunnelip "$section" 'tunnelip'
config_get tld      "$section" 'tld'

service_start /usr/sbin/iodined -l "$address" -c -s -P "$password" $tunnelip "$tld" &
sleep 1
ifconfig dns0 $tunnelip netmask 255.255.255.0
}

start() {
config_load 'iodined'
config_foreach start_instance 'iodined'
}

stop() {
service_stop /usr/sbin/iodined
}

[/dropdown_box]

  • so that it starts automatically
/etc/init.d/iodined enable
  • edit /etc/config/iodined (because there' s a bug on openwrt)
    • change address to 192.168.14.1
config iodined
 option address ''
 option password ''
 option tunnelip '192.168.14.1'
 option tld ''
  • Make sure the openwrt router has a static ip address (he.net provides dyndns updates)
  • Make a dns zone: a.server.com ns -> openwrt.server.com
    • openwrt.server.com has a dyndns update
  • port forward 53 (tcp and udp) from first router to second router (or just open 53 on the openwrt)

osx client

  • http://tuntaposx.sourceforge.net/ (tuntap)
  • script:

[dropdown_box expand_text="code" show_more="Show" show_less="Hide" start="hide"]

#!/bin/bash

# are we root?
if ! [ $UID == 0 ] ; then
  echo "IODINE SETUP: use 'sudo $0'";
  exit 0;
fi;

#$1 says whether we use clearcode or stoynov.com
if [ -z $1 ] ; then
  echo 'IODINE SETUP: first param must be 1(i.clearcode.org) or 2(i.stoynov.com)';
  exit 0;
fi;

if [ $1 == 1 ] ; then
  endpoint_domain='i.clearcode.org'
  endpoint_net='192.168.14.0/24'
  endpoint_gw='192.168.14.1'
fi;

if [ $1 == 2 ] ; then
  endpoint_domain='j.stoynov.com'
  endpoint_net='192.168.15.0/24'
  endpoint_gw='192.168.15.1'
fi;

# get the first dns from resolv.conf and use it.
abused_nameserver=`cat /etc/resolv.conf | grep nameserver | head -1 | awk '{print $2}'`
abused_nameserver=8.8.4.4
echo ">>>>>>>>>>>>>>>>>>>USING DNS: $abused_nameserver"

# kill iodine if any and remove old routes
killall iodine
route delete 8.8.8.8 > /dev/null
route delete 8.8.4.4 > /dev/null

# get the default gateway for iodine
default_gateway=`netstat -rn | grep default | awk '{print $2}'`

#when I die, restore the default gateway, use trap to get Ctrl+C
function disconnect() {
  # kill the process with id coming as a parameter
  kill -9 $1;
  route add default $default_gateway;
}
#disconnect and exit
function cleanup() {
  disconnect $(pgrep iodine);
  exit 0;
}
trap "cleanup" SIGINT

#dns query types
dns_query_types="TXT CNAME NULL"

function connect() {
  # start iodine (possible dns types are CNAME, TXT, NULL), -F puts a pid file with the processId inside
  iodine_output=$(./iodine -T CNAME -r -P "peshev sucks" -F /var/run/iodine.pid $abused_nameserver $endpoint_domain 2>&1 | tee /dev/tty)

  #remote_net from iodine_output
  remote_net=$(echo $iodine_output | grep -o "Adding route [0-9\.]*/[0-9]\{1,2\} to [0-9\.]*" | awk '{print $3}')  

  #remote_net is something like 192.168.15.2/27 and should be 192.168.15.0/27
  remote_net=$(./ipcalc -nb $remote_net | grep Network | awk '{ print $2}')

  #tunX_ip (tunX_ip) from iodine_output
  tunX_ip=$(echo $iodine_output | grep -o "Adding route [0-9\.]*/[0-9]\{1,2\} to [0-9\.]*" | awk '{print $5}')

  #remote_gateway (gateway on iodine) from iodine_output
  remote_gateway=$(echo $iodine_output | grep -o "Server tunnel IP is [0-9\.]*" | awk '{print $5}')

  # route to nameserver to be abused
  route add -host $abused_nameserver $default_gateway
  # route to remote network via tunX_ip (necessary because my mac sucks)
  route add -net $remote_net $tunX_ip
  # change default gateway from system default to iodine 
  route delete default
  route add default $remote_gateway

  # time to download 100kb file in seconds (1.34). We remove the dot for easy comparison (1.34 -> 134)
  echo TESTING SPEED;
  t=$( { time -p curl -s ftp://speedtest:speedtest@ftp.otenet.gr/test100k.db; } 2>&1 )
  seconds=$(echo $t | awk '{ print $2;}' | tr -d . );
  echo SECONDS: $seconds;
}  
connect;

echo 'READY...READY...READY...READY...READY...'

while true; do sleep 10000; done;

[/dropdown_box]

  •  add ipcalc because the script needs it: ipcalc

Conclusion

Some testing found out speeds like 7-15 kb/s, sometimes less on 8.8.8.8 and 8.8.4.4. With local DNS servers the speeds are like 100kb/s. More testing is necessary.

Force Integrated graphics on VMware Fusion (and probably other apps) on OS X 10.8 Mountain lion (avoid discrete graphics)

With OS X 10.8 gfxCardStatus is no longer capable of enforcing Integrated Graphics card only.

When one uses VMWare Fusion, the discrete graphics card is enforced, which drains the battery too fast.

I have not found any solution online to fix this. But I managed (thanks to PePe) to discover one.

How to use Integrated Graphics Card with VMware Fusion on OS X 10.8:

  • Install gfxCardStatus
  • Before launching VMware Fusion, click on Integrated only (click it several times until it has the checkbox on the Integrated only):

Screen Shot 2013-02-15 at 2.05.32 PM

  • Then launch VMWare Fusion, start whatever virtual machine. And don't do anything inside. Leave it idle.
  • There's a BackTrack 5 R3 with the integrated graphics card:

Screen Shot 2013-02-15 at 2.08.15 PM

  • There's a BackTrack 5 R3 VM and a Windows XP (both idle) with the integrated graphics card:

Screen Shot 2013-02-15 at 2.12.34 PM

  • I'm using iStatMenus to check my power consumption. Here's my power consumption with the two VMs:

Screen Shot 2013-02-15 at 2.07.10 PM

  • Cody Krieger (the creator of gfxGraphicsStatus) says that even if it says that the Integrated is being used, the Discrete (NVidia) is still being powered on, which invalidates the whole exercise.
  • How do I know that I'm saving power? Well, let's go to Discrete and check the power consumption:

Screen Shot 2013-02-15 at 2.16.56 PM -> discrete

  • Now, let's check what the consumption is (the same two idle VMs):

 Screen Shot 2013-02-15 at 2.20.26 PM

 

  • So instead of having 3:27 hours left, I now have 1:22 hours left. My consumption 2.5 Amp, instead of 1.1 Amp.
  • I can't directly go back though:

Screen Shot 2013-02-15 at 2.27.07 PM

  • What I have to do is to stop VMware completely (Cmd + Q), go to Integrated only again and restart all the VMs
  • This is something that I discovered today. So it may not be working as expected, but for now it seems it is.
  • My setup:
    • OS X 10.8.2 on a Macbook Pro 8.2 (A1286, Quad Core i7 2.3 Ghz, 16gb RAM, 256gb OCZ Vertex 3, AMD Radeon HD 6750M 1GB)
    •  VMware Fusion 5.0.1 with 2 VMs - Windows XP Pro and Backtrack 5 R3 (both were idle during this setup).

 

Compromise? Hell NO

Та значи в човешките отношения винаги има търкания. И когато се стигне до такива, ти се казва: ами причината е еди коя си привичка в характера на човека отсреща. Ти си по-зрял, видял си го по-ясно, направи компромис, устискай докато другия узрее. Ето оттук се коренят 3/4 от проблемите в общуването. Добре де - в моето общуване.
Според мен от това "устискай", "направи компромис" следват голяма част от недоразуменията.
Защо? Защото първо, това привлича хора, които не са достатъчно "узрели" и усещат/знаят, че ще получат известна доза търпение. Второ, създава дисбаланс в отношенията, които "неузрелите нежелаят" да компенсират на по-късен етап. Този дисбаланс некомпенсиран оставя доста горчив вкус в устата. Те са свикнали отсрещната страна да е търпелива.
Оказва се, че търпението в тоя случай е най-лошият подход. А търпението е като универсално качество, винаги положително качество. Ами да, ама не. В този случай само се отлага неизбежното.
Освен това, защо просто не общуваме с хора, към които е нужно да се правят по-малко компромиси?!

Куфарът

Пътувам доста от 20тата си годишнина - по работа. С прекъсвания разбира се. Даже за кратко съм поживявал в чужбината. Доста съм понаучил относно това как се пътува най-ефективно. Все още не съм спец и постоянно обърквам нещо дребно, забравям разни неща или просто не преценявам.

Първият ми куфар беше един евтин платнен такъв. Биде съдран и съсипан само за няколко пътувания. Виждал съм как ги разсипват по пистата на софийското летище и просто продължават без да спират. След това реших да си купя пластмасов такъв. Но нямах пари за самсонайт, затова отидох в Метро. Там за 100тина кинта (още помня цената) си купих сегашния куфар. Огромен, сив, с код за отваряне на основната ключалка и ключе за двете странични. Изгубил съм едното ключе. Кодът не е сменян откак го имам.

Куфарът е 4 колела отдолу, задни големи и две предни завиващи. Има въже за дърпане и дръжка, за да се движи само на две колела. Въженцето за дърпане е жестоко, защото така тежестта на куфара не се отразява на пътника, тоест на мен.

В най-тежките случаи куфарът пълен е тежал над 30 кила - първото ми пътуване до щатите. Горкият. Как съм го претъпквал навръщане от Германия. Даже веднъж едно бъги с дистанционно помня съм връщал. От целият този тормоз предните две колела са счупени. Опитах да го поправя, но се оказа, че няма къде. Никой не може да поправи тези 2 колела.

Преди няколко седмици влязох в един магазин на Самсонайт. Разни сплави. Дават ти да скачаш върху куфара и после материята сама се изправя. Магия. Ама вътре лаптопът няма да се изправи. Та не си купих нов куфар със здрави колелца.

Понякога мъкненето с дръжката на две колелца ми тежи, но въженцето вече не е опция, заради разбитите предни колела. Понякога горната страна не се задържа като го отворя и се катурва назад. Всичко останало обаче работи. След почти 10 години.

Само тая година куфарът е бил на 3 континента, поне 10 държави.

Особено като пътувах до Германия, толкова бях свикнал да живея в тоя куфар. Дори не го разопаковах. Беше 2 седмици там, 2 седмици в България. Нямаше смисъл за 2 седмици да разопаковам.

Свикнах да живея с толкова малко вещи, че като тръгна на път да мога всичките да ги натъпча в тоя куфар и една раница с лаптоп. Ама всичките вещи. Откак свикнах така, се старая да не си купувам твърде много излишни вещи. И всяка вещ, която имам да се употребява. Струва ми се тъпо да имам вещи, които не ползвам. На това ме научи тоя куфар. НЕ искам да го сменям с друг. Само да успея да му оправя колелцата. Някой с идеи?

Тук съм малко въздебеличък, но това е единствената снимка, която имам на тоя куфар.

 

Can I watch 1080p torrents while downloading on OS X? -- YES

Updated tutorial with better torrent client here.

Most large torrent files (8-20 gb) take quite a while to download. Is there software for Mac OS X that allows me to watch them while downloading?

The solution

I tried all (I mean all) torrent clients for OS X that I could find.

There were people before me who wanted the same feature and have asked the most popular clients (uTorrent and Transmission) whether they would support serial downloading. Developers replied that that would defeat the purpose of torrent protocol (it would seem that uTorrent changed their minds and have such a feature for windows).

Finally I found one that could download file parts in order. It's called BitThief. It's a research project and has an awful interface. But it works, and most importantly downloads serially.

->
-> -> ->

After the file is put for downloading, the speed must be good enough for watching. For example, if the movie is 1:30h long, I check the ETA time to be less than that.

To watch the movie I use MplayerX (an OS X GUI for mplayer). It can be downloaded for free from OS X App Store. Mplayer is light, can play EVERYTHING, and navigation is done with the arrow keys. Mplayer automatically regenerates the index (the thing that allows using the progress bar). The OS X gui is awesome and supports the Lion's full-screen view.



There's always a chance that things could go wrong - low speed or high speed in the beginning and then low speed (which is even worse).

Keep in mind that in order to watch a 1:30h long movie that is 20gbytes, you have to download with ~3.7mbytes/sec.

Update: tested with 700mb AVIs, 2gb, 6gb, 8gb, 20gb MKVs (was lazy to check the codec, h264 mostly I guess).

Update 2012.07.02: This solution has been serving me quite good. Still here are the issues: BitThief is not very optimized and while other torrent clients can utilize my whole bandwidth, BitThief fails from time to time, probably because it is downloading sequentially. Also magnet links are not supported and the interface sucks so much.

Update 2012.08.16: A fix for utilizing magnet links: magnet->torrent converter. Utilizing magnet links allows this process to work for thepiratebay.org and other sites utilizing the new magnet url technology.

Update 2013.02.04: The newest version of BitThief now supports Magnet URIs. They're saying that a new look and feel is also coming.

Cool new features in OS X Lion. The trackpad.

The coolest thing here is the dictionary - double-tap with three fingers. Adding extra dictionaries is not very straight-forward, but go to this guy: http://mac.tashev.info/:

You can link the dictionary with wikipedia (even the bg version of it). It is amazing.

Another very cool thing is the three finger drag.

Screen 2 - smart zoom, but it doesn't work everywhere.

When OS X Lion came out, the three-finger horizontal drag (swipe) was for switching between screens. In the previous versions it was four-finger. In the latest update they went back to four-fingers, since the three-finger swipe is for dragging windows.

I wouldn't trade a macbook just for the trackpad. I stopped using a mouse since my first one. I am so used to it that when I get back to a normal trackpad it looks like I'm back in the stone age.

Notes on keeping the SSD clean (more free disk space)

I have one of the fastest SSD drives, but unfortunately didn't have the heart to buy the 240Gb, but the 120GB version. Now, 120GB is definitely enough, but this is my primary machine, and I'm doing several different kinds of things on it, so I need space for all the projects.

How do I keep it clean:

CleanMyMac

First I run automatic tools like CleanMyMac (free):

It definitely will find stuff that you missed.

Disk Inventory X

This is another type of program - it says how much disk is used by any folder, so it's easy to find the bigger users of space:

With it I found the /private/var/vm/sleepimage file (8gb) - keeps the data when the laptop goes to sleep. I can safely use the 8gb space until my laptop goes to sleep.

It is free.

OmniDiskSweeper

Same as the former, but all is textual.

Windows XP

I have a Windows XP vm. Keeping it clean is not easy. I use Free Disk Analyzer. It works similarly to OmniDiskSweeper and Disk Inventory X:

System Volume Information

Last time I saved 2.79 GB from this folder. My Computer -> Preferences -> System Restore (there's a slider in XP).

Compacting VirtualBox (.vdi) VMs

VirtualBox is great, because it it's free, but it has many quirks - not that good integration on copy/paste, files, shortcuts and so on. The biggest issue is that compacting the image is weirdly done

  • Defragment the VMs drive (this step is always important regardless of the virtualization software)
  • Zero out the free space. Now this is unnecessary with VMWare and Parallels. It is done with sdelete - a free windows software by SysInternals (you remember these guys? Mark Russinovich?).
    • command is "sdelete -c -z c:\"
  • Compacting the virtual disk (.vdi) is done with this command (the command comes with VirtualBox) (case-sensitive):
    • "VBoxManage modifyhd /fullpath/to/windowsdisk.vdi --compact"

Other concerns

  • I always delete the Windows update files - today I saved 500mb.
  • No swap file for windows - too slow. Few gigs.
  • Now I have no swap for OS X too (500mb).
  • 7GB from compacting the VM
  • Moved some stuff to the Time Machine (20GB)
  • Deleted a lot of temp files and swap files (20 GB)
So now I have a lot more free space. I have spent only an hour for it. Next time it will just take a few minutes.
Wow, the 240GB Vertex 3 now costs as much as I paid for the 120GB less than a year ago. Crap.