Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Saturday, March 20, 2021

[SOLUTION] Cannot Create Foreign Key

Been a long while since I last needed to have Foreign Key in my Database.

Much of my applications are not so complex that I don't bother employ a Foreign Key.

Now that I have to, it took me about three whole hours figuring out the problem.

I cannot create Foreign Key with HeidiSQL!

I've been using HeidiSQL for over ten years now.  It's only now that I faced problem with this MySQL GUI.

My latest Wamp Server uses MariaDB.

Thinking it could be MariaDB having a problem and not HeidiSQL, I tried using MySQL instead.

Still, with MySQL, I could not successfully create Foreign Key!  And I've been pulling my hairs off!

Somehow, this problem has been discussed over at HeidiSQL forums a year ago.  Even the author of HeidiSQL couldn't figure out why because the problem isn't happening on his side.

Luckily, a user named, Patsy, figured out why.

For some reason, my Wamp Server used MyISAM as default Table Engine instead of the more common, InnoDB.

So, in the end, it wasn't a bug in HeidiSQL.  Neither a bug in MariaDB nor MySQL.

It was a compatibility problem with MyISAM not being able to support Foreign Key

Hope this blog post will save you hours of hair pulling.

Happy hacking!

~creek23

Thursday, May 17, 2018

Game Boy Advance Development 101: Compiling Tank Advance

If you've happen to download Tank Advance source code from Loirak Development, chances are you're having a problem compiling a working GBA file with devkitPro.


That's because of the compiler.


The pre-compiled GBA file inside the Tank Advance ZIP file was compiled 2002 -- that's more than a decade and a half.  Last 2002, GCC was just version 3.  As of this writing, devkitPro is using GCC version 7.


Without much further ado, use the following lines in MSYS2:
arm-none-eabi-gcc -c gfx.c -mthumb-interwork -mthumb -O2 -o gfx.o
arm-none-eabi-gcc -c main.c -mthumb-interwork -mthumb -O2 -o main.o
arm-none-eabi-gcc main.o gfx.o -mthumb-interwork -mthumb -specs=gba.specs -o tank.elf
arm-none-eabi-objcopy -v -O binary tank.elf tank.gba



If successful, you should have a freshly compiled Tank Advance and you can start changing the code to understand how it works so you can start writing your own Game Boy Advance game. :)


Happy GBA deving!


~creek23

Friday, May 4, 2018

Game Boy Advance Retro Gaming with Supercard

Why Retro Gaming?

On my early 30s now, and such a nostalgia seeing game boy games being played with Smart Phone.  But the little boy inside me still wants to play these games in a real Game Boy device.


How to do Retro Gaming?

Option 1, buy Chinese knock-off game device that natively runs emulators which then runs your ROM (the game file of your favorite Game Boy game).  Amazon and Ebay lists Game Boy Console but I'm not sure on their authenticity -- so, buy at your own risk!
 
Option 2, buy used Game Boy and used games -- a little harder approach but I was able to find one used Game Boy Advance SP and a used game which isn't my kind of game.
 
So, I had to resort to a Supercard, a cartridge that used SD Card (to which you save your ROM and plays on your Game Boy) -- this Supercard was a hit some 15 years ago when ROMs plagued the Internet.  I learned about this when I was learning how to write a game for Game Boy Advance using free Game Boy SDK -- thanks to Jonathan Harbour's Unofficial Guide!
 
This Supercard only costs about $18 USD which is available online -- the card is also supported by NDS.


Common Problems and Solutions

Where to find ROM -- Internet is still plagued with ROMs, and you are not going to get those links from me.


"not find SD" --  there could be lots of reasons and these are possible solutions:
  • check that your SD card IS NOT SDHC card; if it is, buy a new one -- the SD one!
  • check that your SD card is formatted with FAT and NOT FAT32; it it is, reformat it to FAT!
  • check that your SD card is 2GB and NOT MORE THAN 2G; if it is, buy a new 2GB one.
Cannot read ROM -- you need to convert the ROM to be compatible with Supercard;  I found version 2.71 dated 2010.03.25

Cannot SAVE game -- make sure to Run Supercard converter as Administrator to enable SAVE in your ROM

Conclusion

That's pretty much it!  Comment down for questions and if you happen to have additional information, kindly share them in comments :) Happy Retro Gaming! 

~creek23
 
DISCLAIMER: Yes, my approach is technically "Piracy" and I'm not trying to justify -- it's just that these games are not being sold anymore.  So, NO, I'm not promoting piracy.  Read more on Nintendo's stand on ROMs.


SIDE NOTE:  Nintendo might be able to make money if it had a ROM store much like Apple's App Store or Google's Play Store since it already re-released NES, and SNES -- might as well re-release a WIFI-enabled Game Boy! :)
 

Tuesday, November 11, 2014

[Android Studio] Error : Failed to find: com.android.support

It's nice that Google is trying to make a full-fledged Android Authoring Software, complete with what is expected from an authoring tool.  But as of now, the tool itself is in Beta which has a few hiccups hidden somewhere, and one of this is not being able to compile an Android Project. o_o

Like, really?

So if you, like me, had encountered this problem saying:
Error : Failed to find: com.android.support
Relax and open SDK Manager then install the Android Support Repository and/or Android Support Library.  Better yet, install those two. :)

Upon restart of Android Studio, that problem should go away.

Happy hacking!

~creek23

Thursday, October 9, 2014

[FFMPEG] Adjust video volume

Before anything else, here's a quick disclaimer:  I do not promote the use of torrent for downloading movies you do not currently own.  Yes, I do download movies but only if I have a DVD/Bluray copy of it.  The only reason I download it so I would have a soft copy -- yes, I suck at ripping DVD/Blurays.

Okay.  Now, onto the issue at hand.

It seems that this torrent group called YIFY is famous among torrent freaks because of quality Bluray rips packed in very small HD files.  Sadly, YIFY configured their rips to lessen the quality of audio.  Which is not a problem for people watching the video on their computers since VLC Media Player can double the movie's volume and everybody's happy.

Well, not quite.

People who have LED TVs happen to enjoy the quality of the movie they downloaded by watching it on their 40~50in TVs.  And it so happen that their TVs doesn't have the feature VLC Media Player has (doubling the volume) -- so they are stuck with the audio quality that YIFY offers with their small-size HD movies.

So how do you fix it?

Have I mentioned my disclaimer, yet?

Anyway, let's use FFMPEG! Just type this into your Command Prompt:

ffmpeg -i "input.mp4" -c:v copy -af "volume=10dB" "thanksToCreekCodes.mp4"

Above ffmpeg command should make sure that you should now have a louder audio while having the same video quality.

I'm pretty sure you understood my disclaimer right?  Well, happy viewing!

~creek23

Friday, May 24, 2013

Compiling Geany on Windows

Can't remember exactly how many times I've tried compiling Geany or even thought of trying to compile it on Windows.  But I remember that my last try was last 2011 -- about February or March.

It's been a while that I've been trying to find a stable and reliable free and open source (not to mention cross-platform) Source Code Editing software so I could strip it down to provide an IDE specifically functioning for my open source game creation project called KAGE.  Finally, -- finally! -- I successfully compiled it yesterday!

I know that Geany's project page has a how-to page for compiling it on Windows but I still had bumps along the way.  This tutorial is simply to compliment what seems to be missing in the official tutorial.

So, just a recap. You need to have this things done already:

Not sure if we also need the GtkMM for Scintilla, but I did have that installed on my machine before I tried compiling Geany for the last time.

Before we proceed, let's make sure that you had the contents of GCC and GTK+ under C:\libs directory.  And that C:\libs\bin is added on your %PATH%, as well as C:\libs\msys\1.0\bin.

