magic

How can I obtain file meta information in Perl?

I'm looking for a module or some way to obtain the information of the content of a file. The same that the linux "file" command does, but in Perl language. Thanks. ...

When talking about programming languages, what is the definition of Magic?

The word "magic" gets thrown around a lot here in contexts like "language X just has too much magic", or "platform Y generally avoids magic". However, it seems the term is pretty poorly defined, something people know when they see it. For example, Java is reputed to contain very little magic, but its garbage collector hides a lot from ...

Autoload in Python

In the past I've used perl's AUTOLOAD facility for implementing lazy loading of symbols into a namespace, and wanted the same functionality in python. Traditionally the closest you appear to be able to get is to use a class and a __getattr__ class to achieve this sort of thing. However I've also tried rummaging around in sys.modules, a...

Validation in my CakePHP seems disabled

I'm following the blog tutorial on CakePHP website, but validation doesn't work and i don't understand why, because i'm using the blog tutorial code. I'll report directly from my files anyway... MODEL class Post extends AppModel { var $name = 'Post'; var $validate = array( 'title' => array( 'rule' => 'notEmpty' ...

C++ compile time program wide unique numbers

I've come up with a solution to a problem but I'm not sure if it'll always work or just on my compiler. First, the problem: I've noticed in a number of situations it's desirable to have a template class that gets reinstantiated each time it's used even when given the same types (say your template class has static members that are initial...

How to force table select to go over blocks

How can I make Sybase's database engine return an unsorted list of records in non-numeric order? ~~~ I have an issue where I need to reproduce an error in the application where I select from a table where the ID is generated in sequence, but the ID is not the last one in the selection. Let me explain. ID STATUS _____________ 1234 ...

why can't php just convert quotes to html entities for mysql?

PHP uses "magic quotes" by default but has gotten a lot of flak for it. I understand it will disable it in next major version of PHP. While the arguments against it makes sense, what I don't get it is why not just use the HTML entities to represent quotes instead of stripping and removing slashes? After all, a VAST majority of mySQL is ...

Given an input and desired output, figure out the needed transformation.

I want a program that does what I said in the title. I realize that this is a pretty vague problem. I also realize that figuring out how to transform any input into any output is nearly impossible, but it seems like handling some simple cases should be feasible. To provide a concrete example (in Python): >>> def find_transform(star...

Is chars[4] and 4[chars] the same in C? Why?

I've read this and don't believe it :) I've no compiler here to test. ...

Magic quotes on older and new versions of PHP

this code is supposed to ensure that clean code gets to the database it is supposed to work in earlier versions of PHP (earlier than 4.3.0) and later versions of php (older than 4.3.0) it works well because the data gets to the database without a problem but i get an error on the browser $menu_name = mysql_prep($_POST['menu_name']); ...

Python on Rails?

Would it be possible to translate the Ruby on Rails code base to Python? I think many people like Python more than Ruby, but find Ruby on Rails features better (as a whole) than the ones in Python web frameworks. So that, would it be possible? Or does Ruby on Rails utilize language-specific features that would be difficult to translate...

Why does this program *NEED* MsgBox?

Long story short: I'm trying to write an app that'll dump IE's history to a text file. Because I am lazy, I went searching for a preexisting library and found this beautiful project to build from: http://www.freevbcode.com/ShowCode.asp?ID=6702. Only, I'm stuck... I finally got the program to dump the history, but it ONLY WORKS if I pu...

Touch events with Magic Mouse and iPhone Simulator

I observe that with the iMac magic mouse, while using the iPhone simulator, if: a) the active view has an object in the center of the iPhone screen which is capable of generating touch events, and b) the iMac operator accidentally or otherwise drags their finger(s) across the magic mouse surface in a way which would normally be used for...

count file rows C#

i want to know how much lines i have in my file, how can i do it in a simple way( i mean, not to go through on all over the file and count each line) is there a command for that? ...

compiling libmagic statically (c/c++ file type detection)

Thanks to the guys that helped me with my previous question. (linked just for reference) I can place the files fileTypeTest.cpp, libmagic.a, and magic in a directory, and I can compile with g++ -lmagic fileTypeTest.cpp fileTypeTest. Later, I'll be testing to see if it runs in Windows compiled with MinGW. I'm planning on using libmagic ...

C Memcpy in reverse

I am working with audio data. I'd like to play the sample file in reverse. The data is stored as unsigned ints and packed nice and tight. Is there a way to call memcpy that will copy in reverse order. i.e. if i had 1,2,3,4 stored as ints in an array could i memcpy and magically reverse them so i get 4,3,2,1 ...

Why is there so much "magic" in Perl?

I'm looking through perlop and perlsub pages of the Perl manual. There are many references about "magic" and "magical" here (just search any of them for the "magic"). I wonder why is Perl so rich in them. Some examples: print ++($foo = 'zz') # prints 'aaa' printf "%d: %s", $! = 1, $! # prints '1: Operation n...

How does assignment of a function as a class attribute become a method in Python?

>>> class A(object): pass >>> def func(cls): pass >>> A.func = func >>> A.func <unbound method A.func> How does this assignment create a method? It seems unintuitive that assignment does the following for classes: Turn functions into unbound instance methods Turn functions wrapped in classmethod() into class methods (actually, this i...

C# 4.0 - Does calling a protected method on a dynamic object call TryInvokeMember() ?

In C# 4.0, there is a new DynamicObject. It provides a "magic method" TryInvokeMember() that gets called when trying to call a method that does not exist. http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.tryinvokemember%28VS.100%29.aspx What I would like to know is if TryInvokeMember() gets called when trying to ca...

Incompatible magic value 1008813135

I am writing a Java applet and embedding it in a web page. It used to run Mac and Windows in different browsers without problem. I was using NetBeans on the Mac to build the .jar file the applet used. For some reason or another I decided to load the project on the Windows' NetBeans - I started getting the following error on the Windows ...