Is there a predefined inverse of gmtime_r? mktime converts it as if it were local time. Do I need to pick up current time-zone and correct it manually?
Use the timegm() function.
In my man page (OS X), it's described in the same paragraph as mktime. On Linux, it's listed in the SEE ALSO section.
Related
I would like to be able to check if two words are similar (using the path similarity) in WordNet with Prolog.
I found on the internet this article doing exactly what I want.
I'll paste here the steps needed to let this work:
Download WordNet 3.0 Prolog version from
http://wordnetcode.princeton.edu/3.0/WNprolog-3.0.tar.gz
and unzip it in a directory of your choice. For example:
c:\wn_prologDB
Set the environment variable WNDB to this newly created directory.
For example, use either the system dialog box in Control Panel
(Environment Variables), or write in a Command Prompt (cmd.exe):
set WNDB=c:\wn_prologDB
Download the modules of WN_CONNECT from
https://dectau.uclm.es/bousi-prolog/applications and unzip
it in a directory of your choice. For example:
c:\wn
Add to the PATH environment variable the directory where this tool
is located (similar to step 2 above):
set PATH=c:\wn;%PATH%
Open a terminal and execute the shell script:
wn.sh
I followed those steps, and run wn.bat (since I'm using windows).
As you can see from the picture, the wn_word_info predicate is working, while I cannot understand why wn_path is not working.
Here is the signature:
wn_path(+Word1, +Word2, -Degree)
Any tips on how I could get it to work? Or any solution to calculate path similarity?
The signature was a bit different:
wn_path(+Word1:SS_type1:W1_Sense_num, +Word2:SS_type2:W2_Sense_num, -Degree)
So this actually works:
wn_path(cat:A:B, dog:C:D, E).
Here I'm specifying only the word and the other parameters are variables, but one can specify all three the parameters.
I paste here some of the docs I found in the WN_CONNECT folder:
** wn_path(+Word1:SS_type1:W1_Sense_num, +Word2:SS_type2:W2_Sense_num, -Degree):
This predicate implements the PATH similarity measure.
Takes two concepts (terms -- Word:SS_type:Sense_num) and returns the degree of similarity between them. Note that we do not explicitly require information about the synset type and sense number of a word (that can be variables).
I have unix timestamp in table, wants to show to user using Carbon. How can I achieve ?
e.g.
1487663764.99256 To
2017-02-24 23:23:14.654621
Did you check the carbon docs? I think this is what youre looking for:
Carbon::createFromTimestamp(-1)->toDateTimeString();
Checkout http://carbon.nesbot.com/docs/#api-instantiation
There are several ways to create Carbon instances described in the Carbon documentation, which is linked at the bottom of the project's README. The relevant section is this:
The final two create functions are for working with unix timestamps. The first will create a Carbon instance equal to the given timestamp and will set the timezone as well or default it to the current timezone. The second, createFromTimestampUTC(), is different in that the timezone will remain UTC (GMT). The second acts the same as Carbon::createFromFormat('#'.$timestamp) but I have just made it a little more explicit. Negative timestamps are also allowed.
So you can just do:
$carbon = Carbon::createFromTimestamp($dbResult['SomeTimestampColumn']);
If you really love your fluid method calls and get frustrated by the extra line or ugly pair of brackets necessary when using the constructor you'll enjoy the parse method:
Carbon::parse(1487663764);
Carbon::parse('first day of next month');
I am wondering what is a good way to use Python to generate an arithmetic worksheet consisting only of 2-digit numbers squared. Specifically I want to be able to call upon a Python program in which it asks me for parameters such as the range of the numbers in can call upon to square and the number of questions I want to generate. Once that is done the program will generate the numbers and then automatically open up a .tex file (already with preamble and customizations) and basically do a loop for each question like this:
\begin{exer}
n^2
\end{exer}
%%%%%Solution%%%%%%
\begin{solution}
n^2=n^2
\end{solution}
for some integer n.
Once it is done writing the .tex file then it will run xetex and output the pdf ready to use and print. Any help or suggestions? Python is preferred but not mandatory.
Actually your problem is so simple that doesn't require any special magic. However I would suggest you don't try to append your generated content into a file you already have with preamble, good practice is to leave it untouched and include (in fact you can copy it on generation or use TeX \include).
Now, let's add more to the generation. Python formatter is your friend here, you use the example you've given as a template, and write the product into a file in every iteration. Don't forget to escape "{" brackets, as they're symbols used by formatter.
At the end, (suggestion) you can subprocess to launch XeTeX - depending on your need call() is enough or use popen().
Is there a way to quickly find where a variable was initially defined/declared in Mathcad.
I'm working in a rather large Mathcad (150 pages get printed). I'll see an equation that is using variables declared in earlier sections however I can't use the Edit->Find since the variable uses subscripting. I resort to eye scanning for the variable declaration.
In Eclipse you can control click on a variable and it will take you to the variables declaration. Is there something similar in Mathcad?
Unfortunately, there isn't a 'search for definition' feature. I believe that there have been a number of requests for it over the years ...
Why can't you Edit/Find, though? Which kind of subscripting are you referring to: index or name? Which version of Mathcad are you using?
Search for an array name shouldn't be a problem, as the index won't form part of the name.
If you want a subscripted name and you are using Mathcad 15 (or lower), then simply type the name as you would enter it; eg if your variable is xsub then type x.sub in the find box.
I would like to create a list of all available pixel formats for OpenGL. On Windows, I can do this by calling DescribePixelFormat in a loop, increasing the pixel format id, until it returns false.
Unfortunately, it seems that aglDescribePixelFormat does not work like this. Its AGLPixelFormat parameter is a pointer to an opaque struct - I can't call this in a loop.
Apple's documentation doesn't provide any hints either, nor does google. Any AGL experts out there willing to share their knowledge?
Edit: I've seen mention of a aglListPixelFmts() function but this is not listed in agl.h, nor can I find any mention in Apple's documentation. What gives?
Actually, Apple's documentation does give a hint. Under aglDescribePixelFormat, it says:
To retrieve the data in pixel format
objects other than the first one in
the list, call aglNextPixelFormat.
Then pass the returned pixel format
object to aglDescribePixelFormat to
retrieve an attribute value.