Now, for the `complimentary' part of my tutorial.

First, download the Manifest file from Geany's Git repo, which was not included in the downloadable zipped source code.

Rename win32-config.h to config.h then change the content of makefile.win32 from

all: config.h
 $(MAKE) -C tagmanager/ctags -f makefile.win32
 $(MAKE) -C tagmanager/mio -f makefile.win32
 $(MAKE) -C tagmanager/src -f makefile.win32
 $(MAKE) -C scintilla -f makefile.win32
 $(MAKE) -C plugins -f makefile.win32
 $(MAKE) -C src -f makefile.win32

config.h: win32-config.h
 $(CP) $< $@


to this

all: $(MAKE) -C tagmanager/ctags -f makefile.win32
 $(MAKE) -C tagmanager/mio -f makefile.win32
 $(MAKE) -C tagmanager/src -f makefile.win32
 $(MAKE) -C scintilla -f makefile.win32
 $(MAKE) -C plugins -f makefile.win32
 $(MAKE) -C src -f makefile.win32


The reason behind is that, there seems to be wrong with the makefile that the command COPY thinks config.h is supposed to be a directory.

Now, open a command line then run cd to the directory where you extracted Geany's source code.

Finally, type-in: make -f makefile.win32

Wait for it to compile and you'll then end up a very fresh build of Geany on Windows.

~creek23

Sunday, August 26, 2012

Gimp 2.8 gzdirect problem

This simple solution should fix the problem: "The procedure entry point gzdirect could not be located in the dynamic link library zlib1.dll."

To non-programmers, this error message simply means that your  zlib1.dll is outdated and needs to be replaced.

Somehow, most (if not all) Gimp plugins are using gzdirect which is supposed to be available on  zlib1.dll.

Try checking C:\Windows\System32\ and look for zlib1.dll then rename it to something else, maybe something like  zlib1.dll.old.

So where to get the latest one?  It's actually installed along with Gimp 2.8, but since you have another  zlib1.dll on your Windows' System32 path, Windows is trying to load that copy instead of the copy that Gimp 2.8 has.

Now, re-run Gimp 2.8.

Happy Gimping!

Friday, August 10, 2012

Jenkins: Executing binary from Jenkins script

If anyone of you are having the same problem as detailed on Jenkins forum about not being able to execute any Windows executables from Jenkins Job configuration.  The reason might be that slave-agent.jnlp is running as a service -- and for whatever reason, Windows won't let it run other executables.  To verify if it is the case, try uninstalling the slave-agent.jnlp service -- to do so, use Google -- then try running slave-agent.jnlp as is (meaning, right after executing the code below).

javaws http://yourjenkins.com/computer/yourslaveIP/slave-agent.jnlp

If that didn't solve the problem, sorry but I currently don't have any other solution.

Friday, June 22, 2012

Screencasting with Android

Well, if you are already using the Screencast Video Recorder, there's no use of reading this -- but I'm betting you're not because you stumbled onto this tutorial.

First of all, I am not related to the said screencasting app and I am in no way endorsing it.  I haven't even tried that app yet because 1.) it's not supported on my low-end Android device and 2.) it's a paid app -- yes, I'm cheap, sue me. :P

So this tutorial is about creating a screencast of your Android device using a free and open source tools called Android Screen Capture (or AShot) and FFmpeg.  I should warn you that this tutorial is not for the fainthearted -- it's gonna be messy through setting these tools up, and through creating of the screencast video itself.

I'm going to assume you know what we mean by screencast.  And I'm going to assume you are using Windows on your PC.

To start, download the tools:
AShot - http://sourceforge.net/projects/ashot/files/latest/download
FFmpeg - http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-20120620-git-5a90e55-win32-shared.7z

Here's a very detailed tutorial of setting-up AShot, which I'm very glad not to write over again.  It talks about downloading Android SDK, which AShot uses to capture images from your Android device.  One quick note, however, is the copying of the three files, namely:
  • adb.exe
  • AdbWinApi.dll
  • AdbWinUsbApi.dll
from this directory: C:\Program Files\Android\android-sdk\platform-tools

to this directory: C:\Program Files\Android\android-sdk\tools

Again, simply COPY the three files and not MOVE from one to the other.

Lots of troubleshooting is also discussed on that page, so go thoroughly through that page if AShot won't seem to work.



At this stage, I'm assuming you already got AShot working and you're seeing the same image in your PC as what's on your Android device as shown in the photo above.  You might have also tried screencapturing, and saw a tiny little problem -- (aside from the low FPS which is already answered many times on that page mentioned) instead of a video output, AShot outputs a series of PNGs.  Here's where FFmpeg comes in.

The FFmpeg binary download is just a zip file that can easily be extracted by 7zip or WinRAR -- though, I prefer 7zip.

I'm going to assume you extracted it on the root of your computer in such a way that ffmpeg.exe will be in this path: C:\ffmpeg\bin

And I'm also going to assume that you set AShot to output screenshots on this path: C:\ashot\

Now, all you have to do is open a Command Prompt and type this:
cd c:\ashot\
c:\ffmpeg\bin\ffmpeg -f image2 -i screenshot_%05d.png screencast.avi


Then using any movie player -- I use VLC media player by the way -- you can now view your screencast.avi.

Lastly, if you want to adjust the FPS of your AVI, try adding -framerate X when executing ffmpeg, where X is your desired FPS.

Happy screencasting!

~creek23

Monday, April 23, 2012

Android Development: Override the Device's Back button

When browsing a game's Options Menu and decided to not modify the current settings, you simply want to use your phone's Back button as, well, for going back to Main Menu.

But sadly, this is not the default behavior of that Back button. When you try to create your game, pressing that button will quit (umm... hide, rather) your app.

But don't lose hope. There's actually a way of changing that default behavior.

On your app's Activity class, add the following snippet.

@override
public void onBackPressed() {
  if (state == STATE_MAINMENU) {
     super.onBackPressed();
  } else {

     //do something else
  }
}


Of course, both state and STATE_MAINMENU has to be defined for the snippet to be usable. Also, whatever new behavior you want the Back button will have to do will be coded on the else part of the snippet, as indicated by do something else.

Saturday, April 21, 2012

Android Development: Disable Screen Rotation

By default, your app will run in Portrait mode.  And you might opt to keep it that way, but would also rotate to Landscape mode if the phone it handled sideways.

To keep it in Portrait mode, open your AndroidManifest.xml then add the highlighted text below.

<activity
   android:label="@string/app_name"
   android:name="HelloWorld"
   android:screenOrientation="portrait" >
   ...
< /activity>

But if you are creating an Android game, chances are you wanted to default it in Landscape and stay that way. If so, just change portrait to landscape.

Monday, March 26, 2012

Jenkins: Setting up Email Notification using Google SMTP

This is just about the same as the earlier post about Setting up Jenkins' Email Notification using Yahoo SMTP, only now it's for Google SMTP.

SMTP server - pop.gmail.com
Default user e-mail suffix - @gmail.com
Sender E-mail Address - Foobar CI <your.email@gmail.com>

Use SMTP Authentication - yes
User Name - your.email
Password - p******d

Use SSL - yes
SMTP Port - 995
Reply-To Address - noreply@gmail.com
Charset - UTF-8

To try if it's really working, type-in your email address and click Test Configuration, then you should be able to receive something like: "This is test email #1 sent from Jenkins"

Alternatively, you can also use smtp.gmail.com as SMTP server then use the SMTP port, 465. (Big thanks to Anthony Panozzo for sharing and Julio Carrettoni for confirming)

Jenkins: Setting up Email Notification using Yahoo SMTP

NOTE: This tutorial is for developers who are using Jenkins installed on their local server (with Internet Connectivity).

So you want to setup Jenkin's Email Notification but you don't have email server?

Assuming you have Yahoo Email account, that will work just fine. We just have to configure the Email Notification of Jenkins.

Under Manage Jenkins, go down to E-mail Notification then set these following information:
SMTP server - smtp.mail.yahoo.com
Default user e-mail suffix - @yahoo.com
Sender E-mail Address - Foobar CI <your.email@yahoo.com>

Use SMTP Authentication - yes
User Name - your.email
Password - p******d

Use SSL - yes
SMTP Port - 465
Reply-To Address - noreply@yahoo.com
Charset - UTF-8

Optionally, you might want to try if it's really working. Type-in your email address and click Test Configuration.

You should be able to receive something like: "This is test email #20 sent from Jenkins"

Below is what your configuration should look like.

Happy spamming! :P

Sunday, March 20, 2011

GCC: G++ ifstream reads extra unwanted characters

Been having trouble with GCC's G++ 4.5.2 with MinGW on Windows. I kept having unwanted characters from a file, which should not be present in the first place.

Given that I have a hello.txt text file that contains,
Hello World
and
Hello Universe


when opened with Notepad or any other text editor, G++ keeps sending me,
Hello World
and
Hello Universe
zpzksmsm3jk4509s


Of course, "zpzksmsm3jk4509s" is just a representation of the garbage data I'm getting. Most of the time, that garbage data is readable. So I usually get something like,
Hello World
and
Hello Universe
He


So there is basically no way for me to know which is a garbage data and which is still part of the file. Somehow, getting the file size doesn't seem to work correctly.

string loadFile(string p_fileName) {
  const char *l_fileName = p_fileName.c_str();
  char *bufPath = new char[strlen(l_fileName)];
    strcpy(bufPath,l_fileName);

  ifstream file(bufPath, ios::in|ios::ate);
  ifstream::pos_type size;
  char * memblock;
  string ret;

  size = file.tellg();
  memblock = new char [size];

  file.seekg (0, ios::beg);
    file.read (memblock, size);
  file.close();

  ret = memblock;
  delete []memblock;
  delete []bufPath;

  return ret;
}


Just so you could follow me further, I am trying to make a simple interpreter. I am barely at the part where I have to tokenize the text content and just had a basic checking of which is a command and which is not.

As I run my interpreter, I get the "expected" error, "Unknown command ` zpzksmsm3jk4509s'". But it's the "zpzksmsm3jk4509s"-part of the message that I was not expecting. As I said, the text file only contains nothing more but
Hello World
and
Hello Universe


