tricks

How to generate a compilation error when pointer types differ?

How do I write a macro CHECK(a, b) that generates compilation error when the two pointers a & b have different base type. CHECK((int*)0, (char*)0) -> compilation error CHECK((int*)0, (int*)0) -> works I'm looking for some C89 code, but C99 + gcc extensions will also do. ...

How to Set mouse cursor position to a specified point on screen in C#?

How to Set mouse cursor position to a specified point on screen in C#? am i must hacke the motherboard buffer that receive the mouse and keyboard coordinates and presses ??? is there another one to do clicks or i am imagine ??? ...

How do I show sprites in the border on C64?

I've seen cool C64 demos showing sprites in the border area of the screen. It shouldn't be possible; I think they managed to fool the graphics chip somehow... How exactly did they do it? ...

Possible to disable flash element?

I'm trying to do something unusual. I promise it has a purpose. I'm 90% sure it can't be done, but wanted to double check with geniuses. Is it possible to have an object/embeded .swf in the page, let it be displayed, but do not allow any interaction with it. As an example, can you somehow change the youtube embed code to display the pla...

Fast modulo 3 or division algorithm?

Hello is there a fast algorithm, similar to power of 2, which can be used with 3, i.e. n%3. Perhaps something that uses the fact that if sum of digits is divisible by three, then the number is also divisible. This leads to a next question. What is the fast way to add digits in a number? I.e. 37 -> 3 +7 -> 10 I am looking for somethin...

Practical and useful coding tricks that help web developers save time?

I'm a php web programmer. I want to know if there are common web problems that web programmers face for which there are unorthodox and effective solutions. As an example, I'm making a simple website of user generated profiles. A user can store a whole bunch of information that range from first high school to when he first went to a ba...

Guidance, tips/tricks for larger scale php development.

Hi A project that I maintain and develop in asp.net so far has over 500 c# files (including code behind), 150 aspx, dozens of web controls, masterpages, split over various projects; web, business, cms. There are other projects that are accessed as web services (FYI developed mostly in Java by other teams). This current project is hoste...

javascript tricks. Why (a,b,c) => 5

. var a,b,c = function() { return 5; }; Variables a and b is undefined, c is function, why when we do this (a,b,c)() we have 5 ? ...

about ruby range?

like this range = (0..10) how can I get number like this: 0 5 10 plus five every time but less than 10 if range = (0..20) then i should get this: 0 5 10 15 20 ...

How to access hidden template in unnamed namespace?

Here is a tricky situation, and i wonder what ways there are to solve it namespace { template <class T> struct Template { /* ... */ }; } typedef Template<int> Template; Sadly, the Template typedef interferes with the Template template in the unnamed namespace. When you try to do Template<float> in the global scope, the compiler...

Cross Platform Tips, Tricks & Gotchas

If you've worked on a cross platform development project what advice do you have for someone (like myself) considering starting one? Examples: What worked? What didn't? What problems did you run into and how did you solve them? Did you aim for consistent appearance and functionality across all platforms or try to take advantage of each...

WPF: Replace the XAML of a page or usercontrol (both is ok) at runtime?

I know that it is possible to parse an XAML - file at runtime and create an UIElement which I can insert into my pages grid, no problem there. But what I really want is to replace the whole XAML of my page or usercontrol, is that possible, too? Reasoning: I want to give the users of my application the opportunity to have the applicati...

Hiding and showing parts of an html with PHP?

The example I have in HTML: <div id="red-nav-warp"> <ul id="red-nav-logo"> <li><img class="sponsors" id="sponsorone" src="media/img/logosmall.png" /></li> </ul> <ul class="clearfix" id="red-nav-list-member" > <li><?php $themeSys->Href('logout',$langSys->get('LOGOUT')); ?></li> <li><?php $themeSys->Href('settings',$lang...

What are your favorite little used C# trick?

Possible Duplicate: Hidden Features of C#? Hello Everyone, I'm just wondering what little C# tricks that programmers use in their day-to-day work. I have two - One, an overlooked, for me, language feature. The other a solution to an often occuring need. 1 - Returning a default value (often from collections like ViewState o...

how to switch between vs 2008 & IE (web page) after making changes in code written in vs 2008 ?

I am new to the .NET environment. I have not used vs 2008 much more times. I just started to develop some asp.net pages. I can develop asp.net pages & then use the menu bar in vs 2008 to start debugging. When I start debugging the asp.net web page gets displayed in IE. I want to know the trick by which we can make changes in our existing...

ActionScript 3: how to get the class by just having the name

hi, i am trying te recieve the class with only having the name of the class so example: var className:String = "TheClass"; var theClass = new className(); is this possible? ...

Need the best approch to show a group of server control according to its permission.

Suppose I have a page which have more that 50 asp.net server controls. Now I want to display some control according to the logged in user's permission and rest of the controls will be hidden. In the same way, if an another user logs in then according to his/her permission it will show another group of controls on that page. So what is t...

How to implement MySQL::"LOAD DATA LOCAL INFILE" in PHP?

We have to implement the import procedure. The quantities of data is about 100 megabytes for one CSV files (the files already resides on server, so no upload necessary). Any advice on whether to implement the bulk "LOAD DATA LOCAL INFILE" or row-by-row "INSERT/REPLACE" on importing data into database. I've checked that "LOAD DATA LOCA...