Kivy Sound Module - kivy

What kind of changes should be made in the buildozer.spec file to play an mp3 file using kivy.core.audio SoundLoader in an apk app? Or is it possible anyway to use an mp3 file? For instance you need to add "pillow" module to display images, and you need to add your file extension type to source.include_exts line. What would be the equivalent of this for audio files

You don't need to add a requirement. However you do need to make the following changes in the buildozer file:
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,mp3

Related

read local file content in bazel build system

Hi I would like to read a content of local file in .bzl file.
print(onefile.basename)
#content = ctx.read
#content=ctx.file.onefile
#print(onefile.content)
.bzl code cannot read files, and can't make decisions based on contents of files.
You must create actions (e.g. ctx.actions.run), make the file an action input, and have the action read the file.
.bzl code can load other .bzl files though, you might find that useful.

How to change extension of file on run time in ruby on rails

I am working on a project and I want to show two links to download same file but with different extensions, first link download the file with actual extension and another link download the file with changed extension. Like I have a 1.txt file first link is to download 1.txt file and I want another link to download 1.docx file using ruby on rails.
First link works properly which downloads actual file and I have created a method for second link.
def downloaddocxfile
require 'fileutils'
Dir.glob(params[:file]).each do |f|
if File.extname(f) != '.docx'
FileUtils.cp f, "#{File.dirname(f)}/#{File.basename(f,'.*')}.docx"
send_file "#{File.dirname(f)}/#{File.basename(f,'.*')}.docx"
# system("rm -rf #{File.dirname(f)}/#{File.basename(f,'.*')}.docx")
else
send_file "#{params[:file]}"
end
end
end
This method create a copy of original file and change the extension to .docx.
I don't want to show two files with different extensions in the list of files. So I want to remove that file which is created with .docx extension once it is downloaded. So, How can I do that?
send_file allows you to specify a filename via the :filename option.
Assuming that there's a file x.foo on your server, then:
send_file('x.foo', filename: 'y.bar')
would send the file x.foo under the name y.bar to the browser.
It's up to the browser to use the suggested name, but most browsers will save the file as y.bar.

Add translation using PoEditor

I have files named en_US.po, ru_RU.po etc.
Editing *.po files in PoEdit is very useful, but not while adding new strings manually.
How can I easily add new translation strings which are not automatically detected by PoEdit?
You can edit *.po files in any text editor and then in POEdit generate *.mo file
You misunderstand how gettext translations work. Source strings for translation are extracted from source code. It doesn't make sense to add them manually — they would never be used if they didn't have corresponding source code that uses them.
So the way to add strings is to use xgettext or Poedit's update from sources functionality.
P.S. The name's Poedit, not PoEditor.
You can configure your project (*.po file) opened in PoEdit. If you will done that correct PoEdit automatically update what to translate in this opened *.po file.
First of all, open *.po file which you want update with strings to
translate.
Go to Catalog -> Properties then to Source Paths tab
Add paths where PoEdit should look for source files in Your applilcation. More universal is to use relative to opened *.po file main path. If you have typical zf2 skeleton application folder structure you can add ../../.. for main path and add one module path.
Then go to Source of keywords tab and add translate and if you're using zf2 forms it is useful to add addLabel keyword (PoEdit will scan sources for this functions and add string parameters from them to your *.po file, as string to translate)
Next open Edit -> Preferences and in Processing programs tab, edit PHP section and add *.phtml extension (this will be scanned by poedit also)
After that you have to click in Update button and PoEdit will start scan your sources for strings to translate. Then you only have to do is translate found strings.

Which zipping library should I use to properly assemble a valid XLSX file in Objective-C?