It took me a couple of days before finally figuring out the problem.

According to a Cygwin FAQ entry, there seem to be an abnormality with Windows dealing with CR/LF.

From a Notepad's perspective, the hello.txt file is only 32bytes long. That counts Hello World (11 bytes), and (3 bytes), Hello Universe (14), plus two instance of CR and LF (thus, 4bytes).

G++ on Windows, on the other hand, also sees 32bytes. But! As what the Cygwin FAQ page says, it seems, Windows gives you CR and LF as one single character. Meaning, you, as the coder, should only read 30bytes long. That's why G++ is giving me extra He content.

So I had to modify my loadFile from reading the content all at once, into reading the content one character after the other. Then upon reading an 'LF', I will try to check if 'CR' was the previous character, giving me a CR/LF. In which, I will have to lessen my expected length in each instance of a CR/LF.

My code looked sort of something like this.
  int i = 0;
  file.seekg (0, ios::beg);
  while (file.eof() == false) {
    memblock[i] = (char) file.get();
    if (memblock[i] == '\n') {
      if (i > 0 && memblock[i-1] == '\r') {
        memblock[i-1] = '\n';
        i--;
      }
    }
    i++;
  }


Then make sure the last character of memblock would be a string-terminating "\0" since memblock is not a C++ String but a char*.

Now, if you ask, why did you get a CR then LF if Windows only gives you CR/LF as single character? Well, it seems, if you will have to read the file one character after the other, CR won't be CR/LF but simply CR. Making the next simply LF. You could assume that it's more of a G++ problem than a Windows problem. But as the Cygwin FAQ page suggests, it is a Windows file-handling problem.

Monday, June 21, 2010

Red 5: Fixing NetConnection.Connect.InvalidApp Error

Are you having problem connecting to your Red5 server? Is the error message, NetConnection.Connect.InvalidApp?

This happened to me too. Sadly, there was no available help online -- but there is now. ^^

This error occurs when your Flash application is connecting to a non-Flash-compatible service, like Skype for instance.

Skype opens a local connection at port 80 (the HTTP port). So if your Red5 is ran, it wouldn't actually be able to provide the RTMP service correctly, thus giving the NetConnection.Connect.InvalidApp error message.

What's the solution? Simply close Skype, restart Red5, and viola! Your open source media server is back running!