Hello all,
I am using emacs and autotools, to write and compile c/c++ sources on linux.
I am using gdb via GUD in emacs.
I have defined for convenience: F7:compile, F10:gud-next, F11:gud-step, F5:gud-cont, F9:gud-tbreak, F8:gud-until, F4:gud-print.
I am mainly interested in debugging c/c++ source code on linux from emacs and I would like to get the most gdb can give.
Unfortunately I am using only F4 which prints the variable under cursor.
So my question is how do you guys debug the source code ?
What programs do you use ?
What key bindings (functionality) do you use mostly ?
What do you need the debugger to do for you ?
If you do weird stuff it doesn't matter. I would like to know everything to boost my speed a bit here.
Thanks in advance.
Mihai
How can I force Doxygen to show full include path?
What do I mean:
I have a class foo::bar::bee defined in bee.hpp in following directory structure:
foo
foo/bar
foo/bar/bee.hpp
Doxygen, when it documents foo::bar::bee class tells that you need to include <bee.hpp>, but for my software I need <foo/bar/bee.hpp>
How can I cause Doxygen to do this?
Notes:
FULL_PATH_NAMES is already set to default YES
I do not want to provide include header explicitly for each class, because there
too many of them. I want Doxygen to do this automatically.
Thanks.
Hi, I'm trying to create an image animation using Raphael JS.
I want the effect of a bee moving randomly across the page, I've got a working example but it's a bit "jittery", and I'm getting this warning in the console:
"Resource interpreted as image but transferred with MIME type text/html"
I'm not sure if the warning is causing the "jittery" movement or its just the way I approached it using maths.
If anyone has a better way to create the effect, or improvements please let me know.
I have a demo online here
and heres my javascript code:
function random(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function BEE(x, y, scale) {
this.x = x;
this.y = y;
this.s = scale;
this.paper = Raphael("head", 915, 250);
this.draw = function() {
this.paper.clear();
this.paper.image("bee.png", this.x, this.y, 159*this.s, 217*this.s);
}
this.update = function() {
var deg = random(-25, 25);
var newX = Math.cos(Raphael.rad(deg)) * 2;
var newY = Math.sin(Raphael.rad(deg)) * 2;
this.x += newX;
this.y += newY;
if( this.x > 915) {
this.x = 0;
}
if( this.y > 250 || this.y < 0 ) {
this.y = 125;
}
}
}
$(document).ready(function() {
var bee = new BEE(100, 150, 0.4);
var timer = setInterval(function(){
bee.draw();
bee.update();
}, 15);
}
Im really really a newbie in regexp and i cant figure out how to do that.
My goal is to have the RewriteRule to 'slice' the request url in 3 parts:
example.com/foo
#should return: index.php?a=foo&b=&c=
example.com/foo/bar
#should return: index.php?a=foo&b=bar&c=
example.com/foo/bar/baz
#should return: index.php?a=foo&b=bar&c=baz
example.com/foo/bar/baz/bee
#should return: index.php?a=foo&b=bar&c=baz/bee
example.com/foo/bar/baz/bee/apple
#should return: index.php?a=foo&b=bar&c=baz/bee/apple
example.com/foo/bar/baz/bee/apple/and/whatever/else/no/limit/in/those/extra/parameters
#should return: index.php?a=foo&b=bar&c=baz/bee/apple/and/whatever/else/no/limit/in/those/extra/parameters
In short, the first parameter in the url (foo) should be given to a, the second (bar) to b, and the rest of the string in c
I wroted this one
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(([a-z0-9/]))?(([a-z0-9/]+))?(([a-z0-9]+))(.*)$ index.php?a=$1&b=$2&c=$3 [L,QSA]
</IfModule>
but obviously doesnt work, and i dont even know if what i want is possible.
Any suggestion?
Im really really a newbie in regexp and I can’t figure out how to do that.
My goal is to have the RewriteRule to 'slice' the request URL path in 3 parts:
example.com/foo
#should return: index.php?a=foo&b=&c=
example.com/foo/bar
#should return: index.php?a=foo&b=bar&c=
example.com/foo/bar/baz
#should return: index.php?a=foo&b=bar&c=baz
example.com/foo/bar/baz/bee
#should return: index.php?a=foo&b=bar&c=baz/bee
example.com/foo/bar/baz/bee/apple
#should return: index.php?a=foo&b=bar&c=baz/bee/apple
example.com/foo/bar/baz/bee/apple/and/whatever/else/no/limit/in/those/extra/parameters
#should return: index.php?a=foo&b=bar&c=baz/bee/apple/and/whatever/else/no/limit/in/those/extra/parameters
In short, the first segment in the URL path (foo) should be given to a, the second segment (bar) to b, and the rest of the string in c
I wroted this one
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(([a-z0-9/]))?(([a-z0-9/]+))?(([a-z0-9]+))(.*)$ index.php?a=$1&b=$2&c=$3 [L,QSA]
</IfModule>
But obviously doesn’t work, and I don’t even know if what I want is possible.
Any suggestion?
EDIT:
After playing with coach manager, I got this one working too:
RewriteRule ^([^/]*)?/?([^/]*)?/?(.*)?$ index.php?a=$1&b=$2&c=$3 [L,QSA]
For this assignemnt, I think that I got it right, but when I submit it online, it doesn't list it as correct even though I checked with Eclipse.
The prompt:
Write a method isPalindrome that accepts an array of Strings as its argument and returns true if that array is a palindrome (if it reads the same forwards as backwards) and /false if not. For example, the array {"alpha", "beta", "gamma", "delta", "gamma", "beta", "alpha"} is a palindrome, so passing that array to your method would return true. Arrays with zero or one element are considered to be palindromes.
My code:
public static void main(String[] args) {
String[] input = new String[6]; //{"aay", "bee", "cee", "cee", "bee", "aay"} Should return true
input[0] = "aay";
input[1] = "bee";
input[2] = "cee";
input[3] = "cee";
input[4] = "bee";
input[5] = "aay";
System.out.println(isPalindrome(input));
}
public static boolean isPalindrome(String[] input) {
for (int i=0; i<input.length; i++) { // Checks each element
if (input[i] != input[input.length-1-i]){
return false; // If a single instance of non-symmetry
}
}
return true; // If symmetrical, only one element, or zero elements
}
As an example, {"aay", "bee", "cee", "cee", "bee", "aay"} returns true in Eclipse, but Practice-It! says it returns false. What is going on?
Guys, I have been surfing thru the web to find a way that I could use Multiple-Table-Inheritance in LINQ-To-SQL. But it looks like that it only supports single table inheritance which is not the best way to achieve inheritance in a ORM framework. I got to read that this will be addressed in next LINQ and Entity framework implementations. But how longer a stay we are talking about? In the meantime, if any of you guys have tried out a work-around implementation to achieve this, please let me know. And I thought of using my leisure time to come up with such an implementation so suggestions are welcome!
/Bumble Bee
I built a TicTacToe game to learn the .Net MVC3 framework. The basic functionality works (display board, make a move, detect winning move etc.) What I'd like to do is make it a "real" application - well-architected and using the right technology at the right layer. For instance, I'm currently saving every move to the database via a service call, which feels klugey and may become a bottleneck if this was an MMO game.
How do you determine a good architecture (or right set of technologies) to use in a situation like this? I'd like to learn not just what to do, but why certain decisions are better than others.
I noticed a similar thread here but it just offered opinions without explaining WHY something would be better (e.g. why Node instead of MVC3, etc.)
There are a lot of great programming quotes out there. Which do you like?
Today (Sept 12, 2008) I heard a new one from a friend, Lars-Gunnar, he said "Gud finns i Emacs" (in Swedish). This basically means "God is in Emacs". Still laughing about it here :) What he meant was that a function "gud is grand-unified-debugger" is in Emacs.
A great one I think all programmers should know is The Three Great Virtues of a Programmer.
Hi there
I'm exploring Dynamics CRM 4 and when I search a record
for example, a contact, ex. Abcd, Dynamics is searching by Abcd*,
including, by default, the WildCard in the end.
Is there any way to also include the Wild Card, by default, in the beggining?
Ex. Abcd -- Abcd
is it possible to solve conflicts on client side with sync services for ado.net?
for example, with Client Insert Server Insert, updating client's table id (on client side) , tks
I'm having trouble with sprite animation in XNA that appears to be caused by a struct passed as a reference value. But I'm not using the ref keyword anywhere. I am, admittedly, a C# noob, so there may be some shallow bonehead error in here, but I can't see it.
I'm creating 10 ants or bees and animating them as they move across the screen. I have an array of animation structs, and each time I create an ant or bee, I send it the animation array value it requires (just [0] or [1] at this time). Deep inside the animation struct is a timer that is used to change frames. The ant/bee class stores the animation struct as a private variable.
What I'm seeing is that each ant or bee uses the same animation struct, the one I thought I was passing in and copying by value. So during Update(), when I advance the animation timer for each ant/bee, the next ant/bee has its animation timer advanced by that small amount. If there's 1 ant on screen, it animates properly. 2 ants, it runs twice as fast, and so on. Obviously, not what I want.
Here's an abridged version of the code. How is BerryPicking's ActorAnimationGroupData[] getting shared between the BerryCreatures?
class BerryPicking
{
private ActorAnimationGroupData[] animations;
private BerryCreature[] creatures;
private Dictionary<string, Texture2D> creatureTextures;
private const int maxCreatures = 5;
public BerryPickingExample()
{
this.creatures = new BerryCreature[maxCreatures];
this.creatureTextures = new Dictionary<string, Texture2D>();
}
public void LoadContent()
{
// Returns data from an XML file
Reader reader = new Reader();
animations = reader.LoadAnimations();
CreateCreatures();
}
// This is called from another function I'm not including because it's not relevant to the problem.
// In it, I remove any creature that passes outside the viewport by setting its creatures[] spot to null.
// Hence the if(creatures[i] == null) test is used to recreate "dead" creatures. Inelegant, I know.
private void CreateCreatures()
{
for (int i = 0; i < creatures.Length; i++)
{
if (creatures[i] == null)
{
// In reality, the name selection is randomized
creatures[i] = new BerryCreature("ant");
// Load content and texture (which I create elsewhere)
creatures[i].LoadContent(
FindAnimation(creatures[i].Name),
creatureTextures[creatures[i].Name]);
}
}
}
private ActorAnimationGroupData FindAnimation(string animationName)
{
int yourAnimation = -1;
for (int i = 0; i < animations.Length; i++)
{
if (animations[i].name == animationName)
{
yourAnimation = i;
break;
}
}
return animations[yourAnimation];
}
public void Update(GameTime gameTime)
{
for (int i = 0; i < creatures.Length; i++)
{
creatures[i].Update(gameTime);
}
}
}
class Reader
{
public ActorAnimationGroupData[] LoadAnimations()
{
ActorAnimationGroupData[] animationGroup;
XmlReader file = new XmlTextReader(filename);
// Do loading...
// Then later
file.Close();
return animationGroup;
}
}
class BerryCreature
{
private ActorAnimation animation;
private string name;
public BerryCreature(string name)
{
this.name = name;
}
public void LoadContent(ActorAnimationGroupData animationData, Texture2D sprite)
{
animation = new ActorAnimation(animationData);
animation.LoadContent(sprite);
}
public void Update(GameTime gameTime)
{
animation.Update(gameTime);
}
}
class ActorAnimation
{
private ActorAnimationGroupData animation;
public ActorAnimation(ActorAnimationGroupData animation)
{
this.animation = animation;
}
public void LoadContent(Texture2D sprite)
{
this.sprite = sprite;
}
public void Update(GameTime gameTime)
{
animation.Update(gameTime);
}
}
struct ActorAnimationGroupData
{
// There are lots of other members of this struct, but the timer is the only one I'm worried about.
// TimerData is another struct
private TimerData timer;
public ActorAnimationGroupData()
{
timer = new TimerData(2);
}
public void Update(GameTime gameTime)
{
timer.Update(gameTime);
}
}
struct TimerData
{
public float currentTime;
public float maxTime;
public TimerData(float maxTime)
{
this.currentTime = 0;
this.maxTime = maxTime;
}
public void Update(GameTime gameTime)
{
currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (currentTime >= maxTime)
{
currentTime = maxTime;
}
}
}
I m new 2 XNA game pgming(also C#)....I want 2 create a main page with some buttons and on clicking a particular button, it should goto another screen whr there r some buttons to select which should inturn goto the game screen on clicking....Whether I can put all the codes in the "game1.cs" or create new class for every page....Pls help...
I've jus went through some pages in "Learning xna4.0" by o'reilly...If there s any other gud tutorials, pls suggest me...
I'm looking for a java equivalent to this php call:
hash_hmac('sha1', "test", "secret")
I tried this, using java.crypto.Mac, but the two do not agree:
String mykey = "secret";
String test = "test";
try {
Mac mac = Mac.getInstance("HmacSHA1");
SecretKeySpec secret = new SecretKeySpec(mykey.getBytes(),"HmacSHA1");
mac.init(secret);
byte[] digest = mac.doFinal(test.getBytes());
String enc = new String(digest);
System.out.println(enc);
} catch (Exception e) {
System.out.println(e.getMessage());
}
The outputs with key = "secret" and test = "test" do not seem to match.
I'm writing a Wordpress MU plugin, it includes a link with each post and I want to use ajax to call one of the plugin functions when the user clicks on this link, and then dynamically update the link-text with output from that function.
I'm stuck with the ajax query. I've got this complicated, clearly hack-ish, way to do it, but it is not quite working. What is the 'correct' or 'wordpress' way to include ajax functionality in a plugin?
(My current hack code is below. When I click the generate link I don't get the same output I get in the wp page as when I go directly to sample-ajax.php in my browser.)
I've got my code[1] set up as follows:
mu-plugins/sample.php:
<?php
/*
Plugin Name: Sample Plugin
*/
if (!class_exists("SamplePlugin")) {
class SamplePlugin {
function SamplePlugin() {}
function addHeaderCode() {
echo '<link type="text/css" rel="stylesheet" href="'.get_bloginfo('wpurl').
'/wp-content/mu-plugins/sample/sample.css" />\n';
wp_enqueue_script('sample-ajax', get_bloginfo('wpurl') .
'/wp-content/mu-plugins/sample/sample-ajax.js.php',
array('jquery'), '1.0');
}
// adds the link to post content.
function addLink($content = '') {
$content .= "<span class='foobar clicked'><a href='#'>click</a></span>";
return $content;
}
function doAjax() { //
echo "<a href='#'>AJAX!</a>";
}
}
}
if (class_exists("SamplePlugin")) {
$sample_plugin = new SamplePlugin();
}
if (isset($sample_plugin)) {
add_action('wp_head',array(&$sample_plugin,'addHeaderCode'),1);
add_filter('the_content', array(&$sample_plugin, 'addLink'));
}
mu-plugins/sample/sample-ajax.js.php:
<?php
if (!function_exists('add_action')) {
require_once("../../../wp-config.php");
}
?>
jQuery(document).ready(function(){
jQuery(".foobar").bind("click", function() {
var aref = this;
jQuery(this).toggleClass('clicked');
jQuery.ajax({
url: "http://mysite/wp-content/mu-plugins/sample/sample-ajax.php",
success: function(value) {
jQuery(aref).html(value);
}
});
});
});
mu-plugins/sample/sample-ajax.php:
<?php
if (!function_exists('add_action')) {
require_once("../../../wp-config.php");
}
if (isset($sample_plugin)) {
$sample_plugin->doAjax();
} else {
echo "unset";
}
?>
[1] Note: The following tutorial got me this far, but I'm stumped at this point.
http://www.devlounge.net/articles/using-ajax-with-your-wordpress-plugin
I need to display on my page a list of records pulled from a table. Ajax works fine (I query the database and put all the data inside a on the main page) but if I have lots of records (say 500+) it will hang until data is fully loaded, THEN it will be sent back to the page and correctly displayed.
I would like to be able to display the records on the page while getting them, instead of being forced to wait until completion. I am trying with flush(); inside the remote (ajax) page but it still waits until full data is loaded.
This is what I currently have inside the ajax page:
At the very beginning:
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
ob_implicit_flush(1);
Then whenever I have a echo call:
ob_flush();
Now if I load the ajax page alone... it will list the records while reading them from the database. But if I call the same page via Ajax, it will hang and send all the data at once.
Any idea?
This is the function I use to get the ajax content ('id' is the target , 'url' refers to the ajax page that runs the database query to list the records):
function ajax(id,url) {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById(id).innerHTML = parseScript(xmlhttp.responseText);
}
Basically what I want to do is display an email using javascript to bring the parts together and form a complete email address that cannot be visible by email harvesters.
I would like to take an email address eg [email protected] and break it to:
$variable1 = "info";
$variable2 = "thiscompany.com";
All this done in PHP.
Regards,
JB
Sometime i will encounter this error after multiple access of my web application
I am using Sun Application Server Platform Edition 8.2
What is the reason for encountering this error and how to resolve it.
Hi,
I have been developing web applications for a while now. My applications have been fairing poorly in search engine results because of the dynamic links that my websites generate.
I admire the way some developers do their mod_rewrite to produce something like:
http://www.mycompany.com/accommodation/europe/ to run a substitute of "index.php?category_id=2&country=23"
How can I achieve that in my urls?
Warm regards,
JB
Given one or more instances of a model (AR or DM, whatever). Is it possible to generate the route in the requirement form, by which I mean "/foos/:id"
Given the route:
resource :foo do
resource :bar
end
generate_route_method [@foo,@bar] - "/foos/:id/bars/:id"
I'm not talking about #foos_path or #polymorphic_path, rather, literally generating the string containing the wildcard components (i.e ":id"), the same as it would appear as if you did "rake routes".
Im not sure if this question is appropriate to go in here but after some hard effort in google I had no option but to post this here.
I'm in the process of doing some UIs for a touch screen, but not sure how the template should look like. e.g. how big the buttons/text/labels should be. If anyone has experience in doing s similar stuff, pls share some references you have.
thanks
BB
I want to make all my settings forms across my site confirm that changes are saved, kinda like facebook does if you make changes in a form and then try to navigate away without saving. So I'm disabling the submit button on the forms only enabling if the values change. I then prompt the user to hit save before they leave the page in the case that they do have changes pending.
var form = $('form.edit');
if(form.length > 0) {
var orig_str = form.serialize();
$(':submit',form).attr('disabled','disabled');
form.on('change keyup', function(){
if(form.serialize() == orig_str) {
setConfirmUnload(false);
$(':submit',form).attr('disabled','disabled');
} else {
setConfirmUnload(true);
$(':submit',form).removeAttr('disabled')
}
});
$('input[type=submit]').click(function(){ setConfirmUnload(false); });
}
function setConfirmUnload(on) {
window.onbeforeunload = (on) ? unloadMessage : null;
}
function unloadMessage() {
return 'If you navigate away from this page without saving your changes, they will be lost.';
}
One of these forms needs some additional validation which I do using jQuery.validate library. e.g. if i wanted to ensure the user can't double submit the form on accident by double clicking on submit or somesuch (the actual validation in question is for a credit-card form and not this simple):
$('form').validate({
submitHandler: function(form) {
$(':submit', form).attr('disabled','disabled');
form.submit();
}
});
Unfortunately both bits are trying to bind to submit button and they're interfering with each other such that the submit button remains disabled no matter what I do and it is impossible to submit the form at all.
Is there some way to chain the validations together or something? Or some other way to avoid re-writing the validation code to repeat the "did you change anything in the form" business?