client's cairo surfaces screenshots - lua

I just discovered screenshots possibilities using client.content property.
So to test this functionnality, I put this code and bind it to the XF86Reload key :
awful.key({ }, "XF86Reload", function()
local i = 0
for c in awful.client.iterate(function() return true end)
do
local f = c.name
gears.surface(c.content):write_to_png( "/home/david/" .. string.format('%02i',i) .."-" .. f .. ".png")
i=i+1
end
end)
Unfortunately, some images are puzzled. Is the Cairo surface needs to be on the screen (ie non minimized) to be properly shot? (it seems it's also happening sometimes to visible windows) or maybe some other reason I can't see...

Is the Cairo surface needs to be on the screen (ie non minimized) to be properly shot?
Yes (and also: may not be obscured by other windows or outside of the visible space; you can only get what is actually shown on the display).

Also note that running Compton or another compositing manager makes it a lot more reliable

Related

Cytoscape - Set nodeCustomGraphicsSizeSync and nodeSizeLocked from CyREST

Is there a way to programatically set nodeCustomGraphicsSizeSync and nodeSizeLocked in Cytoscape with the CyRest api ?
They are usually set in the UI by the two checkboxes "Fit Custom Graphics to node" and "Lock node width and height" (see image).
I tried this, which does not work:
from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient()
my_style = cy.style.create('custom_theme', original_style=cy.style.get('default'))
net = cy.network.create(name='My Network', collection='My network collection')
my_style.update_defaults({
'NODE_SIZE':200, #works
'NODE_CUSTOMGRAPHICS_SIZE_1':80, #works,
'NODE_CUSTOMGRAPHICS_POSITION_1':'N,S,c,0.00,0.00', #works
'nodeCustomGraphicsSizeSync' : 'false', # does not work
'nodeSizeLocked' : 'false' # does not work
})
cy.style.apply(my_style, net)
I think it is because these are not VisualProperties but Visual Property Dependencies
I found this mention of a related issue, but no other references (the redmine seems down):
3245 Creating a copy of a VisualStyle--VisualPropertyDependencies not copied
from https://cytoscape.org/cy3_welcome_letter_v14.pdf
I'm using Cytoscape 3.7.2 and py2cytoscape.
There is a way in CyREST, but I'm not sure it's been made available through py2cytoscape. Basically, you need to update the dependencies, which is a different REST endpoint (/{name}/dependencies) and you want to use "enabled" rather than "true". You may want to see if there is an update_dependencies in py2cytoscape (I don't see one after a quick look at the docs). If not, add an issue in github: https://github.com/cytoscape/py2cytoscape
-- scooter

Don't starve Lua: Can't figure out how to spawn additional bamboo with each bamboo tree, or other machete resources

I'm building, or trying to build, a mod called More Drops (DS). I ported it to Don't Starve from "Don't Starve Together", so my lua knowledge is very limited, but I've been working on this thing for days and can't figure it out, so I need to ask for help.
I figured out how to expand on the original mod authors work by adding new trees and resources, but when it comes to "hackable" resources, I'm stumped.
So this is what I was trying, and tons of variations on this. This doesn't work and I don't understand why, and I'll show you what does work in the next two.
--bamboo
if inst.name == "Bamboo Patch" and utils.LootRandom(bambooChance) then
utils.DoTimes(GetModConfigData("bambooAmount", KnownModIndex:GetModActualName("(JEM) More Drops DS")), inst.components.lootdropper.SpawnLootPrefab, inst.components.lootdropper, "bamboo")
end
This does work
--Spawn extra logs for tall trees
if inst.components.growable.stage == 3 and utils.LootRandom(logChance) then
utils.DoTimes(GetModConfigData("extralogstall", KnownModIndex:GetModActualName("(JEM) More Drops DS")), inst.components.lootdropper.SpawnLootPrefab, inst.components.lootdropper, "log")
end
And this works as well
if inst.name == "Evergreen" and inst.components.growable.stage ~= 1 then
if utils.DropLootRandom(inst, "pinecone", seed_chance) then print("Dropped seed") end
end
Now I'm not sure how much of the files I should paste here, but here's the start of the trees.lua just to add a bit more context
local utils = require("utils")
local logChance = GetModConfigData("logChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local function ImproveTree(inst)
--Do these when the tree is fully chopped
local seed_chance = GetModConfigData("treeseedchance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local egg_chance = GetModConfigData("eggChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local coconut_seed_chance = GetModConfigData("coconutChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local bambooChance = GetModConfigData("bambooChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local oldonfinish = inst.components.workable.onfinish
inst.components.workable:SetOnFinishCallback(function(inst, chopper)
All of the info is called in modmain.lua correctly as far as I can tell, I made sure to add things in the same way as the working code.
I expected this to drop some extra bamboo! I've tried so many different ways, even made my own choppable.lua file and added it the same way the original author added pickable.lua, but I figured it's gotta be a bit more like trees than regular resources, since you use a tool and it drops the item on the ground rather than adding to invetory.
If you want to see the whole mod, I've uploaded it here: https://www.dropbox.com/s/ahss2d0s861j2an/%28JEM%29%20More%20Drops%20DS.7z?dl=0

Roblox Studio - Warning/Error when i try to sell the "snow" in my backpack

As you can see on the picture below I can't sell what I have in my backpack when I enter the circle. I get this error/warning and I can't figure out what the problem is. I have found out that the problem happens on line 5: player:WaitForChild
The Error/Warning on line 5: Infinite yield possible on Players.asbjornbonde.PlayerGui:WaitForChild("Stats")
Here is the picture:
Here is my code:
script.Parent.Touched:connect(function(Hit)
local player = game.Players:FindFirstChild(Hit.Parent.Name)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
local PlayerGui = player:WaitForChild("PlayerGui"):WaitForChild("Stats").Backpack
if leaderstats and PlayerGui then
local Cash = leaderstats:FindFirstChild("Cash")
local snow = PlayerGui:FindFirstChild("snow")
if Cash and snow then
if snow.Value <= 0 then
else
Cash.Value = Cash.Value + 2 * snow.Value
snow.Value = 0
script.Parent.DigSound:Play()
script.Disabled = true
wait(0.1)
script.Disabled = false
end
end
end
end
end)
I have used many hours on trying to fix this problem but i really can't. I would appreciate help.
Infinite yield possible on is a warning in Roblox Studio that means there is a possibility that your script could be stuck on that line waiting forever if object it is waiting on doesn't exist and is never created.
As the only WaitForChild that is causing an error is two WaitForChild's joined together I'm guessing the script doesn't like you doing that.
First Solution
If you were to split both WaitForChild's into two different variables it shouldn't give you the error however this is creating another variable for no real reason so I would go for the second solution.
Second Solution
As the player has loaded in and touched the part it's safe to assume the GUI has loaded for them so you can change your WaitForChild to FindFirstChild if you still want to check you didn't get a nil or you can reference it normally: player.PlayerGui.Stats.Backpack
Hope this helps.
Think of WaitForChild() as a loop. It is constantly executing in the background, as fast as the Lua engine can execute it. Wouldn't recommend using this or any sort of un controlled loop in Roblox Lua as the engine doesn't handle it very well.
If this is a server script with a filtering enabled game, the issue is that the server cannot access existing members of PlayerGui. To work around this, you either need to run this code on the client (with the necessary changes), or you'll need to make use of a remote event!

VB6, ActiveReports, and Ricoh printers: Rotating the Page?

I have a BEAST of a program written in VB6. It uses ActiveReports to generate letters.
The reports are processed in a loop; with verbage-building loops and (a whole lotta) nested 'if' and 'case' statements. Fugly!
The reports are sent to the printer like such:
Function PrintIt(ltrobj as Object)
Set ltrobj = MyARdocument '(.Dsr file)
ltrobj.txtfield1 = strVerbage 'This string was populated somewhere else
ltrobj.Printer.DisplayProgressDialog = False
ltrobj.PrintReport False
End Function
Now here's the weird part: The pages physically come out of the printer rotated 90 degrees each iteration of the loop. What's even weirder -- this only happens for my VB6 application -- other Word documents, reports, batch jobs, whatever come out normal.
So the first page comes out like normal, the header first (pointing North). The second page comes out sideways (header pointing West). The third comes out of the printer like the first, the fourth comes out like the second, and on and on...
The printer: A Ricoh Aficio MP5000
I cannot find a setting on the printer, or a property in ActiveReports that controls this.
Any ideas, help, or a general direction would be greatly appreciated!
Thanks,
Jason
There is no "rotation" setting in ActiveReports. The closest things that might impact this would be the page size and orientation, but at worst I would expect them to flip back and forth not actually rotate the page. I would try to do a few things:
Trace the printer & page settings related to orientation and page size as report prints.
Try printing to another printer to see if it happens on all printers or just this one.
Preview the reports on screen and see if they're rotated in the preview or not (or export them to PDF with report.Export(...) ad see if they're rotated there).
To trace page settings you should do it in a couple places. One on the printer, and another on each page (or Canvas) in the report. There is also the ActiveReport.PrintWidth (the width of the report, not the pages) that may also be relevant. So just before printing each report try tracing out the following values:
report.PrintWidth
' the default settings for the report
report.PageSettings.TopMargin
report.PageSettings.RightMargin
report.PageSettings.BottomMargin
report.PageSettings.LeftMargin
' actual printer's current settings:
report.Printer.PaperSize
report.Printer.PaperHeight
report.Printer.PaperWidth
report.Printer.Orientation
' settings for a specific page:
for each page in report.Pages:
report.Pages(...).Width
report.Pages(...).Height
report.Pages(...).Orientation
BTW: ActiveReports COM Help is here.
If the preview/PDF test seems okay then I'd focus on the printer itself. Same for the print to another printer obviously. Otherwise, focus on ActiveReports settings.
Hope this helps
Scott Willeke
GrapeCity

why is the behavior of extent (imagemagick) not uniform across my machines?

I'm using extent in rmagick/imagemagick to center images on a canvas of certain size.
On some of my machines, it centers them - on others it does the opposite. If I fix code to work on one machine, it does the exact opposite on the other.
Does anyone know why this is happening?
I actually already knew the answer -- after 5 hours of struggling with code. Just posting this for reference.
For some unknown (and I think stupid) reason , this appeared in the ImageMagick changelog:
2010-09-13 6.6.4-2 Cristy <quetzlzacatenango#image...>
# Don't negate the geometry offset for the -extent option.
For whatever reason, the ImageMagick team decided it was okay to change a function to do LITERALLY THE EXACT OPPOSITE OF WHAT IT HAS HISTORICALLY DONE in a release .
The function should have remained as-is, a corollary function with the new behavior could have been introduced, and the original function been deprecated - with warnings - over several releases.
A strategy such as this - which is pretty much the standard way of handling changes like this - would have allowed those with active code built against ImageMagick to continue as normal. Instead, people now have to write code supporting both versions of this function, or forcing upgrades.
the following ruby code is an example of how to handle this, as you have NO IDEA WHATSOEVER what version someone will be running on their machine.
offset_coords= { 'x' => 100 , 'y' => 100 }
expects_negated = true
# ImageMagick 6.6.4-2 changed the behavior of extent
# me: !(*#&#(#! .
#mversion = "ImageMagick 6.6.4-1 2010-12-07 Q16 http://www.imagemagick.org"
mversion = Magick::Magick_version
( v_version , v_commit ) = mversion.split(' ')[1].split('-')
( v_version_1 , v_version_2 , v_version_3 ) = v_version.split('.')
if Integer(v_version_1) >= 6 and Integer(v_version_2) >= 6 and Integer(v_version_3) >= 4 and Integer(v_commit) >= 2
expects_negated= false
end
if expects_negated
offset_coords['x'] = - offset_coords['x']
offset_coords['y'] = - offset_coords['y']
end
#new_image.background_color= "#000000"
#new_image = #new_image.extent( target_dimensions['w'] , target_dimensions['h'] , offset_coords['x'] , offset_coords['y'] )

Resources