by Jamsi on February 3, 2010
I recently had issues with an outlook error “0X80040201″ and for the life of me I couldn’t fix it.
However after much distress I was able to uncover what the problem was. I recently went from an Exchange 2007 environment to a IMAP environment and hence some of my contacts were corrupted. If I tried to send an email to anyone from my old exchange contact list – the email would fail; hence the error 0X80040201.
Simply creating new contacts in Outlook for the people I wanted to send emails too, fixed this issue!
by Jamsi on December 22, 2009
Is it just me or is Subsonic the topic of discussion right now? 
I had a need to retrieve the last ID that had been generated in a table; that being, the last “auto increment” ID of a table.
The following example worked a charm using Subsonic and activerecord.
1
2
3
4
5
| var fetch_ref_id = contract.All().OrderByDescending(c => c.id).Take(1).ToList();
if (iRef_new_id != null)
{
iRef_new_id = fetch_ref_id[0].id;
} |
As you can see, it creates a new list (noted by the ToList()) by connecting to the table “category”, it then selects all results (All()) and then orders the list by Descending and finally, the take(1) simply takes the top record.
I then whack the result (if you have a column called id) into a integer.
by Jamsi on December 22, 2009
So the subsonic documentation sucks. If you’re new to activerecord, linq and subsonic in general; you’ll find it fairly hard to construct basic queries. However once you’ve got it under control, it’s a piece of cake.
To sort your table using activerecord, use the following examples;
To sort ascending by a column called name
1
| var categories = category.All().OrderBy(c => c.name); |
To sort descendingby a column called name
1
| var categories = category.All().OrderByDescending(c => c.name); |
You can then just bind to your gridview/dropdown list or whatever you like.
1
2
3
4
5
| if (categories != null)
{
drp.DataSource = categories ;
drp.DataBind();
} |
by Jamsi on December 5, 2009
So for some strange reason, it just took me a good 20minutes to find an article on Google to tell me how to reset the Mediawiki admin password (because yes .. I forgot it). Some articles mentioned using phpMyAdmin to edit the users table directly, however the password is stored in a TinyBLOB format – so I had no clue.
Luckily I finally found a way to reset the Admin password!
You’ll need shell/SSH access for this procedure to work.
1) Login to your media wiki installation
2) Then type the following;
1
2
| cd maintenance
php changePassword.php --user=Admin --password=tada321$ |
This will change the “Admin” user’s password to “tada321$” ! I then highly suggest you login to MediaWiki and change the password to something more secure/familiar
by Jamsi on November 26, 2009
So I used to be one of those old “tables are still cool for layouts” kinda guys and proceeded to use tables for just about anything web related that I touched. But there came a moment where I decided .. you know what, everyone else is raving on about this CSS layout business, so I set out to see what could be done. Now I came across quite a few tutorials on Google; and I wanted to outline the best ones that I came across!
1) Creating a CSS layout from scratch
This is pretty much my favourite CSS tutorial .. which pretty much takes the scenario of cutting and slicing a web design into an actual functional website using CSS.
2) CSS Template Layout
This tutorial goes into a bit of detail and lacks images along the way (to break up the text), however everything just made sense whilst reading this tutorial.
3) CSS Tutorial: Layout a page using CSS
A little more detailed than the others, this tutorial aims to keep it simple; but yet goes into detail about each element and tag reference. The thing to remember, is that learning CSS is like learning to ride a bike – once you know it, it’ll stick – trust me.
by Jamsi on November 25, 2009
I wanted to demonstrate the complete and utter power of SubSonic Activerecord’s toolset. Pretty much, its an easy to use querying engine which automatically creates objects that you can use within your ASP.NET project. You can use LINQ querying if you like, or you can use the SubSonic preferred way as demonstrated below;
Want to bind a gridview?
1
2
3
| var categories = category.All();
gvList.DataSource = categories;
gvList.DataBind(); |
Boom. Done.
What about deleting a record?
1
2
3
| int iLineID = 1;
category delCat = category.SingleOrDefault(x => x.id == iLineID);
delCat.Delete(); |
Too easy right?
What about adding a new record?
1
2
3
| category newCat = new category();
newCat.name = "Dummy category name";
newCat.Add(); |
How easy is that? Go grab SubSonic now!
by Jamsi on September 17, 2009
So what the heck is this Bootstrap PHP thing anyway?
Bootstrap means to load a small program that eventually calls the desired program into the computer, similar to an operating system being called by a BIOS program. The word bootstrap also has different meaning in different fields like science, medical, etc.
With regards to computer technology, “bootstrap PHP code” means creating a bootstrapper that handles all the dynamic requests coming to a server and apply the true MVC (Model View Component) framework so that in future you can change the functionality for each unique component or application without changing the entire code or application.
Below you will find some steps to get the process started;
1. Go to the home directory of your website and create a “Website_Src” folder and put all your application files inside it.
2. Inside the “Website_Src” directory, create an index.php file and add the following code to it.
1
2
3
4
5
6
7
8
9
10
11
| class index
{
public function _construct()
{
}
public function index($args)
{
echo 'This is default index page visible to every request that can’t be routed';
}
} |
3. Now, create a second file and name it “welcome.php” & add the following lines of code to it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| class welcome
{
public function _construct()
{
}
public function index($args)
{
// redirecting it to test function()
$this->test($args);
}
public function test($args)
{
if (isset($args[0] )) echo $args[0];
if (isset($args[1] )) echo ' '.$args[1];
}
} |
4. Now, create a “.htaccess” file (if you don’t already have one) and add the following code to it. This will allow only specific characters in URI.
1
2
3
4
5
| Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-_/ ] )$ index.php?route=$1 [L,QSA] |
5. Finally, paste the following code into you “index.php” file present in the “public_html” directory and test your bootstrap php code by clicking on your website link say: http://www.mywebsite.com/welcome/testing/hello
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| // This bootstrap php code will work only with php5 with no template engine.
// Stops from reporting any error
error_reporting(0);
// This is the folder where all your application files are present.
define('CLASSDIR', ' Website_Src ');
// Absolute path to the source files, just one level behind public folder
define('BASEDIR', @realpath( dirname (__FILE__).'/../'.CLASSDIR).'/' );
// Automatic loading of classes by using a function so that you can get rid of all include() calls.
function _autoload($class)
{
$file = BASEDIR.$class.'.php';
if (!file_exists ($file) )
{
echo 'Requested module ''.$class.'' is missing. Execution stopped.';
exit();
}
require($file);
}
// breaking requesting URI to parts & retrieving the specific arguments, methods & class
$route = '';
$class = '';
$method = '';
$args = null;
$cmd_path = BASEDIR;
$fullpath = '';
$file = '';
if (empty($_GET['route']) ) $route = 'index'; else $route = $_GET['route'];
$route = trim($route, '/\');
$parts = explode('/', $route);
foreach($parts as $part)
{
$part = str_replace('-', '_', $part);
$fullpath .= $cmd_path.$part;
if (is_dir($fullpath))
{
$cmd_path .= $part.'/';
array_shift($parts);
continue;
}
if (is_file($fullpath.'.php') )
{
$class = $part;
array_shift($parts);
break;
}
}
if (empty($class) ) $class = 'index';
$action = array_shift($parts);
$action = str_replace('-', '_', $action);
if (empty($action) ) $action = 'index';
$file = $cmd_path.$class.'.php';
$args = $parts;
// now that we have the parts , let's run a few more test and then execute the function in the class file
if (is_readable($file) == false)
{
echo 'Requested module ''.$class.'' is missing. Execution stopped.';
exit();
}
// load the requested file
$class = new $class();
if (is_callable(array($class, $action) ) == false )
{
// function not found in controller , set it as index and send it to args
array_unshift($args, $action);
$action = 'index';
}
// Run Action
$class->$action($args);
}
?> |