The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

ssl/ssh multiplexer

Posted by jpluimers on 2017/08/07

sslh accepts connections on specified ports, and forwards them further based on tests performed on the first data packet sent by the remote client.

Probes for HTTP, SSL, SSH, OpenVPN, tinc, XMPP are implemented, and any other protocol that can be tested using a regular expression, can be recognised. A typical use case is to allow serving several services on port 443 (e.g. to connect to ssh from inside a corporate firewall, which almost never block port 443) while still serving HTTPS on that port.

Hence sslh acts as a protocol demultiplexer, or a switchboard. Its name comes from its original function to serve SSH and HTTPS on the same port.

sslh supports IPv6, privilege dropping, transparent proxying, and more.

Interesting…

–jeroen

Posted in *nix, https, Linux, OpenSSL, OpenVPN, Power User, Security | Leave a Comment »

sleep wake – Macbook Air – battery drains while sleeping (but not when shut down) – via: Ask Different

Posted by jpluimers on 2017/08/07

I had the same issue as in sleep wake – Macbook Air – battery drains while sleeping (but not when shut down) – Ask Different which suddenly introduced itself in April 2016 after I had been running El Capitan (OS X 10.11) for a while.

The Mac didn’t have PowerNap active as I verified using How Power Nap works on your Mac – Apple Support

At first it looked like an SMC reset worked as explained by Reset the System Management Controller (SMC) on your Mac – Apple Support and mentioned in Mac Air loses 90% of battery overnight when in … | Apple Support Communities.

The Mac is indeed running Chrome, but I don’t like to turn that off before sleeping.

Executing pmset -g would show hibernatemode 3.

So I opted for the hibernate option as mentioned in the first link:

sudo pmset -a hibernatemode 25

This will take a bit longer to restore the memory from hibernate state, but saves a lot of frustration.

–jeroen

Posted in Apple, Mac, MacBook, MacBook-Air, Power User | Leave a Comment »

Vier 3d-printers van ongeveer 300 euro – Conclusie – Round-up – Tweakers

Posted by jpluimers on 2017/08/05

Eerder dit jaar testen we 3d-printers die voor minder dan 1000 euro te koop zijn. Het kan echter nog goedkoper. Dit keer testen we vier 3d-printers die ongeveer 300 euro kosten.

Source:[WayBack]  Vier 3d-printers van ongeveer 300 euro – Conclusie – Round-up – Tweakers

Posted in 3D printing, Development, Hardware Development, Power User | Leave a Comment »

Remember when G+ search was useful? It again is.

Posted by jpluimers on 2017/08/04

