How to use Google's Sparse Hash - hash

In my project, I am asked to use Google's Sparse Hash. But I don't even know where to start. These are steps that I take and do not get my code even compiled:
The sparsehash-1.11 code is in the same directory with where my code is.
I typed "#include " at the beginning of my code.
The error is
Multiple markers at this line
- fatal error: google/sparse_hash_map: No such file or directory
- Unresolved inclusion: <google/sparse_hash_map>
I really don't know what to do. Waiting for your helps.

Sorry if this is obvious, but if your google hashmap source is already in the same directory as your code is, you should probably try:
#include "sparse_hash_map"
instead of
#include <google/sparse_hash_map>
Worse case, include -I</directory/to/google/sparse_hash_map> in your compile command line.
Good luck!

You could locate sparse_hash_set in your computer ( locate sparse_hash_set ) and create a symbolic link from the directory where sparse_hash_set is installed to google/sparse_hash_map.
test#ubuntu:~# updatedb # To update the locate database
test#ubuntu:~# locate sparse_hash_map
/usr/include/google/sparsehash/sparse_hash_map
test#ubuntu:~# ln -s /usr/include/google/sparsehash/sparse_hash_map /usr/include/google/sparse_hash_map

Related

Trouble creating symlinked folder

I am following the DrizzlexReact tutorial # https://truffleframework.com/tutorials/getting-started-with-drizzle-and-react
I've reached a point where I have to symlink my contract folder using the command: 'mklink \D contracts ....\build\contracts'.
When typed as is from the tutorial I get a "The syntax of the command is incorrect" error.
I've even tried quotes around the file names/paths. Nothing.
Any advice? Thanks
It was a '/D, as per mklink docs & not '\D', as per the tutorial.

locate j*.vim doesn't work?

I've read the locate man page and searched this site, but I don't see how to do this:
I'm looking for all *.vim files starting with j. How can I use locate to achieve this?
[docker#docker1 ~]$ locate java.vim
/usr/share/vim/vim74/ftplugin/java.vim
/usr/share/vim/vim74/indent/java.vim
/usr/share/vim/vim74/syntax/java.vim
[docker#docker1 ~]$ locate "j*.vim"
[docker#docker1 ~]$
You have to use find command.
Just type find -name "j*.vim" and you will get expected search result.
I found the answer here, and it's simple. Locate stores the whole path, so you need a wildcard on BOTH sides on your search terms:
docker#docker1:~$ locate '*jav*.vim'
/usr/share/vim/vim74/autoload/javascriptcomplete.vim
/usr/share/vim/vim74/compiler/javac.vim
/usr/share/vim/vim74/ftplugin/java.vim
You can, of course, also resort to regular expressions:
docker#docker1:~$ locate -r 'jav.*.vim'
/usr/share/vim/vim74/autoload/javascriptcomplete.vim
/usr/share/vim/vim74/compiler/javac.vim
/usr/share/vim/vim74/ftplugin/java.vim

Unsure of how to proceed with creating ec2-consisten-snapshot

I was just put on a task to try and debug and figure out why our ec2-consistent-snapshot script isn't working.
Our lead programmer followed this blog post.
We have a .sh script that we'd like to take the snapshot and it looks like this:
#!/bin/sh
/opt/aws/bin/ec2-consistent-snapshot --aws-access-key-id MYACCESSKEY --aws-secret-access-key MYSECRETKEY --freeze-filesystem /vol --mysql --mysql-host localhost --mysql-socket /var/lib/mysql/mysql.sock --mysql-username USERNAME --mysql-password PASSWORD --description "Demo MySQL data volume: $(date +%c)" vol-MYVOL
If I run this by doing sudo ./snapshot_script.sh I get a single error:
ec2-consistent-snapshot: ERROR: create_snapshot: File does not exist: at /usr/share/perl5/vendor_perl/Net/Amazon/EC2.pm line 232
I of course followed this error and line 232 in EC2.pm is this:
my $ref = $xs->XMLin($xml);
I have 0 perl experience and I don't know what this could be doing.
Any help would be wonderful.
The Net::Amazon::EC2 that I'm looking at on CPAN has that line at 252, not 232 so perhaps you are not on the latest version. Looking above that line, the program has attempted to do a "query to sign" using lots of the security parms. I suspect there is a problem with the authentication keys you are using. There is a debug flag, you might want to turn that on to generate more messages.
If you go to this page, you will see that XMLin() is a function of XML::Simple, and it takes a file as an argument. So, $xml is presumably a variable that contains an xml file name. That file does not exist.
The next step would be to trace the error back into the source code of ec2-consistent-snapshot, in order to see how it is calling XML::Simple and where the bad value gets passed in.

Error while try to rename a file name in matlab

This is my code:
filename_date = strcat('Maayanei_yeshua-IC_',file_date,'.pdf')
filenamepdf = strcat(filename,'.pdf')
rename(['C:\Users\user\Desktop\' filenamepdf],['C:\Users\user\Desktop\' filename_date]);
And i get the error:
<??? Error using ==> movefile The system cannot find the path specified.>
or
<??? Undefined function or method 'rename' for input arguments of type 'char'.>
I checked hundreds of times and the file is there... i don't know why it can't find it, any help ?
Use the command
doc rename
to discover that rename is for working with ftp servers, which you are not doing here. What you want is the command movefile
Use the help window brought up by helpwin to look up all the commands you are using.
Also, from the command prompt try
dir(['C:\Users\user\Desktop\' filenamepdf])
to verify the file you want to move exists.

How can I resume downloads in Perl?

I have a project that depends upon some other binaries to be downloaded from web at install time.For this what i do is:
if ( file-present-in-src/)
# skip that file
else
# use wget to download the file
The problem with this approach is that when I interrupt a download in middle, and do invoke the script next time, the partially downloaded file is also skipped (which is not desired), also I want wget to resume the download of the partially downloaded file.
How should I go about it:
Possible Solutions I could think of:
Let the file to be downloaded to some file say download_tmp. Move to original file
if successful.
Handle SIG{'INT'} to write proper cleanup code.
But none of these could help resume the partial file download,
Any insights?
Fist, I don't understand what this has to do with Perl, since you're using wget to do the dowloading ... You could use libwww-perl (perldoc LWP) and have more control about the download process.
Then I second your idea of downloading to a "tmp" filename and move the file on success.
However I think you need to go further and verify the integrity of the files. Doing an MD5 or SHA hash is very easy, and match the downloaded one with what you're expecting. You can have a short file on server containing the checksum (filename.md5). Determine success only when you have a match.
Note that catching all the signals and generally trying to make the process unkillable, and then expecting it to have worked is bound to fail at one point or another. There could be a network timeout, a crash, power failure, configuration problem on the server ... you should instead assume downloads can fail, because they will, and code so that your process can recover.
Finally you're not telling us what kind of binaries you're downloading and what you're doing with them. Since you use wget I'm going to assume you're on Unix; you should consider using RPM+Yum or the likes, they handle all this for you. RPM are easy to write, really.
use your first approach ..
download to "FileName".tmp
move "FileName".tmp to "FileName" move! not copy
once per diem clean out all .tmp files (paranoia rulez)
You could just use wget's -N and -c options and remove the entire "if file exists" logic.