You are here: All articles » Programming
-
Fixing no thumbnail generation in Shopware 6
written: 4 years ago category: Programming
While struggling with importing images into a Shopware database, I found the column media.media_type has to have a certain value, depending on the file extension. Without a value in it,
bin/console media:generate-thumbnails
won't generate a thumbnail for this image. -
Moving a WD MyCloud harddisk into a pc
written: 5 years ago category: Programming
I just successfully moved the WD Red harddisk out of its chassis, into my Intel/Windows 10 tower. Altough that's not what WD recommends, and I'm sure I lost any warranty with it, it's good to know there is a way to do that. E.g. in case the network controller or the power connector is broken, or whatever.
So, here's how to do that
-
My new favorite undelete tool
written: 7 years ago category: Programming
Just found on heise.de when searching for a tool to recover deleted files from the SD card of my 14 years old daughter. She managed to delete exactly those photos which she intended to keep. Well, I had no copies of these anywhere, as they were only some days old yet. But then came PhotoRec and saved my life: The GUI is a bit special for most users but very ok if you feel familiar with shell windows. Quite conveniant. And most important - it recovered more files than Recuva.
-
Code signing for Open Source executable
written: 9 years ago category: Programming
I just hassled various hours with code signing, certificates, and terms I am not handling every day with. So, here's my working tutorial for signing an .exe file using signtool.exe from Microsoft...
-
Execute multiple queries in one mysql command line
written: 9 years ago category: Programming
On the command line, you may want to execute more than one SQL command at once. Most hints recommend a batch file to accomplish that, but that requires an additional file placed somewhere where you may forget it.
You can also fire several queries with the --execute parameter, separated by semicolon:
mysql -hlocalhost -uroot --execute"TRUNCATE dba.log_customer; TRUNCATE dba.log_quote; TRUNCATE dba.log_summary;"
...and the slightly shorter version:
mysql -hlocalhost -uroot -e"TRUNCATE dba.log_customer; TRUNCATE dba.log_quote; TRUNCATE dba.log_summary;"
-
Revealing "SKU does not exist in the Amazon.com catalog"
written: 9 years ago category: Programming
Got the following error with the SubmitFeed action in Amazon's Marketplace API:
This SKU does not exist in the Amazon.com catalog. Your inventory data was not processed. For reasons why, and help fixing this, see https://sellercentral.amazon.de/gp/errorcode/13013
The reason is self-explanatory, the product's sku is not listed in the catalog. I sent 1000 products to the API, of which only 100 were activated. So I expected 900 errors, but got only 200!
So, what's going on? Took me a while to find out:
The sku does not exist error only seems to occur on products for which you send a quantity value greater 0. Products with a quantity of 0 do not trigger the error.
Hope that helps someone saving some time on debugging.
-
SSH client on freeSSHd extremely slow
written: 10 years ago category: Programming
If you are using the freeSSHd server and you're experiencing extremely slow connection startups, downloads and uploads from any SFTP client, it is likely that you just need to turn off IP resolving in logfiles. You can disable that in the tab "Logging" > "Resolve IP addresses into hostnames".
Or, by editing the freesshdservice.ini file:
[Logging] LogResolveIP=0
-
Solving hard to find "XYZ is not a constructor" JavaScript errors in Magento
written: 10 years ago category: Programming
It took me quite a few hours to find the cause of various mysterious errors in Magento's compiled JavaScript files. On most pages these errors did not occur, only on a specific product review page. Magento was told to leave some .js files away on this url. So there was a difference between the compiled .js file on that review url and the other urls. The thing which drived me nuts was: how can I have an error in JavaScript code which just has less code than some other file which was even bigger, but had no error?
Take a look at the following two snippets. The first one does not throw an error:
Product.Config.prototype = { // some code } Calendar = function() { // some code }; (function(global){ // some code })(window);
Now, I'll remove the "Calendar" definition, and suddenly the code throws errors:
Product.Config.prototype = { // some code } (function(global){ // some code })(window);
The reason is a silly missing semicolon after the definition of "Product.Config.prototype". This is only a problem if the immediately following code starts with a parenthesis, like in the second snippet.
In Magento versions up to the newest v1.9 you will find such prototype definitions without a semicolon in the folder /js/varien/. Adding a semicolon at the end of these saved me from getting even more grey hair than I already have.
-
CSS Lint
written: 13 years ago category: Programming
Not just another CSS validator, but more: checks your CSS code for bad, unpreferred and browser-incompatible code: https://csslint.net/
-
Set meta description in extension
written: 14 years ago category: Programming
To set a page title from within any Typo3 extension, you just access the relevant page array item:
$GLOBALS['TSFE']->page['title'] = 'My title'
Now, if you expect this to work also for the meta description you will probably be disappointed. Try this instead, which worked for me on a 4.1 installation:
$GLOBALS['TSFE']->cObj->data['description'] = 'My description'
-
How fucked is your database?
written: 14 years ago category: Programming
-
Delphi shortcut
written: 15 years ago category: Programming
Just found by accident: When editing a .pas unit, Shift + Ctrl + [ArrowUp or ArrowDown] jumps from procedure declaration to implementation. Very nice if you have large units with several thousands of lines and numerous procedures and functions.
-
Delphi generics
written: 15 years ago category: Programming
Just found a wonderful and deep look into generics, anonymous routines and routine references here . Written by Sébastien Doeraene.
Generics were introduced in Delphi 2009, and I'm a big fan of them, as they help me do less type casting on TObjectList's items for example.
Want to know how sorting a TObjectList<TWhatever> works? Here's how it works:
type TDBObject = class Name: String; end; TDBObjectList = TObjectList<TDBObject>; TDBObjectComparer = class(TComparer<TDBObject>) function Compare(const Left, Right: TDBObject): Integer; override; end; procedure TMainform.btnOkClick(Sender: TObject); var o: TDBObject; begin Result := TDBObjectList.Create(TDBObjectComparer.Create); o := TDBObject.Create; o.Name := 'foo'; Result.Add(o); o := TDBObject.Create; o.Name := 'bar'; Result.Add(o); end; function TDBObjectComparer.Compare(const Left, Right: TDBObject): Integer; begin Result := CompareText(Left.Name, Right.Name); end;
ftp://ftp-developpez.com/sjrd/tutoriels/delphi-generics/delphi-generics.pdf
-
Typo3, exclude rootline menu on first level pages
written: 15 years ago category: Programming
On the root or first level page you probably want to hide a so called breadcrumb menu, as it would be a single word, identically with the page title, looking like a repetition of the page title. All "deeper" page levels should indeed include the complete path.
There is a HMENU.minItems property which looked pretty like what I needed. But that created a dummy item with three dots for missing level items, not what I wanted. So, the trick is to use a conditional block, where the first one is executed on page level 0 and 1, and the second one for all deeper levels:
[treeLevel = 0,1]
# No breadcrumb on root or first level pages
mainPage.10.marks {
BREADCRUMB = TEXT
BREADCRUMB.value =
}
[else]
mainPage.10.marks {
BREADCRUMB = HMENU
BREADCRUMB {
wrap = <p>|</p>
special = rootline
# No item at all for the root page, so we start at level 1
special.range = 1|-1
1 = TMENU
1.NO = 1
1.NO.allWrap = | »
1.CUR = 1
1.CUR.doNotLinkIt = 1
}
}
[end]http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/4/1/
-
Add anchor in getTypoLink
written: 15 years ago category: Programming
getTypoLink() doesn't allow you to pass an anchor parameter. So, in order to add an anchor to such a link you just have to add the anchor part to the id parameter:
$this->cObj->getTypoLink('Link Label', '123#myanchor');
$this->cObj->
pi_linkToPage('Link Label', '123#myanchor'
);$this->cObj->
getTypoLink_URL('123#myanchor');By the way, ever saw what the harmless function
class.tslib_content.php:typoLink()
does? Have a look just for fun, it's a 300 liner! Feels like Typo3 has a damned considerable amount of workarounds for various special cases and requirements.http://www.typo3-jack.net/typo3-dev-lists-netfielders-de/3076-typo3-dev-typolink-anchor.html
-
VirtualTree Bugtracker
written: 15 years ago category: Programming
Mike has just set up a bugtracker at Google Code for his popular VirtualTree component for Delphi. So, finally, all interested developers can actively participate in enhancing and extending this thing.
HeidiSQL makes extensive use of VirtualTree - as replacement for the normal TTree's and TListView's we had in old days. VirtualTree can display tree-like structures as well as lists, in all colors and flavours you can imagine:
Much more: it minimizes CPU and memory usage by strictly following the virtual paradigm (= just process visible nodes, nothing more, the rest is processed when the users scrolls to it). That means you can create millions of nodes in milliseconds. It has support for drag'n drop, custom cell editors (similar to plugins), images in column headers and cells, tons of useful events, and numerous other things you won't like to miss once you get used to them.
http://www.soft-gems.net/index.php?option=com_content&task=view&id=56&Itemid=1
-
Get number of enumerated, ordinal elements in a SET
written: 16 years ago category: Programming
Imagine some ordinal type and a set enumeration of it in Delphi:
Now, imagine you have several loops and points where any TLocation is added to or substracted from locs. At a later point in your application you need the number of elements in locs. Although that seems totally trivial that is not implemented in Delphi's compiler. The only SET related procedures in Delphi's compiler are Include, Exclude and In - there is no Count method for SETs. Well, you can help out and write your own one, as I discovered here:type TLocation = (locHere, locThere, locElsewhere); TLocations = Set of TLocation; ... var locs: TLocations; ... begin Include(locs, locHere); end;
function CountSetItems(SetValue: Integer): Byte; var Mask: Integer; begin Mask := $80000000; Result := 0; while Mask <> 0 do begin if SetValue and Mask <> 0 then inc(Result); Mask := Mask shr 1; end; end;
-
New HeidiSQL release: 4.0 RC3
written: 16 years ago category: Programming
Mainly a maintenance release but some nice enhancements in it:
- Legacy MDI (Multi Document Interface) has been removed completely
- Use Ctrl+Tab and Shift+Ctrl+Tab for switching main tabs
- Added quick connect sessions via drop down menu of connect button
- Session background color
- Date time editing fixed
- Various bugfixes
Download your copy.
Note that if you use the original 4.0 RC1 release your auto update mechanism won't update to this new release as in that older release it was broken (caused by the "M" in "r1901M").
In case you're wondering about the missing RC2 release: That version was created as Subversion tag but found as broken (XP theming was accidently disabled in a previous commit). So I decided to fix that first and - for consistency reasons - created a new version tag.
-
Bolan Website online
written: 16 years ago category: Programming
Finally done and uploaded to its correct place. A new website is born, selling home fashion and furniture by a flexible and experienced team of Bolan Home Fashion in Wettringen.
-
Basic Oracle support in jHeidi
written: 16 years ago category: Programming
-
HeidiSQL 4.0 RC1 released
written: 16 years ago category: Programming
Some of the new features:
- Completely rewritten user manager
- Full Unicode support for international characters in grids, SQL queries, CSV import etc.
- New grid component, including user friendly popup editors for blobs, date/time, set, enum columns. Grid cells have customizable colors, according to their data type.
- A new view editor
- Enhanced Vista style and a new, stylish iconset
- Automatic update check
- More speed in various places
- much more ...
-
How to enable Unicode in VirtualTree's inplace editor
written: 16 years ago category: Programming
VirtualTree's inplace editor is the only thing which is (by default) not Unicode enabled in that package. Just found after having a Unicode enabled inplace editor for VirtualTree half implemented: If you have TNT Controls installed, you can activate "TNT support" in your [PathToVirtualTree]\Source\VTConfig.inc :
{$define TntSupport}
-
IE6 reserved word "functions" in class name
written: 16 years ago category: Programming
Internet Explorer 6 has several excuses for not wanting to display certain DIVs or text in DIVs. Most of them arise from the internal hasLayout property which has to forced to -1 (on!) to unhide those HTML parts. I just came around another, very odd reason for why IE6 hides text in certain situations: CSS classnames which interfere with reserved words such as functions. Simple example:
<div class="functions">bla blub</div>
Just rename functions to whatever and you're done.
-
The mother of all Delphi components
written: 17 years ago category: Programming
Thank you, Mike, for Virtual Treeview . It's the most useful, powerful, fast, flexible, beautiful, multifunctional Delphi component I've ever seen.
Thank you, thank you, thank you!
-
Ensuring window visibility after plugging off a second monitor
written: 17 years ago category: Programming
I recently connected my new HD TV to my notebook, to test the DVI-to-HDMI adapter I just bought and various resolutions. I played a bit with different resolutions, started HeidiSQL, moved it to the TV which was used as second desktop. Then, after having plugging off the TV I started HeidiSQL again and saw - nothing! No window visible... HeidiSQL remembered its last window position and started in the area where the TV has previously provided its resolution. So, looked like a bug :) Started Delphi and found the place where the main window restores its position (Top, Right) and size (Width, Height) from the last session. I discovered the global Screen object has some Monitor* properties - these are:
Screen.Monitors Screen.MonitorCount Screen.MonitorFromPoint Screen.MonitorFromRect Screen.MonitorFromWindow
The most important property to fix the above described bug seemed to be MonitorFromWindow which tells the TMonitor object of the monitor on which the window is being displayed. The great thing about that is: If there is no second monitor plugged in, MonitorFromWindow returns the first TMonitor object available. So it always returns the best fitting monitor number for the given window handle, but never a no longer plugged monitor. Given this TMonitor object you can check if your window is placed within the monitor's resolution:var Monitor: TMonitor; const MoveWinThreshold: Byte = 80; begin // ... // 1. Some code to restore the last GUI position and dimension // ... // 2. Detect the relevant monitor object Monitor := Screen.MonitorFromWindow(Self.Handle); // 3. Now ensure the just positioned window is visible to the user // 3.a. Set minimal visible width if Left > Monitor.Left + Monitor.Width - MoveWinThreshold then Left := Monitor.Left + Monitor.Width - MoveWinThreshold; // 3.b. Set minimal visible height if Top > Monitor.Top + Monitor.Height - MoveWinThreshold then Top := Monitor.Top + Monitor.Height - MoveWinThreshold; .. end
If the window (that means: the upper left corner) is placed somewhere outside the monitor's resolution, the above code moves its Left + Top properties so there's a minimal rectangle of 80x80 pixels visible in the current monitor. Given this minimum rectangle, the user can now manually move and resize the window. P.S.: Don't try to Free the TMonitor object afterwards which you got by Screen.MonitorFromWindow - that will lead to an access violation. Most probably MonitorFromWindow returns a reference to that object. -
How to solve "can't open activity db - access is denied" for SVN commits
written: 17 years ago category: Programming
I somehow messed up the file privileges of a rsync'd SVN repository on a Windows server. Most probably it was rsync/cygwin which broke something here. After fiddling around with the folders and files I just zipped the complete directory of the repository, deleted the original files and then unzipped the zipfile again - works perfectly now! A ZIP file cannot store given privileges of files and folder. But be aware that RAR can, so prefer ZIP!
-
Typo3 3.5 running with PHP 5.x
written: 17 years ago category: Programming
This took me at least one hour to find out: If you encounter either this error while accessing the backend at /typo3 : Error in init.php: sitepath not specified correctly or this error while accessing the frontend: Cannot find configuration. This file is probably executed from the wrong location. Just ensure the old PHP arrays like $HTTP_SERVER_VARS are registered. You can do so by adding this PHP flag to your .htaccess :
php_flag register_long_arrays 1
-
Am Anfang war Niki
written: 17 years ago category: Programming
Meine ersten Gehversuche im Programmieren gehen zurück ins Jahr 1991, als ich ohne irgendwelche Vorkenntnisse in der 11. Schulklasse des Arnold-Janssen-Gymnasiums für ein halbes Jahr das Fach Informatik wählte. Lern-Stoff war eine abgeschlossene Programmier-Umgebung, in der man mit einem stark abgespeckten Pascal den Roboter "Niki" über ein viereckiges Feld steuern musste. Soweit ich mich erinnern kann, waren die damaligen PCs ausgestattet mit einem 80-086 Prozessor (4,7 MHz), 2 x 5¼-Zoll-Diskettenlaufwerken, Hercules-Grafik und Bernstein-Monitor. Vor kurzem fand ich die Niki-Software im Web wieder und sah mit Begeisterung, das es hier bereits eine Windows-Umsetzung gab: https://www.hupfeld-software.de/niki.php. Für alle Programmier-Anfänger heute noch wärmstens zu empfehlen