I am trying to modify an XLSX file programmatically using Objective-C.
So far, I am only modifying the data on one of the sheets. The steps I am taking are as follows:
Copy the XLSX file to Documents folder
Unzip the XLSX container with keeping the directory structure
Parse the corresponding sheet XML file (sheet2.xml in my case)
Add some rows
Rewrite the XML structure and save it
Put the updated XML file back into the XLSX container
However, the new XLSX file becomes corrupt. I am using GDataXML for XML parsing/writing and Objective-Zip for zipping/unzipping.
I know that the XML file I have created is proper, because when I manually unzip and the re-zip the corrupt XLSX file, it opens without any errors. I have done this on both OS X (using Unarchiver) and Windows (using 7-Zip).
The problem is either with the Objective-Zip library, or the way I use it. Below is how I implement the zipping method:
ZipFile *zipFile = [[ZipFile alloc] initWithFileName:XLSXDocumentsFilePath mode:ZipFileModeAppend];
ZipWriteStream *stream= [zipFile writeFileInZipWithName:XLSX_WORKSHEET_XML_SUBPATH compressionLevel:ZipCompressionLevelNone];
[stream writeData:data];
[stream finishedWriting];
[zipFile close];
I also tried the other compressionLevel arguments available with no luck:
ZipCompressionLevelDefault
ZipCompressionLevelBest
ZipCompressionLevelFastest
My questions are:
Which zipping library should I use to create a valid XLSX file programmatically?
If Objective-Zip is suitable, what is wrong with my code?
From an answer to another question, I found out that: "The OOXML format imposes that the only compression method permitted in the package is DEFLATE".
Is it possible to force Objective-Zip to use DEFLATE? Or is there an open-source iOS zipping library that uses DEFLATE?
I found the answer upon doing some research and also having a one to one correspondence with Objective-Zip's developer, flyingdolphinstudio.
First of all, Objective-Zip uses DEFLATE as the default compression method. I also confirmed this with the developer, who told me that using ZipCompressionLevelDefault, ZipCompressionLevelFastest or ZipCompressionLevelBest for the argument compressionLevel: will guarantee a DEFLATE compression.
So, the problem is coming from the mode: argument, which is ZipFileModeAppend in my case. It seems that MiniZip does not have a method to delete the files inside a zip file and that's why I am not overwriting the existing file, but adding a new one. To make it more clear, take a look at how my xl/worksheets folder look like after zipping it using Objective-Zip:
So, the only way to create a valid XLSX container is to create the zip file from scratch, by adding all the files and also keeping the directory/file structure intact.
I hope this experience would help somebody out.

How can I include some js file in JSFL file?

I'm using JSFL to writing some script, I need parse json string from some config files, so I need the JSFL can parse json string, but JSFL seems can't do this. then I thinks to include some json lib, like json.js, to JSFL file.
Way can I include the json.js file to my JSFL file?
Sorry for my english.
The absolute bare minimum would be:
// #include Config._jsfl
var scriptPath = FLfile.uriToPlatformPath(fl.scriptURI);
var scriptPathEnd = scriptPath.lastIndexOf("\\");
scriptPath = scriptPath.slice(0, scriptPathEnd + 1);
fl.runScript(FLfile.platformPathToURI(scriptPath + "Config._jsfl")); /*jsl:import Config._jsfl*/
This is more or less copied from my code, JSL tags included. I make the extensions on any libraries to be ._jsfl so that if it's in Flash's Commands folder, they don't show up in the menu.
I wrote a set of static classes (a Logging system, URI conversions, array utility functions) and wrote a global include function using them to automatically convert a relative path to an absolute URI based upon the running scripts location so that I could just say include("file._jsfl"); to simplify my scripts. HOWEVER all my scripts have to do that first include as shown above to gain the include function. Since my include function relies on a handful of static classes, I've not pasted it here.
Edit: spelling error.
If the library is local, you can store it in a subfolder of your Flash config path, i.e.
C:\Users\username\AppData\Local\Adobe\Flash CS6\language\Configuration\jslibs
Then, it is quite easy to include it in a single line:
fl.runScript(fl.configURI + "jslibs/file.js");

Resources