<form id="form" method="post" action="" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" name="submit" value="submit"/>
</form>
<script>
var form = document.getElementById('form');
form.onsubmit = function(a){
//get the file we would likt to submit
var theFile = form.elements.namedItem("file").files[0];
if(theFile != undefined){
var xhr = new XMLHttpRequest();
//monitor the on upload data progress (so we could implement the simple progress bar perhaps..?)
xhr.upload.addEventListener("progress", function(e){
console.log(e);
}, false);
//POST method with the target url of 'test.php'
xhr.open( "POST" , "test.php");
var ff= new FormData();
//append any post data here
ff.append( "submit" , 1 );
//append the file here
ff.append( "file" , theFile );
//finally send the ajax request!
xhr.send(ff);
}
return false;
}
</script>
Kamis, 05 Juni 2014
[Javascript] Uploading File Field using AJAX
This simple snippet will show you how to upload file through the AJAX `protocol` using pure Javascript
Sabtu, 01 Februari 2014
[MySQL] Note about, listing table rows which is not mentioned on some other table row
Straight from StackOverflow:
SELECT table1.*
FROM table1
LEFT JOIN table2 ON table2.name=table1.name
LEFT JOIN table3 ON table3.name=table1.name
WHERE table2.name IS NULL AND table3.name IS NULL
MySQL, as well as all other systems except SQL Server, is able to optimize LEFT JOIN / IS NULL to return FALSE as soon the matching value is found, and it is the only system that cared to document this behavior. […] Since MySQL is not capable of using HASH and MERGE join algorithms, the only ANTI JOIN it is capable of is the NESTED LOOPS ANTI JOIN
Essentially, [NOT IN] is exactly the same plan that LEFT JOIN / IS NULL uses, despite the fact these plans are executed by the different branches of code and they look different in the results of EXPLAIN. The algorithms are in fact the same in fact and the queries complete in same time.
It’s hard to tell exact reason for [performance drop when using NOT EXISTS], since this drop is linear and does not seem to depend on data distribution, number of values in both tables etc., as long as both fields are indexed. Since there are three pieces of code in MySQL that essentialy do one job, it is possible that the code responsible for EXISTS makes some kind of an extra check which takes extra time.
SELECT table1.*
FROM table1
LEFT JOIN table2 ON table2.name=table1.name
LEFT JOIN table3 ON table3.name=table1.name
WHERE table2.name IS NULL AND table3.name IS NULL
MySQL, as well as all other systems except SQL Server, is able to optimize LEFT JOIN / IS NULL to return FALSE as soon the matching value is found, and it is the only system that cared to document this behavior. […] Since MySQL is not capable of using HASH and MERGE join algorithms, the only ANTI JOIN it is capable of is the NESTED LOOPS ANTI JOIN
Essentially, [NOT IN] is exactly the same plan that LEFT JOIN / IS NULL uses, despite the fact these plans are executed by the different branches of code and they look different in the results of EXPLAIN. The algorithms are in fact the same in fact and the queries complete in same time.
It’s hard to tell exact reason for [performance drop when using NOT EXISTS], since this drop is linear and does not seem to depend on data distribution, number of values in both tables etc., as long as both fields are indexed. Since there are three pieces of code in MySQL that essentialy do one job, it is possible that the code responsible for EXISTS makes some kind of an extra check which takes extra time.
Jumat, 31 Januari 2014
Lua, Function List on Notepad++
New feature for the notepad++ version 6.5.2! it could shows you the function list for the currently viewed document, function list for php, c++, c, perl is supported out-of the box
For those of you Lua programmer using notepad++, here is a simple how to add Lua function list to the notepad++
For those of you Lua programmer using notepad++, here is a simple how to add Lua function list to the notepad++
- Locate your %APP_DATA% folder, if you are using the zip distribution, go to your extraction directory
- Open functionList.xml
- On NotepadPlus >> functionList >> associationMap , see the commented LangID for LUA, on my installation it is 23
- Add the following
<association langID="23" id="lua_function"/> on that section - Creating the parser:
on NotepadPlus >> functionList >> parsers add the following section<parser id="lua_function" displayName="Lua" commentExpr="((--\[\[.*--\]\])|(--.*?$))"> <function mainExpr="function\s+(\w+[:\.])?(\w+\s*\(\s*[\w,\s]*\s*\))" displayMode="$className->$functionName"> <functionName> <nameExpr expr="\w+\s*\(\s*[\w,\s]*\s*\)"/> </functionName> <className> <nameExpr expr="[\w]+(?=[\s]*[:.])"/> </className> </function> </parser>
- Warning: if you copy paste xml content on line 5, please make sure that the xml properties are in one line, if they appear to be 2 line, it is because html page wordwrapping ;)
- Restart notepad++
- Open your lua file, open function list panel (Menu >> View >> FunctionList)
If the functions is not showing, chances are :
- You are using Gary's mod lua lexer.. uninstalling it should overcome the problem
- Wrong language ID noted from step 3
That's all! :)
Have fun!
Minggu, 26 Januari 2014
How to find out built in defines from a specific GCC compiler?
A little trick i read from LuaJit's makefile and the gcc manual page. To list all built-in defines use the following (assuming that you don't have yohan.h file on the current directory..)
# touch yohan.h
# gcc -E -dM yohan.h
and if the "yohan.h" contains your own code of defines, it will also be resolved.. giving you the exact picture of what's happening with your sources defines
# touch yohan.h
# gcc -E -dM yohan.h
and if the "yohan.h" contains your own code of defines, it will also be resolved.. giving you the exact picture of what's happening with your sources defines
Selasa, 07 Januari 2014
[c++, c#] Journey of cross compiling mono 3.2.5, utilizing ScratchBox2
This one is a tough one, usually i get away compiling just by trial-and-error after successfully compiling the library for the windows target. But compiling this one is very much a challenge.. and then out of curiosity.. here i am writing this blog entry so that someday i could revisit and think .. what the **** am i doing compiling libraries and not doing those projects!
Well if my future me see this post, "I do it because of cross environment, playbook, win 7.5, vala, mono, xna, cocos2dxna, and Pou.. i bet you will understand and remember.. hehe, and yes, i know, it is very silly.. but Y.O.L.O!"
So let's go with it shall we..
After trying to compile using BB NDK SDK version 2.1 i encountered problem with the assembler compilation. If i can recall the error correctly, the message was "invalid operation $03" or something similar like that..
After 2 nights of blackened eyes, i give up and then tried to compile on a virtual machine, for that machine i choose LINUX Mint 15 for the OS, chosen simply because the OS iso file lying around on my hard-disk. For the virtualization, i'm using vmware
I was thinking about using linux because i could simply use ./configure and then make, but i think to myself it would be better if i could directly compile this for the arm architecture, after diving to google, there is a very exciting project callled Scratchbox2, and then here i am using the command
$ sudo apt-get install scratchbox2
$ sudo apt-get install qemu
Then i tried to find linux arm compiler toolchain, for this purpose i search for the file arm2009q1-203-none-linux-gnueabi simply because that is the compiler i used in Windows when venturing with WebOS.. (love that platform.. hixs..)
here is the name of the file i downloaded from codesourcery: arm-2009q1-203-arm-none-linux-gnueabi.bin
What?? you need the web address you say? here it is: http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
Let's go to the terminal and then type the following..
$ chmod +x arm2009*
$ ./arm2009*
Follow those installation screen with care, i choose to install on default directory.. and that is at $HOME/CodeSourcery
Here is the trick! if i use sb2-init with the -c and without -C -static it will fail to run sb2-build-libtool! don't know about that -c, but if i did not specify -C -static, the compiled will try to find the library linux.so.3, about the -lpthread, that's because when compiling mono, there are undefined references to pthread, so i decided to put that to default.. maybe we should find a cleaner solution to this
Therefore here is the command i use to initialize sb2
$ sb2-init -d -C "-static -lpthread" arm $HOME/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc
$ sb2-init -d arm $HOME/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc
when not using this arm-2009q1-203-arm-none-linux-gnueabi.bin release, for example using built in arm-linux-gnuebi-gcc (from the apt), i failed to run sb2-build-libtool, a workaround would be adding parameter -C "-static" to sb2-init but i guess this would break some build system.. note to self: Need to find-out building custom rootfs! (finger crossed, perhaps copying the libc content? hehe..)
important! you need to init sb2 in $HOME/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc because that is the rootfs for that toolchain
let's try with a simple hello world program shall we..
$ sb2
$ gcc hello.cpp -o hello
$ file hello --> this should show that we have compiled for the arm-architecture! ;)
$ ./hello --> will run!
$ exit ->> this will exit us from the "jail" arm-environment we had setup earlier
Ok, now is the fun part, let's go to the extracted tarball mono source folder, cross your fingers :p and then type
$ sb2
$ ./configure --with-monotouch=no --without-mcs-docs --disable-mono-debugger CFLAGS="-DBROKEN_64BIT_ATOMICS_INTRINSIC -DARM_FPU_NONE" LIBS=-lpthread --disable-mcs-build
The configuration is a success!
But, the potential horror might now came along.. anyway.. let's proceed!
before make! i add the patch to the mono/mini/mini.arm.h
#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
change that to
//#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
on the same terminal, lets go make some!
$ make
$ make install DESTDIR=$HOME/mymono
there you have it! a compiled mono for arm architecture!
Some hints:
for the mono's ./configure script, to show the options accepted by the configure run
$ ./configure --help
Ps. If you like and learn something from other people, and you can't or don't want to donate to them directly, show your support by sharing the article, google+ing the article, or perhaps checking out the advertisements which may appear on the website ;) many thanks before!
Well if my future me see this post, "I do it because of cross environment, playbook, win 7.5, vala, mono, xna, cocos2dxna, and Pou.. i bet you will understand and remember.. hehe, and yes, i know, it is very silly.. but Y.O.L.O!"
So let's go with it shall we..
After trying to compile using BB NDK SDK version 2.1 i encountered problem with the assembler compilation. If i can recall the error correctly, the message was "invalid operation $03" or something similar like that..
After 2 nights of blackened eyes, i give up and then tried to compile on a virtual machine, for that machine i choose LINUX Mint 15 for the OS, chosen simply because the OS iso file lying around on my hard-disk. For the virtualization, i'm using vmware
I was thinking about using linux because i could simply use ./configure and then make, but i think to myself it would be better if i could directly compile this for the arm architecture, after diving to google, there is a very exciting project callled Scratchbox2, and then here i am using the command
$ sudo apt-get install scratchbox2
$ sudo apt-get install qemu
Then i tried to find linux arm compiler toolchain, for this purpose i search for the file arm2009q1-203-none-linux-gnueabi simply because that is the compiler i used in Windows when venturing with WebOS.. (love that platform.. hixs..)
here is the name of the file i downloaded from codesourcery: arm-2009q1-203-arm-none-linux-gnueabi.bin
What?? you need the web address you say? here it is: http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
Let's go to the terminal and then type the following..
$ chmod +x arm2009*
$ ./arm2009*
Follow those installation screen with care, i choose to install on default directory.. and that is at $HOME/CodeSourcery
Therefore here is the command i use to initialize sb2
$ sb2-init -d arm $HOME/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc
when not using this arm-2009q1-203-arm-none-linux-gnueabi.bin release, for example using built in arm-linux-gnuebi-gcc (from the apt), i failed to run sb2-build-libtool, a workaround would be adding parameter -C "-static" to sb2-init but i guess this would break some build system.. note to self: Need to find-out building custom rootfs! (finger crossed, perhaps copying the libc content? hehe..)
important! you need to init sb2 in $HOME/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc because that is the rootfs for that toolchain
let's try with a simple hello world program shall we..
$ sb2
$ gcc hello.cpp -o hello
$ file hello --> this should show that we have compiled for the arm-architecture! ;)
$ ./hello --> will run!
$ exit ->> this will exit us from the "jail" arm-environment we had setup earlier
Ok, now is the fun part, let's go to the extracted tarball mono source folder, cross your fingers :p and then type
$ sb2
$ ./configure --with-monotouch=no --without-mcs-docs --disable-mono-debugger CFLAGS="-DBROKEN_64BIT_ATOMICS_INTRINSIC -DARM_FPU_NONE" LIBS=-lpthread --disable-mcs-build
The configuration is a success!
But, the potential horror might now came along.. anyway.. let's proceed!
before make! i add the patch to the mono/mini/mini.arm.h
#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
change that to
//#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
on the same terminal, lets go make some!
$ make
$ make install DESTDIR=$HOME/mymono
there you have it! a compiled mono for arm architecture!
Some hints:
for the mono's ./configure script, to show the options accepted by the configure run
$ ./configure --help
Ps. If you like and learn something from other people, and you can't or don't want to donate to them directly, show your support by sharing the article, google+ing the article, or perhaps checking out the advertisements which may appear on the website ;) many thanks before!
Rabu, 13 November 2013
c++ defines, what is the meaning of that dreaded ## signs.. :)
That ## syntax maybe looks like evil, but as a lovely c++ programmer, you need to use and get familiar with that syntax
When i first saw this syntax.. the ants starts to creep on my stomach as my lack of skill in pronounces, i could not find the right keyword to google that '##' syntax.. :(
when you see something like this on some c++ header file:
That macro, by the compiler will be translated to
Yep, and that is all folks.. :)
When i first saw this syntax.. the ants starts to creep on my stomach as my lack of skill in pronounces, i could not find the right keyword to google that '##' syntax.. :(
when you see something like this on some c++ header file:
#define CF(className) create##ClassName(){}
this macro if applied for example..
CF(kittyClass);
That macro, by the compiler will be translated to
createKittyClass(){};
Yep, and that is all folks.. :)
Jumat, 02 Agustus 2013
[Tizen] Problem starting emulator
Does your hardware support hardware virtualization? if not i share your pain :( if you download and install the Tizen SDK ver 2.1 there is a solution posted to make your emulator runs.. yes it runs.. but it is veeeryyyy slooowww..
Steps:
Steps:
- Create your new emulator
- Run the emulator
- Wait for it to load
- Right click and then open the shell
- Type the following command :
- su
- sed -i 's/notify/oneshot/g' /usr/lib/systemd/system/user-session@.service
- If you would like to use the manual way of changing that one, buut this one is on your OS'es command prompt
- sdb pull /usr/lib/systemd/system/user-session@.service user-session@.service
- Edit that file using notepad, Modify "Type=notify" to "Type=oneshot"
- sdb push user-session@.service /usr/lib/systemd/system/user-session@.service
- Now verify by typing these on your emulator's shell:
cat /usr/lib/systemd/system/user-session@.service - Restart the emulator
Senin, 01 Juli 2013
[Wordpress]problem of wordpress post thumbnail images not resized correctly
Let's open the article with the following code snippet, taken from WP's(WordPress'es) function image_get_intermediate_size from the file media.php from
Well, what's wrong with that statement? there is nothing wrong with that statement, it is just that when you have an original image size which width or height was the same as the default thumbnail size, since the autogenerated thumbnail width is always lesser than the original image, then the 'autogenerated' thumbnail size will always be returned
Consider the following example, you have your original image at the resolution of 200px * 135px.
Note that the default thumbnail size generated by WP is 150px * 135px, and then you have the following code which is intended to show the featured image for the current page:
You will not get your 200px * 135px as you intended, instead the code will give you a 150px * 135px thumbnail size, since the later rule from the if stament presented earlier fits to these sizes perfectly, it will gives you a cropped and scaled image of 150px * 135px
A fast fix would be specifying get_the_post_thumbnail($page->ID, array(200, 136)) which will give you a 'slightly distorted' thumbnail, another fix would be implementing a default thumbnail size via WP's function set_post_thumbnail_size on your theme's function.php file
if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
$file = $data['file'];
list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
return compact( 'file', 'width', 'height' );
}
Well, what's wrong with that statement? there is nothing wrong with that statement, it is just that when you have an original image size which width or height was the same as the default thumbnail size, since the autogenerated thumbnail width is always lesser than the original image, then the 'autogenerated' thumbnail size will always be returned
Consider the following example, you have your original image at the resolution of 200px * 135px.
Note that the default thumbnail size generated by WP is 150px * 135px, and then you have the following code which is intended to show the featured image for the current page:
<?php echo get_the_post_thumbnail($page->ID, array(200, 135)); ?>
You will not get your 200px * 135px as you intended, instead the code will give you a 150px * 135px thumbnail size, since the later rule from the if stament presented earlier fits to these sizes perfectly, it will gives you a cropped and scaled image of 150px * 135px
A fast fix would be specifying get_the_post_thumbnail($page->ID, array(200, 136)) which will give you a 'slightly distorted' thumbnail, another fix would be implementing a default thumbnail size via WP's function set_post_thumbnail_size on your theme's function.php file
Minggu, 26 Mei 2013
[Delphi] DevExpress Ribbon - how to
Since it's is a rather sparse documentation, i think i will try to post how to add a Ribbon Control to the Delphi XE application
- Open Delphi!
- Create a new VCL Form Application
- Open your main pas file
- Change the ancestor for the TForm, to TdxCustomRibbonForm
- Add the unit dxRibbon
- Drop a dxBarManager and then assign it to your dxRibbon
- On dxRibbon, right click and then choose Tabs Editor..
- Add a TdxRibbonTab, and then highlight that newly created ribbon tab
- On you inspector, click on Groups and then click on the ellipsis to create a new Ribbon Tab Group
- For the time being, leave it as is..
- Double click you dxBarManager, create a new Toolbar
- Create a new command and then drop that command to your toolbar
- Now let's go back to your previously created Ribbon Tab Group, in the inspector, see the property Toolbar and assign it the toolbar you created on step 11
- Okayh, that's one great strong basic, now go wild!
Cheers!
Kamis, 17 Januari 2013
[YII] Quick Start, YII Tutorial in 2 minutes!
Yii as simple as 1..2..3 For this tutorial, i assume that you are working in windows environtment and already setup your local webserver (xampp, wamp, etc..)
- Download Yii anywhere you wanted, extract them to any folder you wanted.., for this example let's say after you download the zip file, you extract it to c:\yii
- Open up command prompt / terminal
- Change your dir to the directory where you put your php.exe, in my case it is in C:\xampp\php
- On that dir, execute the command:
php "C:\yii\framework\yiic" webapp MyAppName - Now move the folder MyAppName to your htdocs folder,
in my case i move entire folder to C:\xampp\htdocs - That is it.. now you have a fully working MVC Yii application
Open your browser and then go to the address http://localhost/MyAppName
Rabu, 16 Januari 2013
[Delphi] MDI On a TPanel, RTTI power example
Ummh, since it's 3 AM, and just as a quick note on delphi power, MDI child on a TPanel and an introduction to a RTTI usage..
You will need Delphi XE and TMS Component
You will need Delphi XE and TMS Component
procedure TForm1.AdvOfficeMDITabSet1TabClose(Sender: TObject;
TabIndex: Integer; var Allow: Boolean);
var
form : TForm;
begin
form := AdvOfficeMDITabSet1.GetChildForm(AdvOfficeMDITabSet1.AdvOfficeTabs[TabIndex]);
form.Close;
Allow := False;
end;
procedure TForm1.New1Click(Sender: TObject);
var
c : TForm;
begin
c := TForm2.Create(Self);
c.Parent := Panel2;
c.SetBounds(0, 0, Panel2.Width, Panel2.Height);
c.Caption := 'Yohan ' + IntToStr(Panel2.ControlCount);
(c as TForm2).EllipsLabel1.Caption := c.Caption;
c.Show;
//introducing the power of delphi RTTI!
if(c.ClassType = TForm2) then
AdvOfficeMDITabSet1.AddTab(c);
end;
Jumat, 30 November 2012
[Debian VPS]Installing lamp, till bind9
Edited: 29 Jan 2015
To manage this kind of things, let's use a more powerfull thing which is called Webmin. Download the debian package, and then setup Apache Virtual Hosts, and Bind Configuration from there.
side note: when installing bind to the VPS, we should set the DNS Server to 127.0.0.1 (localhost) and then set the bind dns forwarding accordingly.
-----------OLD ARTICLE STARTING-------->>
I was tempted with the low price on vps these days, and it's my goal someday to create a multiplayer game.. err not multiplayer.. but online where people could play and compete with each other online.. ;)
any whoo..
the steps..
To manage this kind of things, let's use a more powerfull thing which is called Webmin. Download the debian package, and then setup Apache Virtual Hosts, and Bind Configuration from there.
side note: when installing bind to the VPS, we should set the DNS Server to 127.0.0.1 (localhost) and then set the bind dns forwarding accordingly.
-----------OLD ARTICLE STARTING-------->>
I was tempted with the low price on vps these days, and it's my goal someday to create a multiplayer game.. err not multiplayer.. but online where people could play and compete with each other online.. ;)
any whoo..
the steps..
- After you receive your username, password, and ip address, log in to you vps SSH by ussing putty
- Start by upgrading.. aptitude update && aptitude upgrade
- Next, install mysql aptitude install mysql-server mysql-client
- Enter you mysql username and password, don't lose it
- install the server aptitude install apache2 apache2-doc
Minggu, 25 November 2012
[c++]Void Ptr storing your pointer to classes
A quick note, if you do store your inherited class, and then store them to a void pointer. Later on you call a method which is "public" from the parent class, please remember to static cast your void ptr to the parent class
because:
to fix above situation, you should
..why?? dunno.. but it worth as a note.. well at least for me that is.. hehe ;) Cheers!
DerivedClass *dc = new DerivedClass();
void *ptr = dc;
..
..
some mumbo jumbo.. :)
..
..
void SomeFunction(void *ptr)
{
BaseClass *base = (BaseClass*)ptr;
//this will give you access violation which willl gives you a head scratcher.. i've been there.. :'(
}
to fix above situation, you should
BaseClass *dc = new DerivedClass(); void *ptr = dc //.. now it is safe to use //that SomeFunction
..why?? dunno.. but it worth as a note.. well at least for me that is.. hehe ;) Cheers!
Jumat, 02 November 2012
[c++] Function Pointers Snippet
Hi there, let the code speaks for it self.. ;)
// funtors.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef float (*MyFuncPtrType)(int, char *);
MyFuncPtrType my_func_ptr;
float test_func(int a, char *c)
{
fprintf(stderr, "in a function with argument: %d, %s\n", a, c);
fflush(stderr);
return a + 10.123f;
}
class functors;
typedef float (functors::*ClassMemFuncPtr)(int, char *);
// For const member functions, it's declared like this:
typedef float (functors::*ClassConstMemFuncPtr)(int, char *) const;
class functors
{
public:
virtual ~functors()
{
obj = 0;
}
void invoke()
{
(obj->*memx)(10, "Yeah!!");
}
void bind_x(MyFuncPtrType funcPtr)
{
x = funcPtr;
}
float invoke_x(int a, char* c)
{
return x(a, c);
}
void bind_memx(functors *obj, ClassMemFuncPtr mem_func)
{
this->obj = obj;
memx = mem_func;
}
float invoke_memx()
{
return (obj->*memx)(11, "Uh yeahh.. i'm invoked!!");
}
private:
MyFuncPtrType x;
ClassMemFuncPtr memx;
functors *obj;
};
class derived: public functors
{
public:
float derived_func(int a, char *c)
{
fprintf(stderr, "I got called with the following params: %d, %s", a, c);
return 1.01111f;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
my_func_ptr = test_func;
float a = my_func_ptr(10, "yohan");
fprintf(stderr, "%f\n", a);
fflush(stderr);
functors *base = new functors();
base->bind_x(test_func);
a = base->invoke_x(11, "pandewi");
fprintf(stderr, "%f\n", a);
fflush(stderr);
//testing member function..
derived *the_derived = new derived();
base->bind_memx(the_derived, static_cast(&derived::derived_func));
base->invoke_memx();
delete the_derived;
base->invoke_memx();
delete base;
return 0;
}
Kamis, 25 Oktober 2012
[Irrlicht]Working with files:Intro
Hi there! if any of you need a quick code snippet to work with file in Irrlicht:
//Reading file sample
io::IReadFile *f = App::Instance()->GetDevice()->getFileSystem()->createAndOpenFile("didum/dadam/anykindoffile.ext");
//this is how you get actual path (physical/not relative), it will return the input given to it if no actual path was found
io::path p = App::Instance()->GetDevice()->getFileSystem()->getAbsolutePath("didum/dadam/anykindoffile.ext");
//preparing a buffer to save the file contents
char *buffer = new char[f->getSize()];
long fl = f->getSize();
//read that file to the buffer
f->read(buffer, f->getSize());
//writing file sample
io::IWriteFile *wf = App::Instance()->GetDevice()->getFileSystem()->createAndWriteFile("savedname.saved");
wf->write(buffer, f->getSize());
wf->drop();
f->drop();
delete [] buffer;
Fair warning though.. i did not included the safe checking for the file exists etc.. i guess you know where to put them right ;)
Cheer!
Minggu, 21 Oktober 2012
[Irrlicht]Blender 2.6X as your game scenes editor?
Just a quick note for me to implement scene / level editor in the future,
You could generate your UVs, Images, Vertices, Faces (even triangulates them) through the python scripting library..
And by using blender's "Append / Link" along with "Custom Properties" , we should be able to load / re-use and do almost everything to compose our game world. Wouldn't it be great to have msvc express for the IDE, angelscript / lua as the scripting interface, and Blender as your modeler and game scene editor?
For the 'future me" here is a list of scripts function which will help you.. :p
- dont forget the 'dir' command! example: dir(bpy.data.meshes['mesh_id']
- bpy.data.images['IMAGE_ID'].filepath for retrieving physical location of the image file used as the texture
- bpy.data.libraries['LIB_ID'] for your external files..
- list(bpy.data.meshes["YOUR_MESH_ID'].vertices) this is an array of your vertices
- list(bpy.data.meshes[' YOUR_MESH_ID '].faces[1].vertices) this is the face, and the indexs of your vertices
- it is a bit longer to get this one.. but here it is.., to get the texture coordinates: bpy.data.meshes["YOUR_MESH_ID"].uv_textures['UVMap'].data[1].uv# with # being 1 to 4..
- a simple tutorial on wikibook : exporting scene!
Now there you have it.. a complete arsenal to represent a 3d world (vertices, faces, textures, texture coordinates, and transforms..) what? owh yes.. what about animation you asked? well.. for the time being, if you need an animated mesh, you should consider manually add them to your 'static' world ;)
cheers!
Kamis, 06 September 2012
XNA, .NET: Solving The located assembly's manifest definition does not match the assembly reference
Yup, ran across this one, which to the popular believe as the errors which every .net programmer should face. The problem arise when i tried to compile a new assembly version, and then when i compile/build old project, the project complains about The located assembly's manifest definition does not match the assembly reference. Tried to delete the assemblies, removing the references but to no avail.
Finally, i tried to modify app.config and then changes this line (yours might be similar)
<bindingRedirect oldVersion="0.0.0.0-1.4.0.0" newVersion="1.2.0.0"/>
Now the program compiles successfully. Hope to help someone else ;)
Ciaoo!
Finally, i tried to modify app.config and then changes this line (yours might be similar)
<bindingRedirect oldVersion="0.0.0.0-1.4.0.0" newVersion="1.2.0.0"/>
Now the program compiles successfully. Hope to help someone else ;)
Ciaoo!
Selasa, 04 September 2012
Win7 XAMPP, port 80 problem. Could not start xampp
I could not start xampp on my computer, i think i need to put the findings here. Just in case i need them again, or someone else having the same problem as i had
- Open your comand prompt and type netstat -ano
- Search for the line which is listening to port 80, note the PID
- If the PID is not 4 then you may have the solution right away. Go back to command and type tasklist
- Search for the PID, if it's Skype, you need to change the port by using the advanced configuration panel, if any other program, re-check if you need the program, if you don't need it, you may simply do a taskkill -pid [pid]
- You may restart your xampp now.
- Other area you might want to check :
- Disable IIS Service: World Wide Web Publishing
- Disable BranchCache Service
- SQL Server 2008 R2, turn of the Error Reporting Feature - If the PID mentioned earlier was 4, as the last resort you might want to do the following
- Open Device Manager
- View » Show hidden devices
- Under the tree-view, Expand Non - Plug and Play Drivers
- Search for HTTP and then disable it
- Do a reboot
**If you have trouble with printer spooling after this steps, you might want to change the default port by modifying the httpd.conf file and change the port 80 to something more unique to yourself , but after you change the port, say for example port 98 you need to access the local site using this : "http://localhost:98"
Update:
another way to try which one is using the port 80, use telnet
- If telnet client is not installed, install it by opening cmd prompt and then run it as administrator then type "optionalfeatures" without the quotes, and then find telnet client and then install it.
- Run telnet
- open host: o 127.0.0.1 80
- type : GET
- read the information there
Good luck All!! :)
Selasa, 26 Juni 2012
Some Library to ease your web-app development
I read some website, and i think i'm going to make my own note here, hope someone or someday we will find this usefull. This is a list of 'commonly' used javascript library when developing business application
- jQuery
Yep.. the famous jQuery.. hhe - jQuery treeTable plugin
A plugin which will render a tree-like table, table rows which have child for them.. that's a tree-table - jQuery contextMenu
Just do a "right click", and there you have it, a customized contextMenu for your web app - BeutyTips
The name says it all.. i guess.. - Editable and AutoComplete
Editable : any area of your web page is editable by clicking them. AutoComplete : FB/twitter like auto complete when you tag your friend - Color Picker
- jQuery numberFormatter
Entering the edit box makes the number goes normal, and leaving the edit box makes the number pretty.. 60000 => 60,000 - iScroll
IOS like scrolling? hmm eye candy.. - Mustache
Template-ing by using Javascript - Quicksand
Another eye candy.. i think iOS made some revolution here!! Shuffling ordering the divs! - JQGRID
Yep.. the mighty grid we all see everyday on our business application - Hotkeys
If you are here.. you should press cntrl-d (bookmark cubei pleaseee.. hhe) - jsTree
- Raphael
Small but powerful library to help you working with your vector drawings - gRaphael
do you need some chart? :)
That's it guys.. now go and invent an app! :D
c ya and God Bless!
Sabtu, 09 Juni 2012
KPR Bank Jabar :)
Tanggal 8 Juni 2012 merupakan tanggal akad kredit saya di Bank JABAR :) saya sungguh bersyukur karena 1 dari 3 dari target janji saya(Atap, Kendaraan, Tabungan) bisa saya penuhi buat keluarga saya.. hoho..
Nah, yang menjadi kejutan untuk saya adalah perhitungan bunga (walaupun sy tahu bahwa perhitungan bunga "floating" merupakan salah satu perhitungan yang cukup 'mengerikan') karena di tahun ke-2 cicilan KPR saya adalah (mungkin) sebesar 13.5%, dan lonjakan kredit bulanan menjadi agak sedikit 'lumayan besar' oleh karena itu, saya membuat sebuah excell spereadsheet yang mungkin bisa membantu rekan-rekan sekalian yang ingin menghitung cicilan KPR rekan (dikhususkan untuk bank JABAR)
Download file excell untuk menghitung KPR Bank Jabar - Prime Lending Rate (metode anuitas bulanan) bersangkutan, rekan-rekan bisa mendownload dari link berikut ini :
Semoga bermanfaat :D
Nah, yang menjadi kejutan untuk saya adalah perhitungan bunga (walaupun sy tahu bahwa perhitungan bunga "floating" merupakan salah satu perhitungan yang cukup 'mengerikan') karena di tahun ke-2 cicilan KPR saya adalah (mungkin) sebesar 13.5%, dan lonjakan kredit bulanan menjadi agak sedikit 'lumayan besar' oleh karena itu, saya membuat sebuah excell spereadsheet yang mungkin bisa membantu rekan-rekan sekalian yang ingin menghitung cicilan KPR rekan (dikhususkan untuk bank JABAR)
Download file excell untuk menghitung KPR Bank Jabar - Prime Lending Rate (metode anuitas bulanan) bersangkutan, rekan-rekan bisa mendownload dari link berikut ini :
Semoga bermanfaat :D
Langganan:
Postingan (Atom)