-
#OpenSource Migration
Hello,
First of all, i want to wish a happy 2023 to all of us!
It has been a while since i’ve posted to this blog last time. This year, i am planning to be more active on social media.
As a part of my 2023 social media plan, i will post a DevLog to YouTube each week. Last week i migrated my creativity toolkit to open source.
I was using Godot Engine for a while but i added Ardour DAW to my toolkit, and Linux Mint as the operating system.
Please subscribe to my YouTube channel and give me feedbacks about my weekly DevLogs.
-
Starting and Stopping IBM BAW – BPM
Hello,
This post is a kind of note for myself. Sometimes, i need to restart servers on a single node of a clustered BAW environment. While restarting single node, you need to stop and start servers in an order.
Restarting environment in wrong order, crushes the environment.
Stopping a BAW/BPM Node
- Sup
- App
- Messaging
Starting a BAW/BPM Node
You need to start servers in this order:
- Messaging
- App
- Sup
After restarting them in this order, environment would work fine.
-
I Missed You
Since last post, more then 2 years. Of course missed you, this blog and sharing stuff with you.
I didn’t have very crowded base of readers, but there were always traffic on this website, actually there are still but since i don’t force users to SSL connection google pushed me back. Last month, i’ve updated this policy, now it seems like Google started to give me some good results with SSL.
What Happened?
Of course i need to write “what happened during those 2 years?”
In March 2020, Turkey has also met with Covid-19 pandemic and it is still growing here. To be honest, i haven’t done much stuff since pandemic has started. I work during the daylight time. At nights i grab a beer or watch netflix or play games. To be honest, it gets more boring everyday.
But before pandemic i was travelling around the world, i’ve been in:
- Luxembourg
- Kenya
- Saudi Arabia (Riyadh, Jeddah, Jubail)
- United Arab Emirates (Abu Dhabi and Dubai)
During those travels i ate a lot of new food, met new people.
Also i have learnt some new stuff:
- Godot Engine
- Unity
- IBM MQ
- Redhat Openshift
I was not used to game engines. But since 2019 i am practicing Untiy and Godot simultaneously and that was a great experience for me. Because i’ve understood that, engines are very important tools that let us to focus on game itself.
As some of my readers remember, I was big fan of Phaser and LibGdx (I am still) those are great libraries, very performant, but as a hobbyist i don’t have much time to focus on UI, canvas, systems etc. Also those kind of libraries, provide multiple ways to do stuff. Testing those methods and switching between them consumes time. Godot and Unity has a standard method for most of 2D stuff.
More About Godot Engine
Even i introduced game engines with Unity, i liked Godot Engine more.
Why Do I Prefer Godot Engine over UnityLightweight, ease of use, easy shading language, performant 2D, elastic, extensible, supports native programming, easy (GD Script) programming language.
I installed Unity to my home workstation (oh, i also upgraded it) not to my work laptop, because it’s disk is small and doesn’t have external graphics card. Then i discovered Godot Engine from a blog post and navigated to it’s website. I saw it’s download is 32 MBs only, i thought thats an installer. I downloaded it to IBM’s Lenovo T400s (400 something, i can’t remember) and it runned directly. That was amazing.
I explorer Godot Engine for a period of time. It is very different than my previous experiences, it prioritizes ease of use and that is very different.
May be i can create another post about it, but Godot Engine is the most used tool for me since 2 years.
What About My Career
I am still working at IBM as Software Specialist (some says i am a consultant, i am not sure) and helping customers to improve their business via technology.
Since IBM acquired RedHat i am learning Openshift. Openshift is my priority right now.
To be honest, i am very happy at IBM. Of course each job has it’s own advantages and disiadvantages, but IBM has a good balance overall.
UnCategorized
I’ve became a professional life coach. I was kidding to life coaches once, and i am one of them now. Who knows what is next.
Join my discord
I’ve a discord server. Would you like to join me?
Hope to see you sooner.
-
wp_nonce_field Form Security Tutorial
wp_nonce_field() is a WordPress function that creates a hidden form field to validate requests origin. Simply, anyone can send a http request to your website from outside.
wp_nonce_field is a method to verify requests origin. nonce is an artificial word which is short form of “number used once”.
What is a nonce?
According to definition, nonce is a random number. In WordPress nonces are hash values which is made from combination of letters and numbers.
Difference between common nonces and WordPress nonces is we refer WordPress nonces are security tokens for web forms.
Why Do We Need to Use WordPress Nonces?
Primary reason to use nonces is saving your website against malicious exploits, which are based on Cross Site Request Forgery. This technique of hacking involves making web request from other websites to a website.
Let’s think about a scenario, you are a hacker who wants to populate a WordPress blog’s database malicious data (or useless data). If your target has a contact form on his or her website which isn’t protected with nonce fields, you may make a cross site http request to populate it’s database.
If you are able to add data to database, you might be able to delete data from database. A malicious attacker can write a very simple script to make POST request to victims forms.
WordPress is a most common CMS around the world, that makes WordPress #1 target of hackers and attackers. WordPress nonces are very simple method which can protect you from CRSF attacks. A url with nonce protection would look likes this:
http://example.com/wp-admin/user.php?userid=7&action=remove&_wpnonce=c214gd5315
Hence WordPress nonces always will be different, no one can guess and find a nonce to attack your website.
How Nonces Work?
Developers mostly don’t know how nonces (or CSRF tokens) work.
Lifetime of Nonces
Nonces have a lifetime. Nonces are invalidated after they reach their lifetime. Nonces lifetime is 24 hours.
More Security Information
What if attacker opens the source code and identifies nonce value? Yes they can copy it from source code and add it to end of url. WordPress has seperate nonces per session.
Implementing Nonces With WordPress
If you’d like to add some features to WordPress via HTML forms, you need to implement WordPress Nonces in your code.
WordPress has a funciton which creates a nonce URL. Of course, nonce value will be shown at the end of the URL but as i mentioned above, nonces are unique for users and actions.
$complete_url = wp_nonce_url( $bare_url, 'delete-user_'.$user->ID );
The code above creates a url to delete a user.By default WordPress nonce name is _wpnonce. Using custom nonce names adding even more security to WordPress but you need to remember nonce name if you use custom name:
$complete_url = wp_nonce_url( $bare_url, 'delete-user_'.$user->ID, ‘my_nonces’ );
The code above, creates an URL like this:
http://example.com/wp-admin/users.php?user=5&action=delete-user&my_nonces=c214gd5315
Adding Nonces to Forms
You can implement nonce fields in your forms. When you call WordPress to create a nonce field, WordPress adds a hidden field to your form.
To reach complete reference you can check out this page.
Mostly i create nonce fields with two parameters:
<?php wp_nonce_field( $action, $name); ?>
First parameter is name of the action and second parameter is the name of the nonce. As i mentioned earlier default nonce name in WordPress is _wpnonce.
Validating Nonce Fields
Adding a hidden field to a form isn’t enough by itself. You should validate nonce field before process data.
You can use this method to validate nonce fields submitted in a from:
wp_verify_nonce($nonce, $action);
$nonce: value of the nonce field, might be represented as $_POST[$name]
$action: name of the action given as parameter in the wp_nonce_fieldIf validation fails, this function returns false, it returns true if nonce value is validated successfully.
-
Conway’s Game of Life
After extinction of us, what will remain from us?
Are we going to able to create a new kind of specie?
Famoust mathematician Conway has an answer for this:
Even we can not create a new specie, we can leave a living mathematical formula.
Conway’s Game of Life’s rules are so simple:
For a space that is ‘populated’:
- Each cell with one or no neighbors dies, as if by solitude.
- Each cell with four or more neighbors dies, as if by overpopulation.
- Each cell with two or three neighbors survives.
For a space that is ’empty’ or ‘unpopulated’
- Each cell with three neighbors becomes populated.
These simple rules can “simulate” a living colony (or multiple colonies movement)
Conway’s Game of Life is not a “typical computer game”. It is a “cellular automation” which is invented by Mathematician John Conway.
I always wanted to simulate John Conway’s Game of Life. Though using HTML5 technologies is a great way to simulate John Conway’s Game of Life.
I created a video about programming Game of Life using Javascript and HTML5 technologies. I used Phaser CE framework implement this algorithm.
You can watch creation video below:
https://www.youtube.com/watch?v=ozEd9LEdq0s
Also you can find source code on my Github page.
I hope you enjoy the video!
-
Phaser 3 Tutorial
Phaser V3 is out now! There are lots of new features and improvements. In this article i am going to cover basics of Phaser 3.
First of all, Phaser is not using Pixi rendering engine anymore. Phaser V3 uses it’s own rendering engine. If you want to learn more about it’s new renderer, you can take a look to renderer’s source code from here. I haven’t do any performance benchmarks between Phaser CE and Phaser 3 but i am sure about it’s performance.
Phaser 3 Tutorial
Before getting starting with Phaser 3, i checked it’s documentation, there are some weird changes. First of all, Phaser 3 is now supporting 3D cameras using 2d objects. Second, groups are a little bit changed. I couldn’t see setAll() and forEach() methods in groups.
Starting a Game
We still use new Phaser.Game(), but we are going to use only one parameter with Phaser 3.
var game = new Phaser.Game({ type: Phaser.AUTO, width: 400, height: 400, parent: "game" }); game.scene.add('PlayScene', PlayScene, true);
One parameter of Game() function is an object, we put all required attributes into this object and pass it to Game() function.
Loading & Rendering Assets
Actually, loading asses and rendering them is almost same in Phaser 3.
Loading asset:
preload: function(){ this.load.image('star', 'assets/fullStar.png'); },
Rendering an image:
create: function(){ this.add.image(0, 0, 'star'); },
But result is not same:
As you may remember, (0,0) was bottom left corner of screen, it still is. But image anchors are changed.
If you run same code with Phaser CE, you will see that whole image. But now we can only see half of image. So let’s move it a little bit.
create: function(){ this.add.sprite(128, 128, 'star'); },
Aannd result:
That’s it. Ok, it’s a good feature, but i still need some time to get used to it.
Physics
You can start Physics using configuration object:
var game = new Phaser.Game({ type: Phaser.AUTO, width: 400, height: 400, parent: "game", physics: { default: 'arcade', arcade: { gravity: 20, debug: true } } });
Creating new sprite is a little bit changed, you can initialize a new sprite using active physics model’s factory. In this example I am going to use arcade factory to create a new sprite:
create: function(){ this.physics.world.setBounds(0, 0, 400, 400); var star = this.physics.add.sprite(128, 128, 'star'); star.setGravity(40, 100); star.setBounce(1).setCollideWorldBounds(true); },
Now you can see bouncing image on your screen.
Oh i also created an issue about resizing arcade sprites.
Conclusion:
Phaser is a great framework to create html5 games, with version 3 it will be better. Today, i am going to focus on cameras. After figuring out them, write a new article about cameras in Phaser 3.
Do not forget to subscribe my Youtube and Twitch channel. I am making games on Twitch, every friday 21:00 (GMT+3)
-
ISDS: bindtoreplica: unknown authentication type in agreement
During replication topology set up for IBM Security Directory Server, you may see this error. This error message has written into queue details page, on the Last Attempted Details tab. Complete error message is: bindtoreplica: unknown authentication type in agreement.
You may see this error while configuring replication between servers. This error message explains that: one of your servers does not have credential information. You need to do a cross check for replication credential between servers.
Click to replication management then manage credentials. Check each entry to find which replication credential does not exists on one of the servers.
Create lacking replication credential manually and re-check your queue status.
-
Db2 V9.5 – How to Shrink Tablespace
After deleting a big set of data from a table, we expect it to get smaller than it was before. But in Db2 V9.5 you need to lower high water mark to shrink unused space in tablespace.
After Db2 V9.7 you can use ALTER TABLESPACE command to lower high water mark and reduce a table’s size. You can find more information about V9.7 ALTER TABLESPACE statement from here. You need to use db2dart tool, to reclaim tablespace. In this article, I am going to cover: using db2dart utility to shrink tablespace.
Db2 V9.5 – How to Shrink Tablespace
In most cases, modern database management systems, shrink high watermark automatically. Db2 v9.5 released in 2007, so it’s an old version of Db2, you can not expect cutting edge features from Db2 V9.5.
What is db2dart?
db2dart is db2 database analysis and reporting tool. As you can see, it analysis problems on a database and suggests a solution. You can click here to navigate db2dart’s infocenter page.
In most cases, db2dart will suggest a solution (a solution that works!) for your problem. I always analyze tablespaces using db2dart to see it’s suggestions.
How to Shrink Tablespace
First of all, you need to find information about your tablespaces.
db2 list tablespaces show detail
You should see an output like this:
Total pages = 15783424
Useable pages = 15783392
Used pages = 7776640
Free pages = 8006752
High water mark (pages) = 15783392As you see, High water mark pages are really higher than used pages. That means, you will not be able to use pages between them. Now create a report about tablespace’s “defragmentation” status.
Step 1 db2dart /DHWM
db2dart <dbname> /DHWM /TS 2
This command will create a report for your database. You should see defragmentation in this report file. (Empty spaces between filled pages) If you see a fragmentation in the report, now you should run /LHWM option
Step 2 db2dart /LHWM
db2dart <db_name> /LHWM
db2dart utility will ask you tablespace id and pages count to lower. Your input should be like 2,0. You need to write 0 to lower high water mark as much as possible. Check the report that tool generated. There should be a suggestion at the end of the report.
Step 3 Reorganize Your Tables
If it says you to reorg your tables offline, here is your receipt:
db2 -x "select tabname, tabschema from syscat.tables where type='T' and tabschema NOT LIKE 'SYS%'" | grep '[^[:blank:]]' | awk '{print $2"."$1}' | grep -v "-" | sed '/^record(s)./d' | sed 's/^/REORG TABLE /g' | sed 's/$/ ALLOW NO ACCESS LONGLOBDATA;/g' > reorg.sql db2 -x "select tabname, tabschema from syscat.tables where type='T' and tabschema NOT LIKE 'SYS%'" | grep '[^[:blank:]]' | awk '{print $2"."$1}' | grep -v "-" | sed '/^record(s)./d' | sed 's/^/REORG TABLE /g' | sed 's/$/ ALLOW NO ACCESS;/g' > reorg_noac.sql
These commands will generate two sql files. Execute them using db2 -tvf option.
Step 4 Check Your Results
You might need to repeat step two and three more than once. You need to list tablespaces with detail to ensure if this worked or not.
If you have a question don’t hesitate to ask, leave a comment below, i’ll answer you as soon as possible.
-
How to Solve Db2 SQL0752N Error
SQL0752N Error message and explanation of this error is:
Connecting to a database is not permitted within a logical unit of work when the CONNECT type 1 setting is in use.
SQL0752N error usually occurs on redirected restore.
SQL0752N Error means, one or more of your databases is in restore pending state. You must fix problems about restore pending database.
First of all you must get output of this simple command:
[db2inst2@localhost NODE0000]$ db2 get db cfg for test | grep -i pending Backup pending = NO Rollforward pending = NO Restore pending = YES
As you may see, our DB2 dabatase is in restore pending state. (It also might be in rollforward pending state, but firstly you must solve restore pending issue first)
Main reason of this error is an error on restore operation. Usually this kind of errors and problems occur in redirected restore. Because DB2 knows how to handle restore operation while you are restoring a database to same instance.
On redirected restore, you need to set some paths and files to complete restore.
First of all drop test database.
db2 drop db test
If you don’t use generated script to make a redirected restore, you’ll be more likely to fail. Because a redirected restore script can help you to avoid mistakes.
db2 restore db test from /home/yigitozdemir/backups taken at 20050304090733 redirect generate script test_node0000.clp
This command generates a redirected restore script. You can set, log path, db path and table space paths using this script.
Open your redirected restore script via vim (or your other favorite text editor).
Set you log path, database path and table space paths. Be careful about these values. Your restore may fail because of these values. For example, if you are trying to restore, to a file table space, and you already have a folder on same path, you will get SQL0752N error.
After editing you clp file run this command to complete restore:
db2 -tvf test_node000.clp
If you have successfully complete restore, you must get this output:
[db2inst2@localhost NODE0000]$ db2 get db cfg for test | grep -i pending Backup pending = NO Rollforward pending = NO Restore pending = NO
Now your database is ready.
-
How to solve: Db2 is not listening port problem
Sometimes a mistake made by db administrator causes that kind of problem.
To solve this problem we need to take a few simple steps and check system services.
First of all, you need to get database service configuration with this command:
db2 get dbm cfg | grep SVCE
Does that value empty? You need to set a port number to test (we will change it with service name)
Now you should find an empty port, for example 55000. Let’s find if it is in use:
netstat -an | grep LISTEN | grep 55000
That command must return an empty result set. If it returns a row, you need to choose a different port.
Stop db2 and update your configuration for port 55000
db2stop db2 update dbm cfg using SVCENAME 55000
Now start db2 and check does db2 listening port 55000.
db2start netstat -an | grep 55000
You MUST see port 55000 is actively listening. If you can confirm that, db2 is listening 55000, jump to Modifying /etc/services section.
If port 55000 still is not in the list you need to update db2 system variables via that simple commands.
db2stop db2set DB2COMM=TCPIP db2start db2set -all
Last command lists db2 system variables. DB2COMM must be set to TCPIP to listen TCP ports.
Modifying /etc/services
Most of *nix system users are familiar with /etc/services file. In *nix systems, service names and their port and protocol are stored in this file.
We have a simple template to add db2 service to end of this file.
db2c_<instance_name> <port_number>/tcp #db2 service port
Open that file via vi (or your favorite text editor) and add your db2c_…. row to end of /etc/services.
And now, you must update db2 configuration with your new service name:
db2stop db2 update dbm cfg using SVCENAME db2c_<instance_name> db2start
Do not forget to change <instance_name> with your db2 instance name.
Confirm that db2 is listening port in /etc/services.