Bleadof’s world of tinkering

November 11, 2008

AT&T x86 assembly instruction reference

Filed under: Assembly,C,Programming,Studies,Thesis,Tinkering — Bleadof @ 19:11

The juice of this blog post is here: AT&T x86 assembly instruction reference can be found in the Appendix B. with the the title “Common x86 Instructions” from Programming from the Ground Up by Bartlett, J.

The actual process how I came about finding this bit of info was when I was reading Building Secure Software by Viega, J and McGraw, G in towards efforts of finishing my bachelor and master thesis on “Common faults in software which lead to a vulnerability”. The book is a brilliant as an entry level book for everyone working on software development and trying to think more securely when programming. Although hopefully my master’s thesis will serve this entry level of thinking secure while programming as well. Anyway, I was reading the BSS book and on the Stack Overflows chapter there’s this part where you’re told to use the gcc with -S flag to compile the C code to Assembly language and tweak it. So to be able to tweak it I wanted to understand what were the instructions in the Assembly language. I googled a bit to find AT&T instructions and that didn’t give me much until I finally found a question on comp.lang.asm.x86 news group which said that one would be in the Programming from the Ground Up book and there it was.

June 9, 2008

iSync not launching on Leopard 10.5.3.

Filed under: Os X — Bleadof @ 18:06

I had a problem for a while that I couldn’t launch iSync normally from /Applications, but it did still did work launching it from /Applications/iSync.app/Contents/MacOS/iSync . I knew this must be an issue for someone else as well so a little digging got me the anwser from the Apple Support discussion with title “iSync won’t open in 10.5.3.”.

Fix iSync launching problem
  1. Drag iSync from Applications to Desktop.
  2. Drag it back to Applications.
  3. Try launching it normally.

March 14, 2008

Great Assembler programming book

Filed under: Assembly,Programming,Thesis,Tinkering — Tags: , , — Bleadof @ 14:03

I found this brilliantly written Assembler, which I’m reading for my thesis, book online a while back already but I thought it might worth mentioning now. It’s called “PC Assembly Language” and its author is Paul A. Carter. It can be downloaded in PDF and PostScript so I suppose most of the people can read it. I don’t about the accessibility of a PDF or PS so I won’t say everyone can read it, but the text itself is very clear and easy to understand. It also offers good examples. I think it’s a bit sad that it’s written in Intel syntax, but I suppose that’s unavoidable. I’ve been reading mostly AT&T syntax which is a bit different, but you get used to Intel syntax fairly fast.

Now I’m off to a meeting…

July 5, 2006

Ha! I defeated the evil Chinese spam bot!

Filed under: Apache,Tinkering — Bleadof @ 10:07

I’m been spammed by this Chinese spam bot. It tries to post on my non-existing guestbook by loading /?guestbook&action=write and generating dummy hits on my wordpress blog front page. Today I decided to stop that.

Ingredients

  • Apache
  • Apache mod_rewrite module
  • .htaccess love

Steps

  • 1. Create, if you don’t already have, a .htaccess file in your document root (ie. mine is /home/username/public_html/)
  • 2. Edit your .htaccess file and add following lines


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^guestbook&action=write$
RewriteRule ^index.php$ / [G]
</IfModule>

  • 3. Save

Now you are done and that url returns now 410 error code, which means the resource is gone.

July 3, 2006

Work and ajax

Filed under: PHP,Programming,Tinkering — Bleadof @ 11:07

Well, I was asked to do a suggesting text-box for one field in the UI so that it would be easier to type in the info which apparently is the one they make most of the errors. I did it with some script.aculo.us love. It’s nice that they have pretty good docs.

So basically what you have to do is include


<head>
...
<script src="scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="scriptaculous/src/scriptaculous.js" type="text/javascript"></script>
...
</head>

Then add


<label for="signum">Signum</label>
<input id="signum" name="item[signum]" type="text" />
<div id="signumhint" class="signumhint"></div>
<script type="text/javascript">
// <![CDATA[
new Ajax.Autocompleter("signum","signumhint","AjaxController.php?get=signum", {})
// ]]>
</script>

Then add process the request, this is from my AjaxController.class.php draft


function handleRequest($post, $get) {
if(count($post) <= 0 && count($get) <= 0) {
return null;
}
if($post['item']['signum'] != null) {
$signums = $this->getSignums($post['item']['signum']);
}
$this->makeUnorderedList($signums);
$this->printList($signums);
}
function makeUnorderedList($results) {
$unorderedList = Array();
$unorderedList[] = '<ul>';
foreach($results as $result) {
$unorderedList[] = '<li>'.$result.'</li>';
}
$unorderedList[] = '</ul>';
return $unorderedList;
}
function printList($unorderedListArray) {
foreach($unorderedListArray as $item) {
print $item;
}
}

You also need to edit your css so that the hints div will look nice. It’ll be populated data. In here the hints field css looks like this:


