Actually, Sanchit is incorrect. You need to be using sudo to move the file. root is the owner of /usr/lib/, so in order to move the red52 folder to /usr/lib/, you will need to be root.
So try this instead:sudo mv red52/ /usr/lib/
That should work!
JasonHippy 739 Practically a Master Poster
OK, first off; you have posted in the incorrect section of the site. This question belongs in the C section, NOT the web development section.... But I'm sure one of the mods will rectify that shortly!
Secondly, can you post more details on the program that is experiencing the segfault? For starters, is this a program you have written yourself? Or a program you have installed from your chosen distros repositories? Or something you have downloaded from elsewhere? Which Linux distro are you running? Do you have the source code for the program?
With the very vague information you have given, the only advice I can give you is equally vague:
1. Get the source code for the program if you do not already have it.
2. Build a debug version of the program by including the -g flag (you might need to alter some makefiles to do this).
3. Run the program through gdb (GNU debugger) until it crashes.
4. Examine the code around the point of the crash and try to determine what is causing the crash and why.
5. Alter the source code to fix the problem.
6. Rebuild the program - again generating debugging symbols with -g.
7. Run the program to see if the fix worked. If the program still crashes, keep running through steps 4-7 until the problem is fixed.
8. Once the problem is fixed, build a release version of the program (remove the -g …
JasonHippy 739 Practically a Master Poster
After reading your post again, I realise I was doing things the wrong way around. Going the other way - User entering decimal values and converting to hex, would be as simple as this:
#include <stdio.h>
int main()
{
/* two user entered int values.. Just use your imagination dammit! */
int userVal1 = 15;
int userVal2 = 155;
printf("%d in hex: %X\n", userVal1, userVal1);
printf("%d in hex: %X\n", userVal2, userVal2);
printf("%X + %X = %X\n", userVal1, userVal2, userVal1+userVal2);
return 0;
}
There is nothing more complicated required. As mentioned, all numbers are stored and manipulated in memory as binary. Decimal is displayed by default as a convenience to us humans. To display as hex, simply output the value as hex with %X.
JasonHippy 739 Practically a Master Poster
To clarify L7Sqr's point:
At the end of the day a number is just a number.
It doesn't matter what base it is in, it ultimately has the same value.
When a number is stored in an int variable, it is actually stored in memory as a binary value. Octal, Hexadecimal and Decimal are just convenient ways of displaying/representing that value.
When we display the value of a variable using printf, it is displayed as decimal by default, because decimal is the most human-readable format.
In order to see it as hex, you need to specify %x or %X (depending on whether you want the hex digits displayed as lower-case or upper-case characters).
If you want to assign a hexadecimal value to an int variable in a C program you can do this:int hexvalue = 0xA5;
But again, when you output the value of hexvalue via printf, it will be displayed as decimal unless you specify %X.
So, if you are dealing with user input values, you need to parse the strings entered by the users to ensure that they are valid hex values. Then convert the strings to their equivalent int values (using hex, octal or decimal....whatever floats your boat!). You might also want to consider doing some range checking on the values before performing any calculations using standard C maths functions/operators and finally output the results via printf using %X.
That way your users can input hex values as strings, you convert …
JasonHippy 739 Practically a Master Poster
Or as you want to go up a level from the current path, perhaps use find_last_of:
#include <iostream>
#include <string>
int main () {
std::string src, dst;
src = "C:\\Windows\\subfolder";
dst = src.substr (0, src.find_last_of ("\\") + 1);
std::cout << "Original: " << src << std::endl;
std::cout << "Modified: " << dst << std::endl;
return 0;
}
kal_crazy commented: Works perfectly. Thanks +4
JasonHippy 739 Practically a Master Poster
You are using the wrong operator in your if statements. You need to be using the == operator in your if statements, not the = operator!
= is the assignment operator, used to assign a value to a variable.
Whereas == is the test for equality.
EDIT:
In fact, the == operator is incorrect. After looking at your code again, you need to be using the >= (greater than or equal to) operator:
e.g.
if (num >= 400 && num <=424)
cout<< “ Violet “;
else if (num >= 425 && num <= 491)
cout<< “ Blue “;
else if (num >= 492 && num <= 575)
cout<< “ Green “;
else if (num >= 576 && num <= 585)
cout<< “ Yellow “;
else if (num >= 586 && num <= 647)
cout<< “ Orange “;
else if ( num >= 648 && num <= 700)
cout<< “ Red “;
else
cout<< “ Wavelength outside visual range “;
JasonHippy 739 Practically a Master Poster
Which version of Ubuntu are you using?
This blog post explains how to do it in Ubuntu 12.04. The instructions should work on any other recent versions of Ubuntu from what I can see. I haven't tested it myself, but it looks like it should work.
According to the article, Openmeetings will work with LibreOffice as well as OpenOffice. And as LibreOffice is installed by default in recent versions of Ubuntu, you shouldn't need to worry about installing OpenOffice.
The page in the link explains all of the different bits of software you'll need to install alongside Libreoffice in order to get OpenMeetings installed and running.
However, if you still want to find/install the OpenOffice packages rather than using Libreoffice - If memory serves the Openoffice packages are in the partner repo. So your first stop should be to check /etc/apt/sources.list and ensure that the partner repository is uncommented.
To check the partner repo is enabled, you'll need to take a look at /etc/apt/sources.list:
To edit the list from a command-line text editor (vi/vim/nano/pico/emacs), open a terminal and use the command:sudo vim /etc/apt/sources.list
Substitute vim in the above for your favourite command-line editor. To get emacs to run on the command line without the windowed GUI use the -nw option.
To edit in a graphical text editor (gedit, kate, gvim, emacs) use the following command:gksudo gedit /etc/apt/sources.list
Again, substitute gedit for your chosen GUI text editor.
Once you have the file open, …
JasonHippy 739 Practically a Master Poster
Just because something is covered by the GPL does not mean it cannot be bought or sold. RMS himself even states this!
Free software does not have to be free of cost, but users must have the freedom to be able modify the code. That said, other than RHEL I don't know of any free software which isn't also free of cost! Heh heh! XD
I've seen plenty of free software projects that charge for technical support (e.g. Canonical) and/or training courses (Offensive security, the Blender foundation, the Linux foundation).
When I say bought Pear, I mean they've effectively bought David out so they can dictate the future direction of Pear and its development.
If (IF) a company has bought Pear, perhaps they have taken the old pear site down, moved all of the sources across to their own servers. They'll almost certainly have a team of developers of their own to continue development in whatever direction they choose to take it. At some point, they might resurface and try to build a community around their enhanced version of Pear. Either way, when/if it does resurface, whoever has taken over the development of it will have to release the sources for it as stipulated by the GPL.
If it has been bought by an OEM, they will undoubtedly be re-releasing Pear as a free OS for whatever hardware they plan to ship it with. I don't think there is any question of them attempting to sell it!
The …
JasonHippy 739 Practically a Master Poster
Personally, I've been using FLOSS exclusively at home for a number of years now. Even at work I try to use free-software for as many tasks as possible. The only non-free software I use at work ATM is Windows OS and Visual Studio. But I don't get any choice over those.
But wherever I do have a choice, I choose free software. I don't see any point in getting my boss to pay for a licence for me to use Photoshop or Illustrator for creating things like icons or any of the other simple graphical items I might have to create in the course of doing my job. There is no point. I can simply download one of any number of FLOSS programs and do it for free!
I was discussing free-software with a couple of former colleagues from my days at an elearning company who are professional graphics geeks doing 2D and 3D CGI GFX and animations for various companies now.
As mentioned in my previous thread, the main obstacle that we all saw that could prevent wide-spead adoption of free software by professionals was the entrenchment of other proprietary programs.
Many companies just have so much data stored in proprietary formats that are specific to a particular program, they cannot easily switch (unless there is a simple way to convert files to an open format without any loss of quality or data - Which in most cases there isn't). So even if the free-software was up to the …
mike_2000_17 commented: Very complete answer! +14
JasonHippy 739 Practically a Master Poster
So you want to go from OSX Mavericks to Ubuntu?
And you don't want to use a CD drive or a VM.....
The only solution I can think of is to try putting the .iso for the Ubuntu liveCD installer onto a USB thumb drive.
NOTE:
I'm not a Mac user and haven't been for a long time, so apologies if any of this is incorrect.
To get Ubuntu onto a USB drive, do the following:
- Download the .iso for Ubuntu.
- Insert the USB drive you want to copy the iso onto.
- If the USB drive gets auto-mounted by the OS, open a terminal and unmount it - if memory serves I think you need to use diskutil:diskutil unmount /dev/yourusbdevice
NOTE: /dev/yourusbdevice is the device identifier for your usb drive. e.g. /dev/sdb1 << Important: Make sure the device identifier is the correct one for the drive! If you are unsure of the device identifier, you can use the following command:diskutil list
Which should list the disks currently inserted.
- To copy the iso to the thumb-drive, use the dd command in a terminal:dd if=path_to_ubuntu.iso of=/dev/yourusbdevice bs=1m
Where path_to_ubuntu.iso is the path and filename of the iso you downloaded and /dev/yourusbdevice is the device identifier for your thumb-drive e.g. /dev/sdb1.
Now you should have a bootable Ubuntu LiveCD on a USB drive.
At this point, I should point out that I've never installed Linux on a Mac …
JasonHippy 739 Practically a Master Poster
Have you searched your linux machine for ntstatus.h?
Open a terminal and try the following command:find / -type f -iname "ntstatus.h"
This will recursively search from the root of your file-system and try to find the file.
If it lists any files called ntstatus.h, then you know it is a problem with the compilers paths (and in which case, I'm not sure how to fix it offhand!).
But if it does NOT list any files, you'll probably need to download and install the Windows SDK on your Kali Linux machine (because ntstatus.h is part of the Windows SDK).
BTW: If memory serves, when you download the SDK from Microsoft, it is usually a self-extracting archive in .exe format. So I'm not sure whether you'd be best served installing it via Wine, onto Wines virtual C:, or by extracting/installing it on a Windows machine and copying all of the include and library files to your Kali box via a USB thumb-drive.... IDK!
Either way, the first thing you need to do is determine whether or not you have ntstatus.h. I suspect that you do not!
JasonHippy 739 Practically a Master Poster
I agree. Free software has come a long way in the last 10 years or so! It is stunning what can be done with free tools nowadays. There are many free programs that can at least come close to their highly polished, proprietary cousins. There are probably also a few that can give them a run for their money or even better them! Heh heh!
As for things being 'industry standard', that seems to have happened in pretty much all of the creative industries. All of them have some expensive proprietary piece/pieces of software which are seen as the best/only way of doing things. There may be viable, free alternatives to all of these programs, but I don't think that any of the proprietary programs which are currently considered de-facto standards are likely to be knocked off their top spots any time soon. Mainly because they have been so entrenched in the culture of those industries.
However, for your average computer user, students or perhaps even startups that are looking to minimise their costs; free software is becoming a more enticing and viable alternative to expensive proprietary software day by day!
JasonHippy 739 Practically a Master Poster
I remember reading an article somewhere online in the last couple of weeks discussing this very issue.
Pear OS was a one man effort, so it is possible that David Tavares simply decided to end the project. However that is unlikely because before the Pear OS website was taken down (the site is now offline) - David announced that the project was closing because it had been bought from him by a well-known tech company who wanted to remain anonymous for now and who want to develop and improve Pear OS for their products. I don't like to think that David would have lied about that. So it is almost certain that somebody has bought Pear OS.
But without knowing who bought Pear OS and their exact plans for it, we can do little more than speculate.
I too doubt that Apple would have bought it. They have no real need for it. And if Apple wanted it shut down, they have lawyers for that.. Unless it was cheaper to buy Pear out than to sue... Which is possible - but again, extremely unlikely! Personally, I don't think that Pear OS would even have been on Apples radar.
From the vague information that was given by David before the Pear website disappeared, perhaps a harware/OEM type company has bought it and plans to ship their new hardware with PearOS pre-installed. This is a very distinct and feasible possibility. There may be a sincere OEM out there who wants a modern-looking, …
JasonHippy 739 Practically a Master Poster
The compiler is complaining because it cannot find ntstatus.h.
Either you do not have it installed, or it has been put somewhere outside of the systems search path for header files.
Also you should be aware that ntstatus.h is a windows-only header file. It is not available for Linux.
You will need to have a copy of all of the windows header files and the windows versions of the corresponding libraries somewhere on your machine if you do not already have them. Once you do have them, you need to either put them on a path that is recognised by the compiler, or tell the compiler where to find the files.
Personally I've never tried cross-compiling Windows binaries on a Linux machine, so I can't really help beyond that! I know it is possible to do it, but I've never had the desire (or the need) to do so, or to find out for myself. But if anybody here at Daniweb knows anything about this kind of thing, it will probably be Rubberman or Mike!
JasonHippy 739 Practically a Master Poster
Looks like you need to install libcurl-dev. Offhand, I'm not sure of the exact package names on Ubuntu. Your best bet would be to take a look for them in the software centre or to try opening a terminal and run the command apt-cache search --names-only libcurl | grep -i dev
- That should list some packages. Once you've identified the appropriate package for libcurl-dev, use sudo apt-get install xxxxx
where xxxxx is the name of the package you need to download/install.
After installing libcurl-dev and running configure again, you might get similar errors about other missing libraries/dependencies. If this happens you'll need to download/install more dependencies as per the above instructions.
Once you have all of the dependencies installed the configure step will eventually succeed and you should be able to move-on to actually compile/build the program!
JasonHippy 739 Practically a Master Poster
I don't know of any direct Swishmax clones/alternatives on Linux.
The closest I can think of is Synfig - a 2D animation program which I believe can export animations as flash/.swf format (amongst many other formats). So synfig might be OK if you only want to create animations.
Blender (although traditionally a 3D CAD/animation type program) can also be used to create 2D animations (along with many other things like compositing, non-linear video editing, game creation with the built-in game engine etc) - But Blender has quite a steep learning curve!
If you want to create more interactive content like games, IMHO the best bet would probably be something like the Adobe Flex SDK which will give you the tools required to compile/build .swf files from AS3 and mxmlc files. But this means that you will be doing everything in code. If you are comfortable writing code, you shouldn't have a problem using the flex SDK. But if you're one of those 'spaghetti-code nested inside clips and all over the timeline' type flash-devs, you probably won't get on well with it!
Also when using the Flex SDK you'll need to either create your graphics in code, programmatically (which requires a bit of maths/geometry/trigonometry knowledge), or you can use another external image editor like Inkscape to create scalable svg GFX or Gimp/Krita for bitmap/raster GFX and then write AS3 code to import (or embed) and manipulate the GFX in your project.
There is also a program called Minibuilder, which …
JasonHippy 739 Practically a Master Poster
Personally, I like a mixture of the two.
At home I like good old-fashioned paper books. I have my own little geek library, which I use for reference/general study and entertainment... Yes, that's right. I said entertainment! There is some fiction in there, it's not all technical manuals! Heh heh!
I also have a library of ebooks backed-up on one of my removable HDs at home. I have a USB stick loaded with the ebooks I use most often, giving me quick and easy access to them on any PC I use (work, home, friends etc).
And then there's my trusty old Sony e-reader - which I love when I am on the move. With it I can carry an entire library. All of the information, but absolutely none of the weight! Great for travelling/holidays. Also great to keep in my laptop-case when out and about for work too. If I need to refer to something quickly, without having to fire up my laptop; I can whip out my e-reader and quickly check out whatever I need to!
However, there are some things that annoy me about ebooks.
One thing (on e-readers and PCs) is the render time when changing pages. You press/click a button, or scroll down and sometimes you have to wait for what seems like an eternity for the content to display.
That can waste a fair bit of time sometimes, especially if you are trying to skip several pages at a time! (I've noticed …
JasonHippy 739 Practically a Master Poster
As L7Sqr has said, your command structure should not contain the command history. The command history should be a separate entity and should maintain a list of commands entered by the user.
WRT the implementation of the history:
I think you'll need to implement a FIFO stack/queue (from now on I'll refer to it as a queue) with space for 100 command strings. Each time a command is entered by the user, push the command string onto the back of the queue. If the queue is full and you want to add another command to the history, simply pop the oldest item off the front before pushing the newest command string onto the back.
Then the history command itself just needs to list the strings stored in the history queue.
I imagine you've probably already covered implementing stacks/queues in your classes/lectures. If not, there are tons of examples on the web to learn from!
Also I have another thought:
When using the Bash shell on a Linux system, the command history is stored in a hidden text file in the users home directory called ".bash_history". I think most other popular shells do the same sort of thing.
Bearing that in mind:
Rather than only storing the previous command history in memory (so the history is effectively only saved for the current session), would it be worth considering storing the history in a file somewhere in the users home directory? e.g. ".yourshellsname_history"
That way your shell will behave …
JasonHippy 739 Practically a Master Poster
Over the last couple of days the sky's been a funny bright-blue colour and there's been a strange, bright, round-thing in the sky....Not sure what it's called. But I think I have childhood memories of this kind of weather!
Heh heh. It certainly makes a change from all the cold, grey, windy-wetness we've been experiencing here in Somerset, during what has undoubtedly been the wettest winter on record for the UK!
A few unfortunate friends of mine who live out on the Somerset levels (a few miles away from my town) have joked about needing a submarine to get to their local village shop; which has been under several feet of water since January (along with much of the rest of the village!) :/
JasonHippy 739 Practically a Master Poster
Regenesis by Kinasis
Yes, my own band.... Sad, I know! But we have a gig in Bristol tomorrow night and I've been drumming along on my practice pads in preparation. And it was the last song I ran through.. So nah! Heh heh! :P
Here's the official lyric vid for the song: (Taken from our as yet unreleased debut album 'Divine Self-Invention')
http://www.youtube.com/watch?v=N1MAlkkOQvQ
Note: Although we're a metal band, the vid is safe for work. There's no swearing in the song or offensive content in the vid. But it's definitely loud and not exactly what you'd call music! Heh heh! XD
JasonHippy 739 Practically a Master Poster
No, you don't need to reinstall the whole OS. You might just need to download some drivers.
Rubberman was merely stating that there might be some pieces of hardware on your machine which require proprietary drivers and that proprietary drivers might not be installed when the Ubuntu operating system is first installed.
To troubleshoot this problem, open a terminal in Ubuntu and run the two commands specified by rubberman (lspci and lsusb) and repost their output.
The lspci command will list details of hardware connected to your pci bus. The lsusb command will list details of USB devices connected to your computer. This will give an idea of what hardware devices you have.
Also lspci -v
will show more detailed information about the hardware, including the name of the Linux kernel module/driver which handles that piece of hardware (if any). That might help to track down any driver problems.
Once we can see what hardware you are using, someone here will be able to direct you to the correct drivers, if any are required.
Also, you mentioned network problems. What output do you get from the command ifconfig? That will show the networking status of your PC in Ubuntu and will show which, if any of your network interfaces are configured and running.
rubberman commented: Good reply Jason. +12
JasonHippy 739 Practically a Master Poster
I understand what you are trying to do, it is a simple Unix/Linux like terminal clone.
The answer to the first part of your puzzle lies in the comments in my original post. Fix the indentation in your code, double check all of the start and end braces in your code (I'm 99.9% certain that you'll find that the closing brace at line 89 doesn't need to be there and that you require a additional closing brace at the end of your program)
With those changes in place, your program will be able to get out of the tokenisation code and into the part of the code which parses and executes the command entered by the user.
Once you've got to that point, you'll need to make some additional changes to your code. Because as it stands it will not work AFAICT! I haven't gone to any lengths to actually test your code. But it looks like it needs a little more work, as mentioned in my 2nd post!
JasonHippy 739 Practically a Master Poster
A couple of other things I just noticed:
The variable tok
is never initialised before it is first used. I recommend intitialising it to zero at initialisation or before its first use.
Also variable i
is declared once and used at several places in the code, no problem with that. It is first used at lines 32 and 33, but it is not reset to 0 before it is used at line 58. Which doesn't look right. I think that should be reset at line 57. You are correctly resetting it at line 96, but it should also be reset at line 57!
Another thing that looks fishy is the strcmp at line 97:
From what I can see, userCom.Listcomm never appears to be populated with anything. So you'll end up with either no result, or a crash at runtime with that line (depending on what happens when a null string is passed as a parameter to strcmp! - Not sure offhand!)
So it looks like there might be some fuzzy logic at play in your program too!
JasonHippy 739 Practically a Master Poster
If you look at the braces in your program, The while loop declared at line 29 ends at line 94, which is commented as "End token loop".
So you are stuck in an endless loop where you are just getting input from the user. The code in the 2nd half of your program is not getting called because the program is never getting there.
I think you meant for this particular loop to enclose the whole program. So you might want to consider checking the indentation of your program and taking a good look at the braces that start and end the various blocks of the program and ensure they are all where they should be!
From looking at your program, I'd say that you need to remove the closing brace at line 89 and indent the closing brace at line 94
Also add a closing brace at line 139 to end the program, and indent the closing brace at line 138, because that will now close the main while loop, which matches the comment made against that line.
That would appear to be the problem from what I can see!
JasonHippy 739 Practically a Master Poster
According to MSDN GetPixel returns the error value 0xFFFFFFFF / CLR_INVALID under 3 very specific conditions.
- The pixel is outside the boundaries of the current clipping area
- The device does not support GetPixel
- There is no bitmap selected within the device context
Best bet is to take a look at the MSDN page and see whether any of those conditions apply to your application and update it accordingly.
Also, a community comment on the page states that GetPixel is not thread-safe. So if your program is threaded, that could also be part of the problem!
If nothing there helps, then I don't know what else to suggest offhand!
JasonHippy 739 Practically a Master Poster
No, there's only a single statement under the 2nd for loop, so there is no need for enclosing braces there! But without the correct indentation in the OPs code, it does initially look as if there should be an opening brace! :)
JasonHippy 739 Practically a Master Poster
The only thing I can imediately see is that there's a 'do' at line 25 with no opening brace and no corresponding while statement further down in the code. I imagine the cout at line 27 is where the error is being thrown. And this is almost certainly because of the rogue do statement at line 25.
Either remove the do, or enclose the code after the do and put a corresponding while statement later in the code. That should clear that error!
There may be some other gotchas in your code, but I haven't looked at it in any great detail yet!
JasonHippy 739 Practically a Master Poster
Aside from the missing left brace on line 5, there are a few other problems I can see straight off the bat.
For starters: In order to use setw, you'll need to #include <iomanip>
.
Then there's your '3D' array; which from your initialisers, looks more like a 4D array. So you need to set the dimensions of your array accordingly. What you've actually got there is a 4x4 array.
What are you trying to do here??
Then there is the matter of the break condition in your 2nd for loop at line 14. Surely that should be using col, not row:for(col=0;col<4;++col)
<< Note, col < 4 rather than < 3, because you are currently using a 4x4 array!
With the 2nd for loop in its current state (using row in the break condition), you're going to end up overstepping the bounds of your array and/or getting a segfault at runtime.
JasonHippy 739 Practically a Master Poster
Keep a set of counter variables to count the number of A's, B's, C's etc.
Initialise them to zero at the beginning of your program, increment the appropriate counter when a grade is assigned in your block of if..else if statements.
e.g.
Declare some counters with the rest of your variables:
int numAs, numBs, numCs, numDs, numFs;
numAs = numBs = numCs = numDs = numFs = 0;
Increment the appropriate counter in your if..else if block:
if ( score >= 92.0 )
{
cout << "You scored a " << scores[i] << ". You received an A" <<'\n';
++numAs;
}
else if ... // I'll leave you to do the rest!
Finally in your output section:cout << "Number of A's: " << numAs << '\n'
Again, I'll leave you to fill in the rest of the blanks!
:)
JasonHippy 739 Practically a Master Poster
So let me get this straight.... From looking at your other threads, you intend to create a bunch of desktop GUI components for Linux using Visual Studio??
The good news is, if you want to create desktop components for Linux; you can do so, but you will need to have a good understanding of Unix-like OSes and have some programming experience at system level. Also, you're going to need to choose a Linux compatible, cross-platform GUI library to do this with (QT, GTK2/3, wxWidgets etc).
The bad news is, you aren't going to be able to use Visual Studio to do this. Visual studio is Windows only. You'd need to use gcc on Linux.
So are you just planning to create a few replacement components for an existing desktop environment? If so, which desktop? (Gnome3, KDE, Openbox, Cinnamon etc) Or do you intend to create an entire desktop environment of your own?
Also ask yourself, do you really need to undertake this? Would it be simpler to create a theme for an existing Linux desktop environment?
For example: It would be fairly straightforward to make the KDE desktop look and behave like Windows. (saying that, it would probably take a fair amount of time and effort, but it would almost certainly take far less effort than creating your own DE components from scratch!)
Just some food for thought!
JasonHippy 739 Practically a Master Poster
Well, take a look at the url from a search page on google.
I went to google.com and did a search for daniweb.com and got this URL for the results page:
https://www.google.co.uk/?gws_rd=cr&ei=f0UFU-y9CoeK1AW4joGgCw#q=daniweb.com
Looking at that URL, the question mark "?" in the URL indicates the start of the variables that were passed to the search engine in order to generate the results page. The actual search terms are at the end of the url "#q=" indicates the start of the search terms that were used. So it should just be a case of adding "#q=" and your search terms to the google URL.
So if you want to use the script to fire up the browser and search for something, you could have a string variable called googleUrl, which is assigned the value "http://www.google.com/?#q=". This forms the base of the required URL for a search.
Then in your script you could get the user to enter their search terms as a string.
Finally append the users search string to the googleUrl string and open that in your call to webbrowser.open. That should open the browser and perform the search.
e.g.
import webbrowser
new = 2
googleUrl = "http://www.google.com/?#q=";
terms = input("Enter your search terms: ") # or raw_input if using python 2
webbrowser.open(googleUrl + terms, new=new)
Otherwise, if you just want to hard-code the search terms into the script, simply add the terms after '#q=' in the …
JasonHippy 739 Practically a Master Poster
Is the projector physically connected to the laptop before you boot your laptop? Or are you plugging it in after the laptop has booted?
I often plug my Linux laptop into a projector at work. The only times I've ever had problems is when I plug the projector in after my laptop has booted. And in these cases it's just a case of restarting the X server to get the projector to display output from my laptop.
From a logged-in session, to restart X; log out of the current session to go back to the log-in screen. Then select the 'restart X server' option in the shutdown menu. Once X has restarted and you see the log-in screen again; the projector should now be showing some output from your laptop. Then you can log in and do whatever you want need to do!
I find that if the projector is connected to the laptop and is turned on before the laptop is booted, the projector always works. But if the laptop was started before the projector is connected, it always becomes necessary to restart the X-server from the log-in screen.
I hope that is of some help!
JasonHippy 739 Practically a Master Poster
I didn't mean that boost was bad. Far from it! The boost libraries are great!
It's a portable, mature, stable, well-tested set of C++ libraries that are extremely useful.
My comment refers to the fact that some people don't like making their programs rely on an external library for something trivial like this. If you compare the two examples in my post; the 2nd example is extremely simple and understandable and doesn't require a 3rd party library.
At the end of the day, boost::assign::map_list_of is little more than syntactic sugar. It provides an alternate means of initialising a std::list.
Some people (including myself) would consider it overkill to add the boost library as a dependency for just map_list_of! (The only reason I mentioned map_list_of was because it allows you to use similar syntax to your original code)
But the boost library is a great library. I heartily recommend taking a look at it. There are some extremely useful classes available in there.
If you want to use boost, by all means do so!
Personally, I'll only use the syntactic sugar provided by boost::assign if I'm already using other, more significant boost components elsewhere in my program (boost::bind, boost::signals2, boost::filesystem, boost::graph etc). In for a penny, in for a pound and all that! Heh heh! :)
JasonHippy 739 Practically a Master Poster
The compiler does not know where COLOR_BGR2HSV is defined.
I suggest you take a look at the documentation for the OpenCV library and see if you can find the header file that COLOR_BGR2HSV is defined in and ensure it is #included in your source file.
Second thoughts:
From a quick poke around on the net I've found this:
http://opencv-srf.blogspot.co.uk/2010/09/object-detection-using-color-seperation.html
Which contains the following line:cvCvtColor(frame, imgHSV, CV_BGR2HSV); //Change the color format from BGR to HSV
Which looks as if it is exactly what you are doing at the line where you are getting your error. So perhaps COLOR_BGR2HSV is actually incorrect. Perhaps you should be using CV_BGR2HSV instead!
JasonHippy 739 Practically a Master Poster
I don't think you can initialise a std::map like that.
You can initialise std::map in a similar way using map_list_of
in the boost::assign library.
Which would allow you to do something like this (if memory serves):
void ArcherArmor::ArcherArmor_shop(){
soldier_armor = boost::assign::map_list_of<int, Armor>
(1, Armor("Meito Ichimonji", 4, 150, 1))
(2, Armor("Shusui", 10, 230, 2))
// ....Rest of your map declarations
(6, Armor("Soul Calibur", 60, 900, 8));
}
But if you don't want to add boost as a dependency to your program, your best bet would probably be to do something like this:
void ArcherArmor::ArcherArmor_shop(){
soldier_armor[1] = Armor("Meito Ichimonji", 4, 150, 1);
soldier_armor[2] = Armor("Shusui".......
//and so on....
}
JasonHippy 739 Practically a Master Poster
C++ is case sensitive. Change line 5 of your header file from class salaried
to class Salaried
(Note the uppercase S) and that problem should go away!
Effectively you have declared a class called salaried in your header, yet your cpp file contains definitions for Salaried. So the compiler is complaining that it doesn't know what 'salaried' is.
Also FYI: It looks as if you have the private and public members of your class the wrong way around. Shouldn't the member functions be public? and the data members private? You might want to review that! :)
JasonHippy 739 Practically a Master Poster
What about:cp*[24680].enc
or cp*[24680].*
?
So if the files are all in the current directory and you want to copy the even numbered ones to a sub-directory called "even" you could do the following:
Using cp (or mv):cp ./cp*[24680].enc ./even/
orcp ./cp*[24680].* ./even/
or using the find command:find ./ -type f -iname "cp*[24680].*" -execdir cp {} ./even/ \;
EDIT:
Note: Unless you specify a maxdepth for find, it will look for files recursively in any sub-directories, which you might not want it to do.
To make it only search in the current directory you can do this:find ./ -maxdepth 1 -type f -iname "cp*[24680].*" -execdir cp {} ./even/ \;
JasonHippy 739 Practically a Master Poster
BUFSIZE is exactly what its name implies. It is the buffer size. The maximum amount of data to send/receive in bytes.
Regarding the error message:
This error is exactly the same error I encountered and fixed in your other thread. It is to do with the strings used in python3's implementation of sockets.
Sockets use byte-encoded strings, whereas standard strings are in Unicode. So in order to send the string held in the variable called 'data' from your client to the server, you first need to convert the string to a byte string using the encode() function.
So line 17 of client.py becomes:udpCliSock.sendto(data.encode(), ADDR)
Optionally, at line 22:print(data.decode())
This converts the string received back from the server into a Unicode string. So for example, if the user typed hello
; Without the call to decode, the bounced back string is printed as b'hello'. Which indicates that the string is still in byte-string format!
Whereas with the call to decode in place, the string is printed as standard. i.e.:hello
WRT changing the program to send and receive a simple "hello world", is this what you want?
client.py:
#!/usr/bin/python3
import socket
HOST = 'localhost'
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST, PORT)
# Connect to server via a socket
udpCliSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# send some data to the server
data = "Hello world!"
udpCliSock.sendto(data.encode(), ADDR)
# wait for the server to send something back
data, ADDR = udpCliSock.recvfrom(BUFSIZ)
# print what we get …
JasonHippy 739 Practically a Master Poster
Wow, coming back to it with a fresh set of eyes, I see what you mean Mike.
I'm not sure how I missed seeing all of those new's last night, they actually stick out like a sore thumb don't they?! :/
In my defense, I did write that post at stupid O'clock in the morning after a very long day. It was one of the last posts I made before bed yesterday (or this morning) So I was pretty frazzled!
When I scanned through the code, I'll admit, I didn't read every line. I just very quickly (and lazily) scrolled through, the structure of the code generally looked OK. And I'm guessing I must have scrolled past some of those blocks containing lots of new statements, because ordinarily there's no way I would have missed something like that! :/ Shocking!
JasonHippy 739 Practically a Master Poster
Basically, as far as I understand it, there are two types of string in Python3: Byte-strings and Unicode-strings.
The sockets in Python3 aren't aware of the different string encodings, so they only use raw byte-strings. So when passing a unicode string via a socket, you need to convert it to a byte-string using .encode().
Likewise, when receiving a byte-string from a socket to put into a string variable, you need to convert it to a unicode string using .decode()
Not sure why you're having problems there. Both programs work fine for me! I ran the server and the client, typed a couple of messages and then broke out of both programs with ctrl-c.
Here's the output I get from the server:
$ ./server.py
waiting for connection...
...connected from: ('127.0.0.1', 45060)
waiting for connection...
^CTraceback (most recent call last):
File "./server.py", line 17, in <module>
tcpCliSock, addr = tcpSerSock.accept()
File "/usr/lib/python3.2/socket.py", line 132, in accept
fd, addr = self._accept()
KeyboardInterrupt
And here's what was in the terminal running the client:
$ ./client.py
> hello
[b'Fri Jan 17 00:57:36 2014'] hello
> This seems to work!
[b'Fri Jan 17 00:57:51 2014'] This seems to work!
> ^CTraceback (most recent call last):
File "./client.py", line 14, in <module>
data = input('> ')
KeyboardInterrupt
So the client correctly sends data to the server and the server responds by sending a string back to the client.
JasonHippy 739 Practically a Master Poster
I recommend running a debug build of your program from your IDE.
There should be an option somewhere to Debug, or start debugging, or some-such. I haven't used Dev-c++ for at least 8 years, so I really can't remember a lot about it.
Anyway, switch your build profile to a debug build, which will include additional information in your executable that will aid your debugging session. Then build your program in debug mode and start running/debugging your program.
When your program eventually crashes, you should get the option to break out at the line where the program crashes.
If the debugger breaks out at a line of code in your program, then congratulations, you have found where your crash is occurring. Now you need to work out why that line of code is failing. So stick a few breakpoints somewhere near that line of code and run another debug build. Every time a breakpoint is hit, you'll be taken back to your IDE at the appropriate line and you can step through the code and examine the state of any variables that are in scope. And you can check other things like the current call-stack etc. With a bit of time and persistence, you should be able to work out what the problem is.
If the debugger breaks you out to a disassembled version of a system file/library, you need to take a look at your call-stack window and track back through the call-stack to the first line …
JasonHippy 739 Practically a Master Poster
In answer to your questions:
1: I think the first socket in socket.socket is the package name and the second one refers to the socket class which resides in that package.
2: I don't know, but it does! Heh heh!
No, seriously... It is possible for Python functions to return more than one value. I think it's a Tuple that gets returned.
3: Reasons the client's not working? Hmmm.... You did make sure you started running the server before running the client didn't you? :P
Actually, I just tried running your client without the server on my *nix laptop and got a completely different error to the one you are seeing. So I don't think that is your problem.
Running the server and then running the client worked for me, without any errors.
'Network is unreachable' Sounds like the connection to localhost cannot be established. Is it possible that something like a firewall rule on your machine is preventing the client from connecting? Or have you accidentally disabled networking in the network manager applet? IDK. Could be any number of things!
Your client program works for me, right up until I send some data to the server. Then the client bombs out with an error:
TypeError: str does not support buffer interface
As this is python3, at line 17 of client.py, you need to encode the data to convert it to bytes:tcpCliSock.send(data.encode())
You also need to decode the data when it is received by …
JasonHippy 739 Practically a Master Poster
I assume that sub1 - sub6 are the sub-totals for each person. In which case, rather than having 6 separate sub-totals, would it make sense to put them into a single array?
Also with the totals in an array, you could then use a loop to go through each persons data and store each persons total in the appropriate place in the array of totals.
In fact looking at your code again, would it not be better to use something like a Record to store the details for each person (name, status, country, total)?(see here for more on records).
That way, rather than having 6 peoples data spread out across four different arrays, you have a single array containing 6 Records, one for each person.
Records allow you to collect several different types of related data in one single type.
If you haven't covered Records in your programming class yet, ignore the suggestion. But if you are aware of them, it might be worth considering. It would clean up your code quite a bit!
JasonHippy 739 Practically a Master Poster
rmp file? As in a RealAudio media file? Have you tried installing a media player that can play them??
Or do you mean a .rpm file?
If so, which Linux distro are you running?
If it is a distro which uses the Red Hat package management system, it could be as simple as using:rpm -ivh /path/to/package
Or you might want to consider using yum if the program is already in your chosen distros repository.
But if you are using a distro which uses a different package management system, then it's going to be tricky to nigh on impossible.
For example, on a Debian based system; if there are no .deb packages available for a program and the only package available is a .rpm; there is a program called Alien which can convert .rpm's to .debs, which can then be installed using dpkg.
But your mileage may vary! It's not guaranteed to work for every package. I could be wrong, but I think .deb's converted from .rpm's will only successfully install if they are LSB compliant (Linux Standards Base - An attempt to standardise Linux using .rpm as the de-facto package management system). And even then it's not guaranteed!
On distros like Arch or Gentoo, which have their own packaging systems; I don't know of any ways to convert .rpm to pacman or portage format offhand.
In all of these cases, if there aren't any native packages available for your chosen distro, you'd almost certainly be better off building …
JasonHippy 739 Practically a Master Poster
No probs. Glad to have helped.
As a Haskell newbie myself, I know how frustrating it is when first starting out. Haskell is unlike any other programming language I have ever used. It's taking some time to get used to, but I think it's starting to finally sink in! Heh heh!
One other thing; if this has answered your question, could you please mark as solved? Thanks!
JasonHippy 739 Practically a Master Poster
Wow, it's the thread that just keeps giving! :)
I'm glad it's been of some use!
JasonHippy 739 Practically a Master Poster
I don't know of any built in pow function in Haskell (I'm still a novice with it myself), but off the top of my head, you should be able to create a simple pow function like this:
pow :: Int -> Int -> Int
pow x y = x^y
Which you call like this:
pow 3 2
Where 3 is the base value and 2 is the exponent, which should calculate and return the value of 3^2, which is 9!
With regards to the rest of your program, I'm a little confused. The description doesn't make sense.
I'm assuming you need to get the user to input a value for n, which you need to check is positive.
If the value is acceptable, you then calculate the series of values. Looking at the formula you have given, it looks as if it will require a recursive function starting with n^2 and counting down on each recursive call until you get down to 1.
So using the pow function above, we could create a simple recursive function like this:
powthing :: Int -> Int
powthing n
| n < 1 = 0
| n == 1 = 1
| otherwise = pow n 2 + powthing (n-1)
Note: I had no idea what to call this function, so I've simply called it powthing! :)
In the above function, we have a few checks against the value of n. If n<1 we return 0, if n==1 we return …
JasonHippy 739 Practically a Master Poster
Until I got to grips with vim, I used to use nano quite a lot for editing text files on the command line. It took a little while to get my head around using vim, but learning to use it properly was time well spent IMHO!
Nowadays, I seem to spend a LOT of time with vim in the terminal. In fact I'd now go as far as saying it is my favourite text editor full-stop. Since learning to use vim, I've found that I can be far more productive using vim than any other editor I have tried before. But that's just my experience. Your mileage may vary! Heh heh!
I've even started using vim extensively on my Windows machine at work (via Cygwin terminal). On my 2nd monitor, I always have two cygwin terminals open. One for diffing/editing files in vim and another for running scripts and grepping through our code-repositories. Going off-topic here, but using grep seems to be much faster than using VS's built in search functionality. Often, when wanting to look something up in VS - I have to wait for the intellisense database to finish rebuilding. And it always seems to rebuild itself at the most inopportune moments. Whereas grep just starts searching instantly and generally tends to return results quicker than VS's search functionality. I only tend to use VS for debugging nowadays!
Getting back on topic:
At the end of the day a text editor is a text editor. Just another …
JasonHippy 739 Practically a Master Poster
The modulus operator returns the remainder after the division operation. So 3%5 returns 3 because 3 divides by 5 zero times and the remainder is 3.