Wednesday, September 23, 2015

cloud-init slowness

Noticed my ubuntu box have very slow startup time, and it is cloud-init.

edit /etc/cloud/cloud.cfg.d/90_dpkg.cfg, and change [...] to [ None ], fixed for me :)

Friday, April 3, 2015

icse014a usb problems

Recently I started getting interested in automation.  So for a small project I want to try out, bought icse014a 8 relay control via USB.  It arrived today and can't get it to work, device shows status 10 (with a yellow question mark).

After some search found this page: http://leftbraintinkering.blogspot.com/2013/05/usb-to-serial-prolific-2303-device.html  .  The guy was doing the same with some other device and  found windows 8 no longer support the driver.  So some smart guy wrote something to fix it https://www.sendspace.com/file/5m5afw

Now it is working and I can control the device, thanks guys!

Saturday, July 26, 2014

ffmpeg shrink file

I got some mts files that has not been uploaded for a long time, and got some time today to do that.  Windows Movie Maker is nice but one by one upload is just too slow.

Did some research, so finally find a way to do it in batch:

1.  loop all files do:  ffmpeg -i input.mts -fv scale=720:-1 output.mp4

2. drop all the mp4 to youtube :)

Thursday, June 5, 2014

CallContext ThreadStatic and SQL transactions

Recently we changed all our DB calls to async/await, as they are much more "thread" efficient.

And most of our old code, the SQL transactions runs on Thread local.  This won't work on async/awaits since now they are all interrupt like and can run on any thread. (we are not running with coordinated transactions for other reasons)

One of our guys implemented the new way initially with a static context, and we have to pass the context name to all calls.  When it is time for me to fix some of the code, it just feels so unnatural, no only there are a lot of code changes, if you miss one they won't be in the transaction.

And during the research, someone found CallContext, it works very much like Thread Statistic, and I think Microsoft copies it to new threads, so with simple fixes everything is working again (of course anything in a transaction is synchronized again without the DTC, that we can live with for now).

Sunday, February 23, 2014

c# async model

I dislike the async/await way of doing things, thinking that it made the developer's life harder, hiding the threading for no reason (not to mention the messed up stock). Recently one of our companies project was done with that, and I was able to make the project faster by remove some of the async stuff (there is an operation that writes on a single pipe, so I made it single threaded and used a queue instead of the async way of doing things). However during a recent discussion, one of my college's comment kind of wake me up a bit. He said the reason async/await is better is that internally it actually queue things up. Now that made sense. I think MS should make it even better, that is on any IO operation on a task, it should immediately queue it and make the thread available for next queued task, this way we can actually do away with the async/await mess and the complexity will be handled internally without any developer mangling.

Monday, September 23, 2013

Les Misérables

Finished watching Les Misérables tonight, such a pity I got so busy have to finish a movie over a week in small pieces. Read the story as a cartoon long time ago, and the movie certainly bring back most of the memories, I have to say for a opera it is well done. I don't like some of the singing, but I love the ending song and it brought down some tears.

Monday, July 1, 2013

Age of sorcery build path

I recently started to play a game on windows phone, Age of Sorcery. Found out no one has posted its building upgrade path yet, so here it is, hopefully it can be helpful to other new players when they google: Academy => Shrine of fire 1 Academy 2 => shrine of wind 2 Academy 3 => shrine of earth 3 Academy 4 => shrine of fire 4 Academy 5 => City walls 5 Academy 6 => Shrine of Fire 5 Academy 7 => shrine of fire 6 Academy 8 => Castle 7 Academy 9 => Shrine of wind 8 Academy 10 => shrine of earth 10 House 2 => farm 1 House l3=> farm l2 House l4=> mithril 3 House l5 => farm l4 House l6 => Shrine of earth 1 House 7 => Academy 1 House l8 => warehouse l6 House 9 => City walls 7 House l10 => Warehouse l10 Warehouse 2 => Castle 1 Warehouse l3=> mithril l2 Warehouse l4=> House 3 Warehouse 5 => Shrine of Wind 2 Warehouse l6 => castle l5 Warehouse 7 => Castle 5 Warehouse 8 => house 7 Warehouse 9 => Castle 8 Warehouse 10 => City walls 9 Farm 2 => Castle 2 Farm 3 => Warehouse 2 Farm 4 => Castle 2 Farm 5 => Warehouse 4 Farm 6 => Shrine of Fire 1 Farm 7 => Academy 4 Farm 8 => City Walls 6 Farm 9 => City walls 8 Farm 10 => Warehouse 9 City walls 2 => Castle 1 City walls 3 => mithril 1 City walls 4 => farm 4 City walls 5 => House 6 City walls 6 => Warehouse 7 City walls 7 => Farm 7 City walls 8 => Mithril 7 City walls 9 => castle. 8 City walls 10 => castle 10 Castle 2 => House 1 Castle 3 => Warehouse 2 Castle 4 => City walls 3 Castle 5 => House 4 Castle 6 => Academy 5 Castle l7 => city walls l7 Castle 8 => Academy 7 Castle 9 => forge 5 Castle l10 => academy l9 Mithtil 2 => Warehouse 1 Mithril 3 => Warehouse 3 Mithtil 4 => Warehouse 3 Mithtil 5 => Academy 2 Mithril 6 => Academy 2 Mithril 7 => Castle 6 Mithtil 8 => city walls 7 Mithril 9 => Shrine of Fire 7 Mithtil 10 => shrine of fire 10 Shrine of wind => Castle 2 Shrine of Wind 2 => farm 3 Shrine of Wind 3 => mithril 3 Shrine of Wind 4 => mithril 6 Shrine of Wind 5 => farm 6 Shrine of Wind 6 => Castle 6 Shrine of Wind 7 => city walls 7 Shrine of Wind 8 => Farm 8 Shrine of wind 9 => Academy 9 Shrine of Wind 10 => Castle 10 Shrine of earth => Castle 3 Shrine of earth 2 => castle 3 Shrine of earth 3 => mithril 4 Shrine of earth 4 => Warehouse 5 Shrine of earth 5 => Castle 5 Shrine of earth 6 => forge 4 Shrine of earth 7=> forge 6 Shrine of earth 8 => Academy 7 Shrine of earth 9 => Academy 8 Shrine of earth 10 => Castle 10 Shrine of Fire => Castle 4 Shrine of Fire 2=> city walls 4 Shrine of Fire 3 => mithril 5 Shrine of Fire 4 => House 6 Shrine of Fire 5 => Castle 6 Shrine of Fire 6 => forge 4 Shrine of Fire 7 => Academy 6 Shrine of Fire 8 => Academy 6 Shrine of Fire 9 => Academy 8 Shrine of Fire 10=> Castle 10 Forge => Castle 7 Forge 2 => Shrine of wind 4 Forge 3 => Shrine of earth 5 Forge 4 => shrine of fire 5 Forge 5 => city walls 6 Forge 6 => shrine of earth 6 Forge 7 => shrine of wind 7 Forge 8 => Shrine of Fire 8 Forge 9 => city walls 9 Forge 10 => castle 10