Recent Updates Page 5 RSS Toggle Comment Threads | Keyboard Shortcuts

  • webscriptz 23:41 on 16/04/2010 Permalink | Reply
    Tags: allocation, by reference, c, c programming, char, double pointers, malloc, pointer to pointer, realloc   

    C programming: dynamic keyboard allocation with pointer to pointer 

    Something I’ve written for a project I have to do for school, it’s without bugs at least on visual studio 2008.

    The little story about this code:

    This is a dynamic memory allocation function for text entered by the user.

    You give the addresses from pointers to memory placements to the function, it only return errors by value, everything else is returned by reference (pointer to pointer).

    **string is the string pointer
    **cntrChar is a counter for the number for characters

    **cntrChar is used in another function to verify that the chain of characters entered, is longer then 1 because ‘\n’ is also seen as character so you need more then 1 to pass that test normally but it depends on the requirements of the program created.

    
    int keyboardInputString(char **string, int **cntrChar){
    
    	char c, *iString;
    
    	int i=0;
    
    	iString = (char*)malloc(sizeof(char));
    
    
    	if(iString != NULL){
    
    		do{
    
    			c = getchar();
    
    			*(iString+i)=c;
    
    			i++;
    
    
    			iString = (char*) realloc (iString, (i+1) * sizeof(char));
    
    
    			if(iString == NULL)
    
    				return 1;
    
    
    		}while(c != '\n');
    
    
    		*(iString+i-1)='\0';
    
    
    		*string = iString;
    
    		*cntrChar = &i;
    
    
    		return 0;
    
    	}
    
    	else{
    
    		return 1;
    
    	}
    
    }
    

    exemple:

       if(strcmp(**string, "exit") && **cntrChar >1)
         //your code here
    

     
  • webscriptz 09:00 on 02/04/2010 Permalink | Reply  

    Windows ate my thumbdrive 

    Yesterday was disappointing and frustrating.

    Visual studio freaked out which resulted in my project becoming inaccessible from my thumb drive and not long after that the partition table was destroyed, resulting in my thumb drive being of the RAW format.

    I searched and found some recovery software but nothing that wanted to recover my partition table so I had to result to formatting and recovering data afterwords. Unfortunately I got to save every file that was on the drive except for my project which visual studio had obviously eaten up.

    Thanks again Microsoft, nice tool, if only it wasn’t this hungry! Come to think of it almost everyone had problems with visual studio, maybe it wanted revenge for the bad code that we write. :P

     
  • webscriptz 18:57 on 25/02/2010 Permalink | Reply
    Tags: tempalte, , ,   

    Yii themes 

    This was actually fun, a first, i have to admit. Normally when i do convert a template to a theme, i is time consuming, in Yii after some rudamentry settings (2 actually), you’re on your way.

     
  • webscriptz 00:39 on 22/02/2010 Permalink | Reply
    Tags: annoyed, , , , , ,   

    Annoyed…with coding 

    I’ve been coding away all week, that is between my other jobs at home :P

    In all my ‘wisdom’ and persistence i made a small app with Yii which stores data in an array and serializes it into a db, and a basic CRUD, a proof of concept to see if the framework was capable of doing this and in the fastest way possible.

    No problem so far, getting it is simple, but apparently you Yii doesn’t permit everything. So you need a $temp variable to store the model data in, suffice to say that it isn’t really the shortest route to take nor in my opinion the fastest bus alas I have to do with it. This little app of not more then a 60 lines of code took me four days, four damn days to figure out the error,  honestly if we have methods to ‘save space’ in your coding why not permit them?

    I’m not going to bother everybody with my nagging so, I’ll stop here.

    For those who want to see the topic on the yii forums.

     
  • webscriptz 23:47 on 20/12/2009 Permalink | Reply
    Tags: , , , , , , , ,   

    YII framework configuration 

    I’m toying with the Yii Framework for some time now and even if i cost me a lot of anger and frustration in the beginning I’m starting to like it more and more, alas I do have to say that the documentation isn’t always that clear and for someone who begins or who’ll write some large applications the configuration file can be a hassle so here’s my solution:

    Brake down the configuration file in multiple files, this will give you some speed disadvantage and some will  saying that I’m raping Yii framework purpose for speed but at least to me it seems more clear

    This is the protected.config/main.php

    dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'WEBSITENAME',
    'modules'=>array(
    'users'=>array(
    //sub modules in the module users
    'modules'=>array(
    'messaging',
    'profile',
    'dashboard',
    )
    ),
    'about',
    'forums',
    ),
    // preloading 'log' component active loading
    'preload'=>array('log'),
    
    // autoloading model and component classes lazy loading
    // I make the difference between CformModel and CActiveRecord
    'import'=>array(
    'application.models.*',
    'application.models.forms.*',
    'application.models.database.*',
    ),
    
    // application components
    'components'=>array(
    // enable cookie-based authentication
    'user'=>array('allowAutoLogin'=>true),
    
    // data relinquished to database.php
    // for easy access and usability as also for the future
    // installation procedure, it's less to write to a file
    'db'=>include(dirname(__FILE__).'/database.php'),
    
    // for a better overview we exculded url routes to a seperate file
    'urlManager'=>include(dirname(__FILE__).'/routes.php'),
    
    //authentication component needs data from db for CdbConnection
    'authManager'=>array(
    'class'=>'CDbAuthManager',
    'connectionID'=>'db',
    'defaultRoles'=>array('authenticated', 'guest'),
    ),
    
    //security measures
    'request'=>array(
    'enableCsrfValidation'=>true,
    'enableCookieValidation'=>true,
    ),
    ),
    
    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    // uncomment the following if you want static params in the application
    //'params'=>array(include(dirname(__FILE__).'/params.php'))
    );

    database.php

    'CDbConnection',
    'connectionString'=>'mysql:host=localhost;dbname=mysql',
    //'connectionString'=>'pgsql:host=localhost;port=5432;dbname=mysql',
    'username' => 'root',
    'password' => '',
    );
    ?>
    

    routes.php

    'path', // path or get
    'urlSuffix' => '', //.html .whateverextentionyouwant
    'showScriptName' => true,
    'rules'=>array(
    'users/recovery/perimeterSecurity/'=>'users/recovery/perimeterSecurity',
    ),
    );
    ?>
    

    param.php

    //nothing in it at the moment

     
    • Cherry 10:58 on 30/12/2009 Permalink | Reply

      Hi,I’m trying Yii now.Almost everything could be done with Yii.But all the components,those how I configure ,will run.Something ,like,DB session…
      well,my english is so poor!

    • webscriptz 03:32 on 01/01/2010 Permalink | Reply

      I’m a bit torn between speed and programming luxury and because sometimes Yii is poorly documented, nice example code but not all the options are given actually sometimes very few.

      I’m currently doing models and testing them in Yii and i can’t get my head really around it, Codeigniter was really easy to use in the model logic but now what’s the logic, Model driven or controller driven because of the AR layer and the model sql query which seems implemented in the controllers. I thought controllers were just a gateway between view and model because it’s the model that usually contains all the logic not the controller.

  • webscriptz 23:51 on 11/11/2009 Permalink | Reply
    Tags: 2012, fun, , laugh, , people, philosophy, skeptic,   

    2012: a parody at the end 

    Delicious.com served this last thing and unfortunately i can’t keep my skepticism to myself;  please read it first, it really collects two point of views and all the events concerning.

    It’s funny some days back people started talking again, after what seems a really long time in my opinion, of the end of the world / life.  It is interesting to see what people (we) fear most in our lives and death, I think, is  the subject of choice.  However fear of the unknown, or in other words fear of the future, fear of what has to come on which we do not have any control. We do not control the evens nor the outcome, we don’t even know what will happen at all and that’s the fear we have. We swear to everybody that we have ‘full control’ of our lives but in reality we are but in control for a minor part. We drive the car but don’t reach the pedals so to speak.

    Doomsday / Judgment-day / Armageddon / end of ….who knows ?

    Every religion has an doomsday scenario build it, you basically get the complete package, creation – life – destruction ain’t that cool? However the people some hundreds of years back were quit ingenious because they didn’t set a date for doomsday so their bound to have it right…it will come someday.

    Somewhere people need fear, why? Because we need to have excuses to do things stupid or just without a good explanation. Saying today may be the last day they live.

    People tend to like predictions, lots of people make them and even more believe them.  And after it we don’t hear anything anymore from them. What also can be seen really funny is that every prediction has a fixed date, like we’re going to write it down in an agenda.

    Why 21 Dec 2012?

    “Look Ma….now we can write it down in our agenda! Ain’t that cool?”

    Because the Mayan calendar ends then, right nice, good reason keep going genius. Maybe they didn’t know how to count further then 5125 and it’s only  reference is one stone, if it was really that big you would see it all over their temples besides did the archaeologists and translators made the right conclusion, it wouldn’t be the first time we would have to rethink our conclusion(s) on facts.

    Before 1975 people also thought that the world would end, and hmmm well what do we know, hey we’re in 2009 weird….doesn’t it? I don’t feel dead, do you or even can we say we’re alive or that we’re dead or what if we’re on an other plain of existence?….scares the crap out of me and you?

    Why would this or that happen to us?

    “A punishment or god”, “it’s fate”, “it is because it has to be like that”

    Honestly, there ain’t a bigger thrill then scaring the life out of someone else now is there? We give millions of reasons why and it all comes down to one thing, because we don’t understand it (yet), therefor it’s a good enough reason. it’s a bit like with myths in ancient Greece; That what we cannot yet comprehend we explain by something even more bizarre.

    We’ll in any case….see you on Dec 21st 2012 (evil laughter) :P

    P.s.: check the sources in the other website (own responsibility) but it’s fun to read.

     
  • webscriptz 23:09 on 24/09/2009 Permalink | Reply
    Tags: , , , , , , , register,   

    Register & Yii projects 

    So, I think ti’s time for some updates on the website.

    I has been a bit wild the last 3 weeks. School has started yet again and I had a project to finish not to mention that i’m starting to see through the Yii framework structure. I’ve been writing diagrams for different project that I have in my head too and that takes a lot of time. Besides figuring out how I want the database to be and my database system had schifted, alto mysql is the favorite, a friend encouraged that i take a look to postgresql. Yii has given me a hard time to basically because it’s been a bit of a struggle to change coding methodes in function of Yii and then I don’t start talking about the RBAC system it has build-in. It took every neuron to understand everything form begin to end. Models was also something, Yii has two model types and the active records model is something to understand, I was a bit lost at how I would have to write my own AR functions but thanks to the forums I got that figured out too. All in all everything is good at the moment.

    I’ll be uploading some pictures of the system I wrote recently so you can get some sneaky peaks at it but unfortunately it won’t be open source system.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel