Lua lcurses missing tutorial/axamples [closed] - lua

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I've installed lcurses (luarocks + luajit) but I'm not able to find any tutorial.
I'm reading about ncurses with C language trying to replicate code on lua
but the lua porting is not a C library direct match.
Here are the two "Hello World" example:
lua version
package.path = package.path .. ';/opt/luarocks_pkg/share/lua/5.1/?.lua';
package.cpath = package.cpath.. ';/opt/luarocks_pkg/lib/lua/5.1/?.so';
local curses = require('curses');
local os = require('os');
local function main()
--start curses mode
curses.initscr()
--disable line buffering
curses.raw();
--switch off echoing
curses.echo(false);
--initialize standard screen object
local stdscr = curses.stdscr()
--clear screen
stdscr:clear();
--move cursor at (10,10) and print, here only update the stdscr structure
stdscr:mvaddstr(10,10,'Hello World');
--force curses system to dump the contents on the screen
stdscr:refresh();
--wait for keyb input
stdscr:getch();
--frees the memory taken by curses sub-system and its data structures and puts the terminal in normal mode
curses.endwin();
return(0);
end
main()
C version
#include <ncurses.h>
int main()
{
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */
return 0;
}
Replicating C code in lua require a lot of time (to learn how to use lcurses), so I'll appreciate if someone can help me by reporting where I can find a lcurses lua tutorial.

Try lcurses documentation. It indicates that the API is the same so you should be able to get the details from your system's curses or ncurses man doc. If you can't do "man ncurses" or "man curses" (as documented on that link), then you can surely find some online versions:
Same as above, but hyperlinked to actual function docs
Introduction to ncurses
Ncurses howto
ncurses faq
Programmers Guide to ncurses
The intro to ncurses and the howto should provide what you need. Beyond that tou will have to purchase the book. Beyond that you are out of luck, so either way this answer should be closed.

Related

Setting php encoding for v.7.2 [duplicate]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Why does
<?php
echo "HELLO WORLD 1"; // shows
error_reporting(E_ALL);
echo "HELLO WORLD 2"; // shows
print_r(mb_list_encodings()); // does not show
echo "HELLO WORLD 3"; // does not show
$result = mb_convert_encoding("apple", 'UTF-8');
echo "HELLO WORLD 4"; // does not show;
echo $result; // does not show;
// no error what so ever displayed.
?>
fail? What can make this function fail?
I have a PHP web page that runs code and halts at this line, and returns HTTP 500 error.
But I don't know why it fails. Any suggestion for where to check?
Update:
Error Log shows
PHP Fatal error: Call to undefined function mb_convert_encoding()
PHP Fatal error: Call to undefined function mb_convert_encoding()
That means mb_convert_encoding is not installed, because the MB extension is not installed on your version of PHP. How to install it depends on how you installed PHP. Mostly likely your operating system has a package manager (apt-get or such) that will allow you to install it quickly. Otherwise, see the manual.

OpenCV TBB IPP OpenMP functions

Is there a list of functions/methods of OpenCV that have been optimized with IPP and/or TBB and/or OpenMP?
Disclaimer: I have no experience in OpenCV usage.
I found no such a list on the official opencv.org site. However, the ChangeLog says:
switched all the remaining parallel loops from TBB-only tbb::parallel_for() to universal cv::parallel_for_() with many possible backends (MS Concurrency, Apple's GDC, OpenMP, Intel TBB etc.)
Now, we know what to search and grep -IRl parallel_for_ applied on opencv directory gives us the following:
build/include/opencv2/core/core.hpp
sources/apps/traincascade/boost.cpp
sources/modules/calib3d/src/stereobm.cpp
sources/modules/contrib/src/basicretinafilter.cpp
sources/modules/contrib/src/magnoretinafilter.cpp
sources/modules/contrib/src/parvoretinafilter.cpp
sources/modules/contrib/src/retinacolor.cpp
sources/modules/contrib/src/templatebuffer.hpp
sources/modules/core/include/opencv2/core/core.hpp
sources/modules/core/src/matrix.cpp
sources/modules/core/src/parallel.cpp
sources/modules/core/src/stat.cpp
sources/modules/features2d/src/detectors.cpp
sources/modules/gpu/src/calib3d.cpp
sources/modules/highgui/test/test_ffmpeg.cpp
sources/modules/imgproc/src/clahe.cpp
sources/modules/imgproc/src/color.cpp
sources/modules/imgproc/src/distransform.cpp
sources/modules/imgproc/src/generalized_hough.cpp
sources/modules/imgproc/src/histogram.cpp
sources/modules/imgproc/src/imgwarp.cpp
sources/modules/imgproc/src/morph.cpp
sources/modules/imgproc/src/smooth.cpp
sources/modules/imgproc/src/thresh.cpp
sources/modules/ml/src/ann_mlp.cpp
sources/modules/ml/src/gbt.cpp
sources/modules/ml/src/knearest.cpp
sources/modules/ml/src/nbayes.cpp
sources/modules/ml/src/svm.cpp
sources/modules/nonfree/src/surf.cpp
sources/modules/objdetect/src/cascadedetect.cpp
sources/modules/objdetect/src/haar.cpp
sources/modules/objdetect/src/hog.cpp
sources/modules/ocl/src/kmeans.cpp
sources/modules/photo/src/denoising.cpp
sources/modules/stitching/src/matchers.cpp
sources/modules/superres/src/btv_l1.cpp
sources/modules/video/src/bgfg_gaussmix2.cpp
sources/modules/video/src/bgfg_gmg.cpp
sources/modules/video/src/lkpyramid.cpp
sources/modules/video/src/tvl1flow.cpp
Here, we see the list of modules and parts which use the parallel loop. I hope it's enough to answer the question for TBB and OpenMP. For more details, please open the corresponding file and search for parallel_for_ to find out in which circumstances it is applied.
As for IPP, it seems it is quite extensively used by the core library, egrep -IRl '\bipp' gives the following:
modules/calib3d/src/calibration.cpp
modules/core/include/opencv2/core/core_c.h
modules/core/include/opencv2/core/internal.hpp
modules/core/src/arithm.cpp
modules/core/src/dxt.cpp
modules/core/src/mathfuncs.cpp
modules/core/src/matmul.cpp
modules/core/src/precomp.hpp
modules/core/src/stat.cpp
modules/core/src/system.cpp
modules/imgproc/src/canny.cpp
modules/imgproc/src/color.cpp
modules/imgproc/src/deriv.cpp
modules/imgproc/src/distransform.cpp
modules/imgproc/src/filter.cpp
modules/imgproc/src/imgwarp.cpp
modules/imgproc/src/morph.cpp
modules/imgproc/src/samplers.cpp
modules/imgproc/src/smooth.cpp
modules/imgproc/src/sumpixels.cpp
modules/legacy/test/test_pyrsegmentation.cpp
modules/objdetect/src/haar.cpp
modules/objdetect/src/hog.cpp
modules/ocl/src/haar.cpp

iOS: Where to find the full list of OSStatus codes for iOS? [duplicate]

This question already has answers here:
How do you convert an iPhone OSStatus code to something useful?
(19 answers)
Closed 9 years ago.
I can easily find noErr = 0 in the OS X library source code. But it's pretty hard to find a full list of error code for OSStatus on iOS.
On Mac OS X, it's not that hard to find stuff like
kAudioHardwareUnsupportedOperationError
But I can't seem to find useful info for iOS OSStatus codes. It would be nice to have a full list of them or any pointers to the header files that define them.
Thanks!
UPDATE:
I don't think my question is a duplicate of the above question. The op of that "possible duplicate" question wanted to convert the 4-char codes he already knew into human-readable strings. Instead, here is my further spec:
I don't even know what 4-char or typedefed integers to use for iOS.
I'd like to see something like a full list of codes, like you would normally see in many C++ framework/library design, e.g., an enum list, or standard exceptions, or even the OSX k-something codes, which at least can be found in the Xcode docs alone.
My usecases of these codes include:
In my custom functions, e.g., some CoreAudio callbacks that have to return OSStatus, I'd like to return these built-in human-readable codes to indicate the types of runtime errors. Without the list, I don't know what to return, other than noErr.
Apparently, many OSX k-codes are undefined under iOS environment so they can't be used transparently.
UPDATE (CONCLUSION):
I finally found a clue: Search for keyword "Result Codes" in Xcode documentation (Organizer) and we get more or less categorized return codes documentation sections in the "System Guides" result. This is good enough for my original question. –
The best I can do to help is provide the results of using find from the command line:
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
$ find . -name \*.h -exec fgrep -l OSStatus {} \;
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioConverter.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioFile.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioFileStream.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioFormat.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioQueue.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioServices.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioSession.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/ExtendedAudioFile.h
./System/Library/Frameworks/AudioToolbox.framework/Headers/MusicPlayer.h
./System/Library/Frameworks/AudioUnit.framework/Headers/AUComponent.h
./System/Library/Frameworks/AudioUnit.framework/Headers/AudioComponent.h
./System/Library/Frameworks/AudioUnit.framework/Headers/AudioOutputUnit.h
./System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnitProperties.h
./System/Library/Frameworks/AudioUnit.framework/Headers/MusicDevice.h
./System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h
./System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h
./System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMAudioClock.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMBase.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMBlockBuffer.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMBufferQueue.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMFormatDescription.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMSampleBuffer.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMSimpleQueue.h
./System/Library/Frameworks/CoreMedia.framework/Headers/CMSync.h
./System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIDriver.h
./System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h
./System/Library/Frameworks/CoreMIDI.framework/Headers/MIDISetup.h
./System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIThruConnection.h
./System/Library/Frameworks/Foundation.framework/Headers/NSError.h
./System/Library/Frameworks/MediaToolbox.framework/Headers/MTAudioProcessingTap.h
./System/Library/Frameworks/Security.framework/Headers/SecBase.h
./System/Library/Frameworks/Security.framework/Headers/SecIdentity.h
./System/Library/Frameworks/Security.framework/Headers/SecImportExport.h
./System/Library/Frameworks/Security.framework/Headers/SecItem.h
./System/Library/Frameworks/Security.framework/Headers/SecKey.h
./System/Library/Frameworks/Security.framework/Headers/SecTrust.h
./System/Library/Frameworks/Security.framework/Headers/SecureTransport.h
./usr/include/AssertMacros.h
./usr/include/Endian.h
./usr/include/MacTypes.h

open web browser using lua in a vlc extension

I am writing a VLC extension in which i would like to open some url in a web browser( in lua of course ). So far, I have not been able to find any relevant code for opening the web browser from a lua script. Is there any way in which I can perform this task (say for example a google search of the file playing)?
I am able to create a link to the url using a dialog box, but i would like to skip this step and make it open without any user input.
I am a beginner to lua and to making VLC extentions( just started a few days back ) and have been trying things out since then.
The exact command varies between operating systems:
On Windows:
start http://example.com/
On *nix (most portable option):
xdg-open "http://example.com/"
On OSX:
open http://example.com/
The following Lua sample should work on Windows, Linux, and OSX (Though I cannot test OSX).
It works by first checking Lua's package.config for the \\ directory separator (which, afaik, is only used on windows). That should only leave us with OSes that support uname. Then I take a flying leap and assume that Mac will identify as 'Darwin', and thus anything that doesn't is *nix.
Obviously, this is somewhat less than exhaustive.
-- Attempts to open a given URL in the system default browser, regardless of Operating System.
local open_cmd -- this needs to stay outside the function, or it'll re-sniff every time...
function open_url(url)
if not open_cmd then
if package.config:sub(1,1) == '\\' then -- windows
open_cmd = function(url)
-- Should work on anything since (and including) win'95
os.execute(string.format('start "%s"', url))
end
-- the only systems left should understand uname...
elseif (io.popen("uname -s"):read'*a') == "Darwin" then -- OSX/Darwin ? (I can not test.)
open_cmd = function(url)
-- I cannot test, but this should work on modern Macs.
os.execute(string.format('open "%s"', url))
end
else -- that ought to only leave Linux
open_cmd = function(url)
-- should work on X-based distros.
os.execute(string.format('xdg-open "%s"', url))
end
end
end
open_cmd(url)
end

How to monitor a text file in realtime [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
For debugging purposes in a somewhat closed system, I have to output text to a file.
Does anyone know of a tool that runs on windows (console based or not) that detects changes to a file and outputs them in real-time?
I like tools that will perform more than one task, Notepad++ is a great notepad replacement and has a Document Monitor plugin (installs with standard msi) that works great. It also is portable so you can have it on a thumb drive for use anywhere.
For a command line option, PowerShell (which is really a new command line) has a great feature already mentioned.
Get-Content someFile.txt -wait
But you can also filter at the command line using a regular expression
Get-Content web.log -wait | where { $_ -match "ERROR" }
Tail for Win32
Apache Chainsaw - used this with log4net logs, may require file to be in a certain format
When using Windows PowerShell you can do the following:
Get-Content someFile.txt -wait
I use "tail -f" under cygwin.
I use BareTail for doing this on Windows. It's free and has some nice features, such as tabs for tailing multiple files and configurable highlighting.
Tail is the best answer so far.
If you don't use Windows, you probably already have tail.
If you do use Windows, you can get a whole slew of Unix command line tools from here. Unzip them and put them somewhere in your PATH.
Then just do this at the command prompt from the same folder your log file is in:
tail -n 50 -f whatever.log
This will show you the last 50 lines of the file and will update as the file updates.
You can combine grep with tail with great results - something like this:
tail -n 50 -f whatever.log | grep Error
gives you just lines with "Error" in it.
Good luck!
FileSystemWatcher works a treat, although you do have to be a little careful about duplicate events firing - 1st link from Google - but bearing that in mind can produce great results.
Late answer, though might be helpful for someone -- LOGEXPERT seems to be interesting tail utility for windows.
Try SMSTrace from Microsoft (now called CMTrace, and directly available in the Start Menu on some versions of Windows)
Its a brilliant GUI tool that monitors updates to any text file in real time, even if its locked for writing by another file.
Don't be fooled by the description, its capable of monitoring any file, including .txt, .log or .csv.
Its ability to monitor locked files is extremely useful, and is one of the reasons why this utility shines.
One of the nicest features is line coloring. If it sees the word "ERROR", the line becomes red. If it sees the word "WARN", the line becomes yellow. This makes the logs a lot easier to follow.
I have used FileSystemWatcher for monitoring of text files for a component I recently built. There may be better options (I never found anything in my limited research) but that seemed to do the trick nicely :)
Crap, my bad, you're actually after a tool to do it all for you..
Well if you get unlucky and want to roll your own ;)
Yor can use the FileSystemWatcher in System.Diagnostics.
From MSDN:
public class Watcher
{
public static void Main()
{
Run();
}
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public static void Run()
{
string[] args = System.Environment.GetCommandLineArgs();
// If a directory is not specified, exit program.
if(args.Length != 2)
{
// Display the proper way to call the program.
Console.WriteLine("Usage: Watcher.exe (directory)");
return;
}
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args[1];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true;
// Wait for the user to quit the program.
Console.WriteLine("Press \'q\' to quit the sample.");
while(Console.Read()!='q');
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
}
}
You can also follow this link Watching Folder Activity in VB.NET
Snake Tail. It is a good option.
http://snakenest.com/snaketail/
Just a shameless plug to tail onto the answer, but I have a free web based app called Hacksaw used for viewing log4net files. I've put in an auto refresh options so you can give yourself near real time updates without having to refresh the browser all the time.
Yeah I've used both Tail for Win32 and tail on Cygwin. I've found both to be excellent, although I prefer Cygwin slightly as I'm able to tail files over the internet efficiently without crashes (Tail for Win32 has crashed on me in some instances).
So basically, I would use tail on Cygwin and redirect the output to a file on my local machine. I would then have this file open in Vim and reload (:e) it when required.
+1 for BareTail. I actually use BareTailPro, which provides real-time filtering on the tail with basic search strings or search strings using regex.
To make the list complete here's a link to the GNU WIN32 ports of many useful tools (amongst them is tail).
GNUWin32 CoreUtils
Surprised no one has mentioned Trace32 (or Trace64). These are great (free) Microsoft utilities that give a nice GUI and highlight any errors, etc. It also has filtering and sounds like exactly what you need.
Here's a utility I wrote to do just that:
It uses a FileSystemWatcher to look for changes in log files within local folders or network shares (don't have to be mounted, just provide the UNC path) and appends the new content to the console.
on github: https://github.com/danbyrne84/multitail
http://www.danielbyrne.net/projects/multitail
Hope this helps
#echo off
set LoggingFile=C:\foo.txt
set lineNr=0
:while1
for /f "usebackq delims=" %%i in (`more +%lineNr% %LoggingFile%`) DO (
echo %%i
set /a lineNr+=1
REM Have an appropriate stop condition here by checking i
)
goto :while1
A command prompt way of doing it.
FileMon is a free stand alone tool that can detect all kinds of file access. You can filter out any unwanted. It does not show you the data that has actually changed though.
I second "tail -f" in cygwin. I assume that Tail for Win32 will accomplish the same thing.
Tail for Win32
I did a tiny viewer by my own:
https://github.com/enexusde/Delphi/wiki/TinyLog

Resources