i am trying to create random data so i can review an algorithm in cache policy. When i use the first code with rand() i get the same numbers every time i run my code(i knew this was coming) so i tried to use srand. when i inserted it i get different numbers every time i run the code but the same 10 numbers at my loop. What am i doing wrong to create random data??? After that i will make with zip ununiformed data. sorry my bad the loop is in main function: for(counter=0; counter&lt;10; counter++){     printf(&quot;Number %d is %lf\n&quot;, counter, rand_val()); }  And i am using this function to create numbers. double rand_val(){  double rnum;  srand(time(NULL)); rnum=rand();  return(rnum); }
I need a 'good' way to initialize the pseudo-random number generator in C++. I've found  that states:     In order to generate random-like   numbers, srand is usually initialized   to some distinctive value, like those   related with the execution time. For   example, the value returned by the   function time (declared in header   ctime) is different each second, which   is distinctive enough for most   randoming needs.   Unixtime isn't distinctive enough for my application. What's a better way to initialize this? Bonus points if it's portable, but the code will primarily be running on Linux hosts.  I was thinking of doing some pid/unixtime math to get an int, or possibly reading data from /dev/urandom.  Thanks!  EDIT  Yes, I am actually starting my application multiple times a second and I've run into collisions.
What makes SHA-256 secure? For example, RSA relies on a mathematically hard problem, factoring, while ECDSA or similar rely on discrete logarithm problem.  What makes SHA-256 and similar hash functions, of the same family, secure against pre-image and collision attacks? What's the math behind it? Calling a method in java and returning beer cost Changing Date format and appending to original file I have file like this called a.txt:  [2016-03-30T04:51:51.599-04:00]!ER_DEV!Port_Conflict!/u05/app/ [2016-01-20T04:30:21.885-04:00]!ER_DEV!Port_Conflict!/u05/app/   I need to modify it so it looks like:    2016-03-30 04:51:51!ER_DEV!Port_Conflict!/u05/app/   2016-01-20 04:30:21!ER_DEV!Port_Conflict!/u05/app/   i already wrote a command to change [2016-03-30T04:51:51.599-04:00] to 2016-03-30 04:51:51 .but how to append the query output to original file.    awk -F'!' '{print $1}' a.txt | awk -F '[T.]' '{print $1 " " $2}' | awk '{gsub(/\[/,"")}1' Is an empty set equal to another empty set? Einstein-Cartan theory - Book recommendation I want to delve into Cartan's formulation of General Relativity but it don't really know where to look. Does anyone have any book suggestions? Is there a robust command line tool for processing csv files? I work with CSV files and sometimes need to quickly check the contents of a row or column from the command line.  In many cases cut, head, tail, and friends will do the job; however, cut cannot easily deal with situations such as  "this, is the first entry", this is the second, 34.5   Here, the first comma is part of the first field, but cut -d, -f1 disagrees. Before I write a solution myself, I was wondering if anyone knew of a good tool that already exists for this job.  It would have to, at the very least, be able to handle the example above and return a column from a CSV formatted file.  Other desirable features include the ability to select columns based on the column names given in the first row, support for other quoting styles and support for tab-separated files.  If you don't know of such a tool but have suggestions regarding implementing such a program in Bash, Perl, or Python, or other common scripting languages, I wouldn't mind such suggestions. chown -R root.root / So I was working and there was a directory that I was periodically changing to my user in  a root terminal so that I could open the files in text editors, but I accidentally pressed / instead of . and this was the command I put out:  chown -R emil.emil /   Then immediately panicked ^C and put in another command, as I thought I could always change back the files I needed to access:  chown -R root.root /   So now I can't do su from emil to even try to fix this, as I'm getting permission denied error. I'm on Ubuntu could someone tell me if there is a way I could fix this, without absolutely reinstalling the whole thing.  TIP  If you are trying to get root access, and are getting this permission denied error when using su try this command:  gksu gnome-terminal   It will prompt you for the root password and open a new root terminal for some reason this works and gives me root access, when su doesn't. Israel visa stamp issue I am an Indian national living in London. I need to travel to Israel for work. I will need to apply for a visa but I have been told that it will be stamped in my passport. I have read that Israel knows of the problems travellers face in other Arab countries so they issue a paper visa but the embassy in London told me that it will be stamped in. I travel often in Middle East for work and I do not want any issues in the future. Please advise.  Thanks. How do you make Ubuntu accept files sent over bluetooth Proving that $\lim_{x \to 0} \frac{f(x)}{|x|}=1$ implies $f$ is not differentiable at $0$. Wrong place for hyperref link in scaled tikz picture I have a TikZ picture with a node containing a minipage with an itemize environment; each item is a hyperref to other sections of the document.   When scaling the image (for example with \begin{tikzpicture}[scale=.7, transform shape] I've a strange behavior: links in itemize are not in the right place: they present a somewhat vertical offset, as if they don't scale as the rest of image.   Here the MWE:  \documentclass[a4paper]{article} \usepackage{tikz} \usepackage[pdftex]{hyperref} \begin{document}  Here something interesting\label{text:interesting-one} \newpage  Here something interesting, too\label{text:interesting-two} \newpage  and here there are very very interesting stuff\label{text:interesting-three} \newpage  \newpage Now the problem: links rectangles have some offset, making links unusable in case of long itemize  \begin{figure}[htb] \begin{tikzpicture}[scale=.7, transform shape] \node at (0,0) (mynode) { \begin{minipage}{4cm} \begin{itemize} \item \hyperref[text:interesting-one]{First link} \item \hyperref[text:interesting-two]{Second link} \item \hyperref[text:interesting-three]{Third link} \item \hyperref[text:interesting-one]{First link again} \item \hyperref[text:interesting-two]{Second link again} \item \hyperref[text:interesting-three]{Third link again} \end{itemize} \end{minipage} }; \end{tikzpicture} \end{figure} \end{document}   And here a snapshot of the problem    Note: This is evident using the default settings of hyperref package, which draws the red rectangle around links, but it took me some time to found it when only the text is coloured, i.e. when using \usepackage[linkcolor=blue,colorlinks=true]{hyperref} Ubuntu: Resize the root LVM(2?) partition For only my index pages, I am receiving this warning in Google Search Console:     Duplicate, submitted URL not selected as canonical   I know that this occurs because Google is attempting to track both the default landing "page" (i.e. www.domain.example/) and the page to which to which DirectoryIndex points (i.e. www.domain.example/index.html). They are, in fact, the same page, and so the warning is the result of a false positive.  Two questions for our community:   Why does Google not conflate these and count them as a single page? Alternately, is there something wrong with my set up if this has happened? I can easily force both pages to point to a single canonical URL. But which is preferable, "/" or "index.html"? DDL Trigger in MySQL? I have encountered this question while tring to figure out why every sequential space $X$, is a quotient spaces of a metric space. If I understand correctly, given a sequential space, every sequence (including it's limit) can be identified with the space $Y=\{0\} \cup \{\frac1{n+1}|n \in N\}$. So The space $X$ can viewed as a quotient space of $\bigoplus_{(x_n) \in C} \{(x_n) \} \times Y$ where $C$ is the set of all converges sequences in $X$. My question is, How can I show that this space is metrizable?  Thank you! Shir If granted omniscience and we know that $\beta_1$ in a multiple linear regression model is truly 0, what does that mean in words (and math notation)?  The model is: $Y = \beta_0 + \beta_1X_1 + \beta_2X_2 + \epsilon$  Does $\beta_1 = 0$ mean:   Empirically: "If we make infinite, perfect measurements of our data, $\hat\beta_1$ approaches 0 at the limit?" [Math: ??] Formally: "In the true, finite population of our data, $X_1$ has 0 association with $Y$ and their vectors of values are perfectly linearly independent, uncorrelated, and orthogonal?" [Math: ??]   What does $\beta_1 = 0$ mean, precisely? Write a number with two decimal places SQL Server I need to do an  request in JavaScript. What's the best way to do that?  I need to do this in a Mac OS X dashcode widget. How to check if a 2D point is in a polygon? From Manila to Canada via France and Italy I intend to apply for a tourist visa to Canada and a tourist Schengen visa. My itinerary will be from Manila to Paris, France to Rome, Italy then Canada where I plan to visit/stay for 2-3 months with an invitation letter from my daughter who is a permanent card holder. I understand I have to buy a return  ticket from Canada to Manila where I reside. Is this a feasible itinerary?  Will this affect my chance of getting a Schengen or even a visa to Canada as this is my first time to apply for a tourist visa to these countries although I have been to several countries in Asia like Japan, Korea, Hongkong, Macau, Singapore, Thailand, Malaysia, Indonesia, Vietnam, Cambodia to name a few. Will the consul in the France Embassy here in Manila look for a return flight from a member country to Manila?