Question about obj.ttl in Varnish 4.0
I have a small varnish problem and hope anyone can help me.
I am using varnish 4.0 and I want to increase the obj.ttl based on the obj.hits
sub vcl_hit {
if (obj.hits == 1000) {
set obj.ttl = 7d;
}
}
sub vcl_fetch {
set beresp.ttl = 20m;
}
Unfortunately, I receive an error.
Message from VCC-compiler:
Variable 'obj.ttl' is read only.
At: ('input' Line 46 Pos 21)
In Varnish 4, the entire obj variable is read-only:
obj is now read-only
obj is now read-only. obj.hits, if enabled in VCL, now counts per objecthead, not per object. obj.last_use has been retired.
Use beresp.ttl instead (see the VCL reference). I suggest reading the entire Upgrading To Varnish 4 document.
Related
I have created DesignSurface. However, if I change the properties of the control, for example, the Size property.
I stretched Form, so the Size attribute of PropertyGrid should also be changed in time. But I've been looking at Google and MSDN for a long time and haven't found out how to do it. Can you tell me what I should do? Thank you
Part of the code
You can see that the LOCATION property of this button is not correct. This is because the property has not been updated in time.
My problem is how to update control properties to propertyGrid in time.
Thank you
oh,I have solved my problem by myself. The code reads as follows. Mainly the application of IComponentChangeService. Thanks MSDN. Too long.
IComponentChangeService ccs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
ccs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
/* This method handles the OnComponentChanged event to display a notification. */
private void OnComponentChanged(object sender, ComponentChangedEventArgs ce)
{
if (ce.Component != null && ((IComponent)ce.Component).Site != null && ce.Member != null)
Debug.WriteLine("The " + ce.Member.Name + " member of the " + ((IComponent)ce.Component).Site.Name + " component has been changed.");
}
Since I don't have any of the mentioned phones with Windows 10 Mobile, can someone, who have Lumia 950 or 950 XL , run the following few lines of code in blank UWP application project to get the Scale value out of this device (to figure out effective resolution eventually):
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
// ### snipped start ###
var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues;
string scale;
if (qualifiers.TryGetValue("Scale", out scale))
{
System.Diagnostics.Debug.WriteLine(scale);
}
// ### snipped end ###
}
}
Please post the integer number from the output window as an answer - will be much appreciative!
PS. Suspecting that it should be 400 for 950 and 450 for 950 XL, but would like to be sure.
OK, in case anybody will look for it later - the scale is 400 for Lumia 950, thanks to colleague, who bought it recently.
I have subclassed UIRefreshControl to make my own, and I can manage everything except one thing :
The default spinner is always visible, and is of course in the middle of everything I've done in my custom implementation.
I can't find the spinner property or whatever it is I need to put to a clear color, can anyone help me on this?
To hide spinner loader in a UIRefreshControl, set the .tintColor property to a clear color.
e.g. (Swift):
mRefreshControl.tintColor =.clear
For 2023, .tintColor = .clear works fine.
Historic answer:
Swift 4, Swift 5
Bug fix
From time to time only this code doesn't work properly:
refreshControl.tintColor = .clear – first reload shows the indicator :(
This fixes this bug:
refreshControl.tintColor = .clear
refreshControl.subviews.first?.alpha = 0
Override didMoveToSuperview to hide the spinner's superview.
Swift version:
override func didMoveToSuperview() {
super.didMoveToSuperview()
guard let _ = superview else { return }
self.subviews.first?.alpha = 0 // set hidden = true did not work
}
Objective-C version:
- (void)didMoveToSuperview {
[super didMoveToSuperview];
if (self.superview != nil && self.subviews.count > 0) {
self.subviews[0].alpha = 0;
}
}
You may want to do more checks rather than just using the first subview.
I've been playing around of this issue for awhile now and can't get my head wrapped around of it. I'm using Liferay 6.1 CE GA2.
Goal:
User editable content, for example footer in each page. I've created the web content which id is 12701.
Method:
#set ($local_temp_content = $journalContentUtil.getContent($scope_group_id, "12701", null, "$locale", $theme_display))
$local_temp_content<br />
Issue:
It won't return anything sensible. It's just printing "$local_temp_content" as the result.
Any pointers how to debug this issue?
This is a velocity macro to retrieve a web content by ID from local scope first and then by global scope:
#macro(glarticle $temp_article_id)
#set ($temp_content = "")
#set ($scope_group_id = $theme_display.scopeGroupId)
#set ($global_group_id = $theme_display.companyGroupId)
#set ($temp_content = $journalContentUtil.getContent($scope_group_id, $temp_article_id, null, "$locale", $theme_display))
#set ($temp_content = "$!{temp_content}")
#if ($temp_content.length() == 0)
#set ($temp_content = $journalContentUtil.getContent($global_group_id, $temp_article_id, null, "$locale", $theme_display))
#end
$!{temp_content}
#end
How to use it:
#glarticle('1234')
For debugging velocity try outputting every part of your call.
scope_group_id = $scope_group_id<br>
theme_display = $theme_display<br>
journalContentUtil = $journalContentUtil<br>
If you get exactly what you wrote than that variable is not available.
If all are resolved then possibilitis are:
wrong article id
there was exception during article rendering (you should check log)
I have vb.net winform app that has
AutoScaleMode = dpi
AutoScale = false
AutoSize = true
I've signed off after changing DPI setting.
I also tried restarting the machine.
Using g As Graphics = form.CreateGraphics()
Dim dpiX As Single = g.DpiX
dpiX is always 96 regardless of DPI setting. Anyone know what I am doing wrong?
I found solution. My app's manifest has to say it is dpiAware.
Because I am trying to detect high DPI and show a warning message box and not really trying to make my app dpi aware, I couldn't do that.
You can get dpi aware information from registry:
HKEY_CURRENT_USER\Control Panel\Desktop
LogPixels.
If you are using default, you won't have the key. Changing DPI setting will create one.
I ran into this problem and found that if you override the OnPaint(PaintEventArgs e) method of the form, and then get the Graphics object from the argument 'e' i.e. e.Graphics then the DpiX and DpiY value of this Graphics object is correct.
Unfortunately, the way windows handles DPI scaling is all over the place:
Using g As Graphics = form.CreateGraphics()
Dim dpiX As Single = g.DpiX
This code will only work if user has "Use Windows XP Style DPI Scaling" selected when setting custom DPI. Don't know if that option is even available in the new versions of Windows (8.x and 10) or if they've taken it out.
Your best bet would be to just read the registry:
Dim regUseDpiScaling As Integer
Try 'Use Try / Catch since the reg value may not exist if user using 96 DPI.
regUseDpiScaling = CInt(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "UseDpiScaling", Nothing)) ' if this returns 1, it means users is using modern DPI scaling.
Catch ex As Exception
regUseDpiScaling = 0 ' 0 means no DPI scaling or XP DPI scaling
End Try
If Not (regUseDpiScaling = 0) Then
boolUsesModernDPIScaling = True 'Means you haven't clicked "Use Windows XP Style DPI Scaling" while setting DPI in your system.
Else
boolUsesModernDPIScaling = False
MsgBox("2")
End If
Dim regAppliedDPI As Integer
Try
regAppliedDPI = CInt(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics", "AppliedDPI", Nothing))
Catch ex As Exception
regAppliedDPI = 96
End Try
DPIratioX = regAppliedDPI / 96
DPIratioY = regAppliedDPI / 96
I found that having XP DPI scaling can result in different behavior, so it's good to have the program detect if it's being used.