Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Wednesday, August 8, 2012

DBSyncer - A tool to synchronize databases through repository


Recently I started cleaning my PC from old, useless code and projects that I had been working on in the past and then I came across DBSyncer - a project intended to sync databases through repositories. Pretty useful if you and your colleagues (or friends) are developing a website or system, and you need a tool to sync the database between all the dev computers. I started developing this project in my spare time back in the beginning of 2011 because I needed such tool at work, where we were constantly  fighting with database synchronization through our subversion. But then in May 2011 I found a better job, where I didn't need this tool anymore, so development halted. Still, the made progress is pretty good - DBSyncer is fully working. I never released it because I wanted to implement a couple of features to it, but never got the time. Now, after more than an year, I'll release it as is - I'm sure there will be people happy to use it. I only replaced deprecated functions in newer PHP versions with working ones. So, what DBSyncer offers?

  • Automated database synchronization
  • Database change revisions
  • Database revert to revision
  • Well documented API
  • GUI

The main part of DBSyncer is it's PHP class - DBSyncer.php (only about 33kb). All other files are optional. If you choose to use only this file, you'll have to make the settings manually. Info about this, how to use DBsyncer and what methods it offers, is provided in the docs. If you want to use the GUI, then you'll need all files from the archive (available to download at project's page in Google Code). GUI can help you with the following things:

  • Install DBSync
  • Add new database
  • Import database
  • Remove database
  • See revision changes for each database
  • Apply revision to database both forward and backwards
  • Add or remove revisions
  • Export database without data (structure only)
  • Make changes to the config

All of these things are provided by DBSyncer.php. The GUI only helps you to manage databases visually. Also note GUI won't sync your databases automatically. If you want that, then you'll need to implement DBSyncer.php in your project and use its methods. See docs for more info.

Main screen
Screen showing database revisions

There is some unfinished work with the GUI - no "please wait" screen when applying revision (probably somewhere else too). If I have time, I'll fix this.

Final words - Although not entirely finnished, DBSyncer is still a good piece of work if it fits your needs. Enjoy!

Monday, May 28, 2012

Automated JS/CSS combining/minifying system - JSS Build Environment


Recently I wrote a post about JS compressors and how they compare to each other. Now I've build a system for combining and/or minifying JS and CSS files. This system uses Google's Closure Compiler for JS minification and Google's Closure Stylesheets for CSS minification. Both of them require Java, so if you want to use 'Compress' option, then you'll need to install it and point JSS Build Environment to java.exe. I recommend extracting jPortable to a folder next to this EXE file.


Features:



- JavaScript combine and minify
- CSS combine and minify
- Automatic combine/minify when one of the input files is changed.
- Control over the sequence of combining
- Minimizing to system tray
- Single EXE without installer


Setup:



close-compiler is the folder containing compiler.jar file of Closure Compiler.
closure-stylesheets is the folder containing closure-stylesheets.jar of Closure Stylesheets.
Java folder contains extracted files from jPortable.
JSS Build Environment can run without all of these folders, but you'll only have combine option.

Usage:


To use this app, you need to add files to CSS or JS panels (or both), choose Output file and click Build. It's as simple as that. Of course this only activates combining. No compression is applied. If you want compression, then you have to setup files as described in Setup above and then check Compress checkbox before building.
Now let's talk about Auto Build feature. This is really useful feature when you need to build every time you change something. Auto Build monitors the files and when some file is changed it starts build procedure. Build procedure includes compression if it's checked, but I recommend not checking it, as compression takes time and you'll need to wait a lot just to see let's say your text in red. Combining Auto Build with minimizing to system tray and some balloons makes things look and work really good.


Download:


JSS Build Environment
Source Code (in Delphi XE)

Happy codding ;)

Monday, May 7, 2012

Converting multiple files into WebP under Windows (MultiWebP)

You know of Google's image format WebP? If you do and you want to convert your images to .webp, you'll notice it's a bit hard, as you have to do it image by image. I wrote a little batch file, called MultiWebP, which can automate this for you ;) You can download it bellow. There are two files - test.bat and encode.bat. The first is optional and is used to encode only one file, just to test the settings. The second file is used to encode the whole folder :)

Update: New version is out!
Details for MultiWebP 2.0:
- Only one file! test.bat and encode.bat are now combined in MultiWebP.bat.
- One file means only one line of settings, not two as before.
- Subfolders. MultiWebP now supports subfolders. You can run it on a parent folder and all files will be encoded, even those in subfolders.
- Progress. MultiWebP now shows total files to convert and files converted till now.
- Colors. MultiWebP now shows it's window in different colors, depending on the progress made. This is useful for remote observing (if you lay down on your bed and wait it to finish). Color levels: black - 0 to 32%, blue - 33 to 66%, aqua 67 to 100% and green when all is done.
- Beep. Additionally Windows' beep sound is heard upon all task completed.