.signumhint {
position: absolute;
font-size: 0.8em;
background-color: white;
left: 8em;
z-index: 100;
}
.signumhint ul {
list-style-type:none;
margin:0px;
padding:0px;
}
.signumhint ul li.selected { background-color: #ffb;}
.signumhint ul li {
list-style-type:none;
display:block;
margin:0;
padding:0;
height:32px;
cursor:pointer;
}

And voila, you’re good to go.

Ajax screenshot

June 21, 2006

Oracle instant client basic, PHP >= 4.3.9 and Centos

Filed under: Jyväskylä University Library,Tinkering,Work — Bleadof @ 14:06

Whoop-di-fucking-doo!, I didn’t know that getting Oracle database connectivity in PHP 4.3.9 could be this hard to get working. Here are the tricks.

  • Find oracle-instantclient-basic-10.2.0.2-1 as RPM.
  • Find php-oci8-4.3.9-3 as RPM.
  • Install them, restart apache and you’re done.

Sounds easy? Well it’s not. Reason: those packets were hard to find in the first place. Why? Apparently oracle doesn’t want the instant client to be found as rpm. Most of the howtos you’re told to compile PHP from tarball and that’s just not the way you want it to be done. Anyhow I succeeded and now i can use AdoDB to connect oracle database. You know that oci8 is working when you check phpinfo() for oci8 module enabled

June 12, 2006

PHP4 OOP and references

Filed under: PHP,Programming,Tinkering — Bleadof @ 13:06

So today I decided check PHP4 OOP quirks. So now I know for sure how my code is going to behave. I wasn’t really sure how the PHP4 behaves with references so I did a test.

class ReferenceTest {

  var $reference;

  function ReferenceTest() {
    $this->reference = new Reference();
  }

  function getReference() {
    return $this->reference;
  }

  function &getReferenceReference() {
    return $this->reference;
  }
}

class Reference {

  var $var;

  function Reference() {
    $this->var = "";
  }

  function setVar($var) {
    $this->var = $var;
  }

  function getVar() {
    return $this->var;
  }

  function &getVarReference() {
    return $this->var;
  }

}

$rt =  new ReferenceTest();
$ref = $rt->getReference();
$ref->setVar("bar");
$ref2 =& $rt->getReferenceReference();
$ref2->setVar("baz");
$ref3 =& $rt->getReferenceReference();
$varRef =& $ref3->getVarReference();
$varRef = "baf";
$ref3->setVar("foo");

print "ref:".$ref->getVar()."<br/>";
print "ref2:".$ref2->getVar()."<br/>";
print "ref3:".$ref3->getVar()."<br/>";

Do you know what is the output? Here’s the anwser.

June 9, 2006

Last.fm love \o/

Filed under: Jyväskylä University Library,Tinkering,Work — Bleadof @ 09:06

I presume that I’m not the only one who has noticed the lovely features of the Last.fm player… It’s so cool that you’re able to listen your favorite music still at work and not actually being forced to bring the music with you or start streaming from home.

At the moment I’m subscribed because they’ve been messing around with my charts. This means I’ve more radios available than as a normal user. I’ve been mostly listening my personal radio but sometimes it’s nice to hear something new and I listen my neighbour radio. Fun \o/

Now some work… Started to poke around some on the old system. It’s totally crappy. There’s a lot of things which could easily go to The Daily WTF, but I can’t be bothered to submit them. I think I’m suggesting that we throw the old system to trash and do a proper one with OO PHP. Would be nice to actually just use Python but I guess it’s not possible.

We’ll see what happens…

April 27, 2006

PHP4 and error handling…

Filed under: PHP,Programming,Tinkering — Bleadof @ 00:04

I’m working on a project at the moment. Doing stuff for company called Boogie Beat Oy. I’m doing a whole rewrite for their system-of-a-thingie… I decided to start using proper OOP-style. Pretty interesting thing to do with a language which I’ve used only for procedural programming. So I stumbled upon some of the problems which PHP4 has with objects and error handling.

set_error_handler(“yourErrorHandlerFunction”)

I’m used to do objects with Java andJava’s way of handling errors which is quite nice and flexible.

In PHP4 the built in way of raising errors is:

trigger_error("Error message", E_USER_ERROR)

This is not the actual problem but the:


function my_errror_handler($errno, $errstr, $errfile, $errline, $errcontext) {
switch($errno) {
case E_USER_ERROR:
...
}
}
$old_error_handler = set_error_handler("my_error_handler");

Which would be just brilliant if you could say…


$old_error_handler = set_error_handler("$object->errorHandler");

…and when you can’t. You’re basically bound to do like this:


require('Object.class.php');
$object = new Object();
function __errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
global $object;
$object->errorHandler($errno, $errstr, $errfile, $errline, $errcontext);
}
$oldErrorHandler = set_error_handler("__errorHandler");

Which is kind of sucky way of doing things… Basically what I’ve done is that my errorHandler will store all of the errors in an Array and I can just ask for the errors when I need to get them and it’ll return an Array of the errors. So I can easily foreach the errors in a Smarty template and not have to worry about the errors been print out anywhere or anytime they are triggered.

Took me some time to figure out a way to point to the function of this errorHandler class I wrote. This implementation is a hack but it works! It makes it easy to localize the errors if wanted because you can modify the errorHandling as you wish…

Here’s few documents where you can find more information about the error handling in PHP4

Oh well, that’s about it… Probably more about this later…

September 22, 2005

Webcollage XScreenSaver

Filed under: Tinkering,Ubuntu Linux — Bleadof @ 14:09

*grins* This one took some time today… It has dependencies which aren’t told you before you run it from the console *shrug*. This is how I got it to work in Ubuntu Breezy Badger (installed the preview, but now I’ve updating it from the devel repo):

  • At first, it uses /usr/dict/words as its default source for search words: In Ubuntu the one is in /usr/share/dict , but no it’s not the words file you are looking for. It’s either /usr/share/dict/british-english , /usr/share/dict/american-english or what ever language you want it to use.
  • You can set this one from the System->Preferences->Screensaver->Select WebCollage screensaver->Settings…->Advanced >>->Command line
  • It propably says: webcollage -root . Replace it with: webcollage -root -dictionary /usr/share/dict/british-english (or whatever language you want it to use).
  • After this click OK
  • Then go to System->Administration->Synaptic Package Manager
  • Install netpbm and libjpeg-progs packages
  • There you should be set to go if you have internet connection ;) Now you can just click preview and if images start to appear, you were succesful.
Older Posts »

Powered by WordPress