The big G+ news this week was that they brought back search, years after they made the G+ search useless, so jokes like at [WayBackIkey Doherty – Google+ “Remember when G+ search was useful?” finally can be left behind us.

Now that they finally made it useful again, I’m happy with it.

A few example searches to get the hang of the URL syntax:

News sources:

  • [WayBackKristian Köhntopp – Google+: I would not have thought it possible, but after just several years of user feedback Google actually unfucked the search. It’s almost as awesome as their adblocker – absolutely essential, but too little, too late.
  • [WayBackJaana Nyström – Google+: WOOHOOOOOO! The Classic Google+ style search is back! Now one can again search their own posts, even hashtag search works better. Top post vs. latest function, too. ❤️
  • [WayBackRoderick Gadellaa – Google+: #thatsaplus
  • [WayBack] Anna Kiyantseva – Google+: …we’re rolling out a bevy of improvements to G+ Search — most visibly, you’ll find that typing into the search bar no longer interrupts your search attempts by taking you to Explore. That means that your results get to you that much faster!That’s not all…
    • A new, tabbed interface will make it easier for you to find the exact type of content that you’re looking for.
    • In the posts tab, you can filter based on the post author. Finally, you can look back at your many years of G+ posting without being distracted by everyone else’s Neko Atsume updates!
    • Popular Topics are now displayed in the search bar dropdown.As always, let us know what you think and we hope you enjoy!

–jeroen

Read the rest of this entry »

Posted in G+: GooglePlus, Google, Power User, SocialMedia | Leave a Comment »

T568A and T568B termination – TIA/EIA-568 – Wikipedia

Posted by jpluimers on 2017/08/04

Note to self: looking at the various patch cables, it looks like most manufacturers prefer T568B over T568A. Not sure why. I adopted T568B to avoid any confusion.

As I always forget the images on FTP/STP/UTP wiring in both connectors and outlets and forget which standard is T568A and T568B: T568A and T568B termination – TIA/EIA-568 – Wikipedia:

Pin T568A Pair T568B Pair 10BASE-T 100BASE-TX 1000BASE-T Signal ID Wire T568A Color T568B Color Pins on plug face (socket is reversed)
1 3 2 TX+ DA+ tip Pair 3 Tip
white/green stripe
Pair 2 Tip
white/orange stripe
Rj45plug-8p8c.png
2 3 2 TX- DA- ring Pair 3 Ring
green solid
Pair 2 Ring
orange solid
3 2 3 RX+ DB+ tip Pair 2 Tip
white/orange stripe
Pair 3 Tip
white/green stripe
4 1 1 DC+ ring Pair 1 Ring
blue solid
Pair 1 Ring
blue solid
5 1 1 DC- tip Pair 1 Tip
white/blue stripe
Pair 1 Tip
white/blue stripe
6 2 3 RX- DB- ring Pair 2 Ring
orange solid
Pair 3 Ring
green solid
7 4 4 DD+ tip Pair 4 Tip
white/brown stripe
Pair 4 Tip
white/brown stripe
8 4 4 DD- ring Pair 4 Ring
brown solid
Pair 4 Ring
brown solid

Note that the only difference between T568A and T568B is that pairs 2 and 3 (orange and green) are swapped.

For cross-over cables (used less and less because of Auto MDI-X which is standard in 10000BASE-T) this is slightly different Appendix B: Ethernet Crossover Cables – Configuring and Troubleshooting Ethernet 10/100/1000Mb Half/Full Duplex Auto-Negotiation – Cisco [WayBack]:

Four Twisted-Pair Crossover Cable Schematics for 10/100/1000 and 1000BASE-T GBIC Module Ports

3a.gif

3c.gif

There are some nice colour coded wiring diagrams at Tech Stuff – LAN Wiring and Pinouts [WayBack] for both straight wiring [WayBack] and crossed wiring [WayBack]:

All work fine for CAT5, CAT5E and CAT6.

–jeroen

Posted in Ethernet, Network-and-equipment, Power User | Leave a Comment »

Fix Apple TV No Sound Issue – AppleTV2

Posted by jpluimers on 2017/08/04

The first method I try for any Apple TV issue is to reset the device (Hold the Play & Menu button simultaneously on the remote for 6 seconds)

Source: [Wayback] Fix Apple TV No Sound Issue – AppleTV2

This usually works for me too and is easier/faster than fiddling with the solutions mentioned at Wayback: Apple TV: HDMI audio stops working – Apple Support (which now has moved to [WaybackGet help with audio, video, or power on Apple TV – Apple Support).

After releasing Play&Menu buttons, wait for the Apple TV to reboot itself and listen if your remote-buttons will give you audio-feedback from the Apple TV. If that works, then audio on multi-media works fine too.

This is way cheaper than putting additional hardware in the HDMI chain as described in [WaybackThe fix for AppleTV HDMI audio and video woes and HDMI problem solving | The Poor Audiophile

In my setup the [WaybackApple TV 3rd generation is hooked up to a [WaybackHarman Kardon BDS 580 receiver/blue-ray-player.

–jeroen

Posted in Apple, Apple TV, Audio, BDS580, Hardware, Harman Kardon, Home Audio/Video, iOS, Media, Power User | Leave a Comment »

Some more Continua CI links

Posted by jpluimers on 2017/08/03

For my link archive:

–jeroen

Posted in Uncategorized | Leave a Comment »

On List growth strategies and memory managers

Posted by jpluimers on 2017/08/03

Interesting for anybody working on list growth strategies.

In this case with some Delphi background information and in depth coverage of FastMM memory (re)allocation strategies.

[WayBack] Stefan Glienke (of [WayBack] Spring4D fame) needed some help with allocation strategies and observed the difference between:

  • TList.Grow (and TStringList.Grow) growing like this: 4, 8, 12, 28, 44, 60, 76, 95, 118, 147, 183, 228, 285, 356, 445, 556, 695, 868, 1085
  • Generic TList<T> growing  the same way as the .NET List<T>: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024

There is this nice [WayBackDynamic array – Growth factor – Wikipedia, the free encyclopedia mentioning this table:

Implementation Growth factor (a)
Java ArrayList[1] 1.5 (3/2)
Python PyListObject[7] 1.125 (9/8)
Microsoft Visual C++ 2013[8] 1.5 (3/2)
G++ 5.2.0[5] 2
Clang 3.6[5] 2
Facebook folly/FBVector[9] 1.5 (3/2)

[WayBack] Javier Hernández mentioned he doesn’t think exponential is better than n^2.

[WayBack] Eric Grange (of [WayBackDWS and [WayBackbeginend.net fame) mentions he tends to use 1.5, it is about as good as 2 for small lists, but reduces waste for large ones. He also uses a constant delta to accelerate growth early on, so something like:

n := n + (n div 2) + 8

Since allocation strategies highly depend on the memory allocator as well, I was glad [WayBackPrimož Gabrijelčič (of [WayBackOnmiThreadLibrary and [WayBackSmart Mobile Studio fame) elaborated on FastMM:

  • FastMM small block allocator sizes (size includes the leading header) are: 8, 16, 24, 32, … 160 (in +8 steps), 176, 192, … 320 (+16), 352, 384 … 480 (+32), 528, 576, … 672 (+48), 736, 800, 880, 960, 1056, 1152, 1264, 1376, 1504, 1648, 1808 , 1984, 2176, 2384. [FastMM4.pas, SmallBlockTypes global var]
  • While the size of reallocated region fits inside a small block (with a different size than a previous block), the data is moved around (new block is allocated from a new suballocator). If it is too big (>2384 bytes), it gets allocated from the medium block allocator (which handles all block sizes up to 264752 bytes; larger blocks come directly from VirtualAlloc).
  • When small blocks are reallocated (to a larger size), allocator always allocates at least 100% + 32 bytes larger block, even if less is requested by the RTL (example: 8 bytes will grow to 2*8 + 32 = 48 bytes). When medium blocks are reallocated, allocator always allocates at least 125% of the old size. This boosts the performance when blocks are enlarged by small values as they can be enlarged “in place” (no data moved around, just the header is adjusted).

Stefan Glienke and Primož Gabrijelčič then concluded that:

  • Resizing an array from say 4 elements (pointer size) to 1000 (in multiple steps) will for sure move several times when jumping from one region into the next larger one.
  • Changing to a growth factor of 1.5 vs 2 won’t change anything in terms of memory fragmentation in FastMM4.

Source: [WayBack] I was just looking at TList.Grow (and TStringList.Grow) and I realized that the…

Edit 20181127

Delphi 10.3 Rio makes this configurable in a global way for all threads at the same time (#facepalm! as it is the 1980s Turbo Pascal ExitProc mess all over again): [WayBack] Delphi RTL Improvements in 10.3 Rio via [WayBack] +Marco Cantù is unstoppable. I can’t keep up LOL  – Clement Doss – Google+

The SetGrowCollectionFunc is of course not documented in the RTL, only in the [WayBack] What’s New – RAD Studio 10.3 Rio: [WayBack] Search results for “SetGrowCollectionFunc” – RAD Studio 10.3 Rio.

Stefan Glienke commented in that G+ thread:

I recently experimented with different grow factors and while the memory fragmentation can only mitigated for medium and large blocks (where it actually matters imo) it might be beneficial to only grow by 1.5 at that point. But that has yet to be tested.
What I liked so far is the grow strategy that Go uses (2x until 1024, 1.25x after that) – see https://golang.org/src/runtime/slice.go#L115

Since you usually set the size upfront if you add many elements at once (well, if you know how many beforehand) the grow strategy only matters in the long run. You want to balance speed (too many realloc might slow things down unnecessarily), memory overhead (if you are overallocating much you risk wasting too much memory) and memory fragmentation (which might happen with a grow factor bigger than the golden ratio)

–jeroen

Posted in .NET, Delphi, Development, Java, Java Platform, Software Development | 7 Comments »

Delphi call stack from exception…

Posted by jpluimers on 2017/08/02

Lars Fosdal:

MADExcept and Eurekalog are good products (and there is a JVCL tool as well). If you run your app in the IDE, you get the stack there – but for now, you need to acquire a third party package to get it runtime.I don’t disagree with the wish for a basic call stack tool, that works cross platform, but it would affect third party developers.

Stefan Glienke:

Whats the problem? You attach handlers to Exception.GetExceptionStackInfoProc, GetStackInfoStringProc and ` and just call a function that grabs the map or td32 info and generates the callstack – if you don’t want to spend any money for a high quality tool like madExcept (can even use it for free for non commercial use!) then use JclDebug.pas

I edited in some URLs above; the actual info is from: Why Delphi (like other developer environments) natively not included full call stack for every exception… [WayBack] (which is because it would kill even more of the Delphi 3rd party market).

And it taught me about this by madshi (of MADExcept fame):

DebugEngine is a collection of utils related to debug stuff (stack trace, CPU registers snaphot, debug info,…). Basically, I started to write a commercial error log plugin for Delphi, then I noticed that my internal framework got bigger and bigger. So I decided to share it with the community in hope it will be useful.

Source: MahdiSafsafi/DebugEngine: Delphi debug framework

And there is the JCL ExceptDlg.pas which is quite easy to use: just add it anywhere to your project and the global exception handler will show you a stack trace provided you have a .MAP file or .TDS file (which contains TD32 symbol information) in the same directory as your .EXE.

–jeroen

Example code:

https://gist.github.com/jpluimers/3cf26a5bcfc04b6ac28125ce20d6fd5b

Posted in Debugging, Delphi, Development, MAP Symbol Information, Software Development, TD32/TDS Symbol information | 6 Comments »

Visual Representation of SQL Joins – CodeProject

Posted by jpluimers on 2017/08/02

I thought I posted a reference to this a long time ago, but didn’t.

It’s one of the things I show when explaining joins to people. Sometimes I need it myself too (:

The article explains these in greater detail:

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • OUTER JOIN
  • LEFT JOIN EXCLUDING INNER JOIN
  • RIGHT JOIN EXCLUDING INNER JOIN
  • OUTER JOIN EXCLUDING INNER JOIN

Note:

  • the opposite of INNER JOIN is not OUTER JOIN. It’s OUTERJOIN EXCLUDING INNER JOIN
  • the opposite of OUTER JOIN is empty set.

But the diagram is usually speaks for itself.

–jeroen

Source: Visual Representation of SQL Joins – CodeProject

Read the rest of this entry »

Posted in Access, Database Development, DB2, Development, Firebird, InterBase, MySQL, OracleDB, PostgreSQL, SQL, SQL Server | Leave a Comment »