Installation:
1. Download WebP package from Google and extract it somewhere. Optional you can download WebP codec to be able to open .webp files with your Windows Photo Viewer.
2. Download my scripts and extract them.
3. Place the two files next to cwebp.exe.

4. Create two shortcuts for test.bat and encode.bat and name them as you like.

5. Open Explorer and type in the address bar %APPDATA%\Microsoft\Windows\SendTo
6. Paste the two shortcuts there. Now you should see both of them in the Send To menu.

Settings:
You should read Readme.txt of WebP and learn about what cwebp.exe parameters are available. Then you should open test.bat/encode.bat, find cwebp.exe and change it's parameters. I've included some by default, so you can start using my scripts without changing settings.

Usage:
1. Create a folder where you'll put cwebp.exe supported images that have common source (shot with the same camera), to ensure settings will be the same for all files.
2. Right click one of the files and send it to test.bat.

3. Change settings for test.bat if you don't like the result and repeat step 2, until you are pleased with the result.
4. After you found your settings, copy them to encode.bat.
6. You are about to convert the whole folder, so make sure you don't have any unsupported by cwebp.exe files as they will be deleted in the end!
7. Right click on the folder and send it to encode.bat.

8. Go take a walk :)

Tuesday, March 27, 2012

Darkness Beyond Limits

A couple of months ago I was keeping my monitor's brightness setting to the maximum and it was normal for me, even in the evening with the lights off. But things have changed a bit with those tablets around - now I'm used to much less brightness than my monitor's setting allows. I like Android with it's apps (like RootDim) that can control backlit and go beyond the limits. So I wanted an app for Windows that can do the same, as my minimum brightness was too bright for night reading - that's how Darkness Beyond Limits was born. Unfortunately, Windows cannot control monitor's brightness like Android can. The only thing you can do is simulate lower brightness, but this won't actually be backlit going darker :( Nevertheless, the result is satisfying - you get much dimmer screen :) There are two possible ways to achieve that and this app (written in Delphi XE, so if you want to make changes (yes, I provide the source code too) you'll need to install it) supports both of them. XE outputs quite big file, but it assures it's Windows 7 compatible, so I preferred it instead of Delphi 7. Darkness Beyond Limits is really easy to use - it has no options and no hotkeys to mess with your other hotkeys, just a tray icon. The main goal here is to be dead simple. The app will remember your last brightness setting and will apply it on startup. So, if you want to start it with Windows, just put a shortcut inside your Startup folder. I've tested Darkness Beyond Limits on 1 PC, 1 netbook and 1 laptop with Windows 8 DP, Windows 7 and Windows XP respectively. It works quite well. Also I've made some power consumption measurements (see bellow). So, how does those methods work? I'll give you an explanation with pros and cons - you decide which method to use:

Method 1 (Power):
This method uses a transparent black canvas over (almost) all of your applications, making them look darker.
Pros:
- You can get almost black screen
- Power consumption can go down a bit, depending on your screen
- Always works
Cons:
- May produce 100% usage of a core under XP and below
- Taskbar stays ontop when clicked once. This can be used as a pro when setting set too low, but otherwise it's pretty irritating. There is a workaround, but it's for Windows Vista and below - un-check "Keep taskbar on top of other windows" option in your taskbar properties.
Method 2 (Gamma):
This method uses Windows' gamma settings to simulate darker screen.
Pros:
- No 100% usage under XP as Power method
- No Taskbar ontop as Power method
Cons:
- Doesn't always work (depends on the drivers)
- Can't go as dark as Power
- No potential power consumption savings
- Improper shutdown of the app will result in brightness level not returning to normal until system reboot or by running again DBL

Switching methods:

The default method is Power. If you want Gamma, after you've run DBL at least 1 time, open DarknessBeyondLimits.ini (should be next to the exe file you ran) and correct Gamma=0 to be Gamma=1. Save. Now when you start DBL it'll use Gamma method. System Tray icon will correspond to the method used.

Systems:

PC: monitor Fujitsu Siemens P20-2 on Windows 8 Developers Preview
Netbook: Acer Aspire One AOA110 on Windows 7
Notebook: Asus X51L on Windows XP

Power Consumption (only on Power method):

PC w/o DBL: 31.3W
PC w DBL: 29.6W
Netbook w/o DBL: 13.6W
Netbook w DBL: 13.6W
Notebook w/o DBL: 19.2W
Notebook w DBL: 37.5W

Note: All systems have their backlit set to minimum. Increased power consumption on Notebook is because of Windows XP using one core on 100% for DBL.

Conclusion:

As you can see from the graphics above, you can get less power usage, no change in it, or get a lot more of it. It really depends on your monitor. Some monitors use less energy when displaying black colors, so the darker the image is, the less power it consumes. If your monitor is not one of those, Power method will not increase power usage, unless you are using Windows XP, so if you are with XP I strongly recommend Gamma method for you. If you are energy saving maniac like me, use Power method (probably you won't be using XP, as it's draining more juice than 7, not to mention 8). If you prefer stability, use Gamma method.

Download:

Binary
Source code