|
I must say that I find CP's ad display unobtrusive. Ads at the top and bottom of the page don't particularly bother me. Would that all other sites were that considerate!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Gawd I know that feeling!
One of the nice things about uBlock is it shows you how many adds it blocked: when the number reaches double figures it's definitely not going on my whitelist!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
It blocks only ADDs? Shirley it's a beta version, right? Why does it not also block AND, OR, SUB, MUL or DIV?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Sorry? Most of your post was blocked by my system:
CodeWraith wrote: It blocks only? Shirley it's a beta version, right? Why does it not also block?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Very good! Now let's try one more that I forgot: XOR
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
...and stop calling him "Shirley".
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Disable ad-blocker, and update your host-file. I don't accept anything from other domains than the visiting one; it is a security-risc to download and display html+js from an unknown party.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
You can also setup your own DNS server with a raspberry pi and pi-hole. Works for all devices connected to your network.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Bram van Kampen wrote: I learned to my surprise that clicking on a link in that email to get to the appropriate response in the board is conditional to not having an Add blocker.
I am frankly Disgusted! I'm confused. It sounds like you are complaining that a free site has ads on it.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
He's actually complaining that the ads get in the way of viewing the site based on notifications.
An alternative solution is to set your profile to not notify you of things that happen on the site.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
John Simmons / outlaw programmer wrote: ads get in the way of viewing the site based on notifications. I don't understand.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
How do you manage to walk when your knickers are in such a twist? Given the value I get from CP, I am more than happy to help fund it through advertising. It would be churlish of me not to. Or, to put it another way, do you think that CP should go bust because they run out of money?
This space for rent
|
|
|
|
|
Pete O'Hanlon wrote: How do you manage to walk when your knickers are in such a twist Possibly no balls to get in the way.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Bram van Kampen wrote: I am also sending this mail directly to Chris Mauder! Don't forget to tell him that...Bram van Kampen wrote: I ... would prefer to pay premium access
Hmm.
Thinking about it, I'd happily pay a subscription to CP -- and I wouldn't demand that they turn the ads off.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
|
Not clicking it, but I'd use the C preprocessor.
Just because.
|
|
|
|
|
I like to write little libraries for code re-use:
using System;
using System.Globalization;
namespace WHATEVER
{
public static class StringExtensions
{
private static double dbl;
private static int i;
public static StringState GetStringState(this string str)
{
if (String.IsNullOrEmpty(str))
{
return str == "" ? StringState.IsEmpty : StringState.IsNull;
}
else
{
if (String.IsNullOrWhiteSpace(str)) return StringState.IsWhiteSpace;
}
if (Double.TryParse(str, out dbl)) return StringState.IsNumeric;
return StringState.IsStandard;
}
public static NumberState GetStringNumberState(this string str)
{
if (str.GetStringState() != StringState.IsNumeric) return NumberState.NotNumber;
if (Math.Abs(dbl % 1) < Double.Epsilon)
{
return NumberState.IsInt;
}
else
{
return NumberState.IsDouble;
}
}
public static bool StringIsHex(this string str)
{
if (str.StartsWith("0x")) str = str.Remove(0,2);
return Int32.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out i);
}
}
public enum StringState
{
IsStandard = 0x0 << 0,
IsNull = 0x1 << 0,
IsEmpty = 0x1 << 1,
IsWhiteSpace = 0x1 << 2,
IsNumeric = 0x1 << 3,
}
public enum NumberState
{
NotNumber = 0x0 << 0,
IsInt = 0x1 << 0,
IsDouble = 0x1 << 1
}
} Sample tests:
string s1 = null;
string s2 = "";
string s3 = "12";
string s4 = "23.45";
string s5 = "0xFF";
string s6 = "23.45";
var state1 = s1.GetStringState();
var state2 = s2.GetStringState();
var state3 = s3.GetStringState();
var state4 = s4.GetStringState();
var state5 = s5.GetStringState();
var state6 = s6.GetStringState();
var nstate1 = s1.GetStringNumberState();
var nstate2 = s2.GetStringNumberState();
var nstate3 = s3.GetStringNumberState();
var nstate4 = s4.GetStringNumberState();
var ishex1 = s5.StringIsHex();
var ishex2 = "0xddDFf".StringIsHex();
var ishex3 = "0xXdDFf".StringIsHex();
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Using static variables to store state between method calls could be problematic. I'd be inclined to replace them with either out parameters or value tuple[^] returns. Eg:
public static class StringExtensions
{
public static StringState GetStringState(this string str, out double dbl)
{
dbl = double.NaN;
if (str is null) return StringState.IsNull;
if (str.Length == 0) return StringState.IsEmpty;
if (string.IsNullOrWhiteSpace(str)) return StringState.IsWhiteSpace;
if (!double.TryParse(str, out var d)) return StringState.IsStandard;
dbl = d;
return StringState.IsNumeric;
}
public static StringState GetStringState(this string str) => GetStringState(str, out _);
public static NumberState GetStringNumberState(this string str, out double dbl)
{
if (GetStringState(str, out dbl) != StringState.IsNumeric) return NumberState.NotNumber;
if (Math.Abs(dbl % 1) < double.Epsilon) return NumberState.IsInt;
return NumberState.IsDouble;
}
public static NumberState GetStringNumberState(this string str) => GetStringNumberState(str, out _);
public static bool StringIsHex(this string str, out int i)
{
if (str.StartsWith("0x")) str = str.Remove(0, 2);
return int.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out i);
}
public static bool StringIsHex(this string str) => StringIsHex(str, out _);
} Or:
public static class StringExtensions
{
public static (StringState state, double dbl) GetStringState(this string str)
{
if (str is null) return (StringState.IsNull, double.NaN);
if (str.Length == 0) return (StringState.IsEmpty, double.NaN);
if (string.IsNullOrWhiteSpace(str)) return (StringState.IsWhiteSpace, double.NaN);
if (!double.TryParse(str, out var d)) return (StringState.IsStandard, double.NaN);
return (StringState.IsNumeric, d);
}
public static (NumberState state, double dbl) GetStringNumberState(this string str)
{
switch (GetStringState(str))
{
case var n when n.state != StringState.IsNumeric:
{
return (NumberState.NotNumber, double.NaN);
}
case var n when Math.Abs(n.dbl % 1) < double.Epsilon:
{
return (NumberState.IsInt, n.dbl);
}
case var n:
{
return (NumberState.IsDouble, n.dbl);
}
}
}
public static (bool isHex, int value) StringIsHex(this string str)
{
if (str.StartsWith("0x")) str = str.Remove(0, 2);
return (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var i), i);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, Richard; I'll study your comment and code carefully.
cheers, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
cool!
|
|
|
|
|
For mine a string.HasValue() is less explit in intention
- it doesn't really speak to what happens if string itself is NULL (as compared to the empty string "".)
- or does it mean string (itself) has a value, or THE string has a value? and is empty string not a "value": the value is AN empty string.
!string.IsNullOrEmpty() yes more wordy/longer but it does specifically talk to both NULL and the empty string.
btw: I find myself using string.IsNullOrWhiteSpace() more often which one could argue doesn't speak to the empty string: i.e. "" is not NULL but pedantically nor is it white space.
... they should rename that: string.IsNullOrEmptyOrWhiteSpace(),
and why not: string.IsNotNullNorEmptyNorWhitespace() ???
and just for completion: string.IsNullOrEmptyOrWhiteSpaceOrSpecials() / string.IsNotNullNorEmptyNorWhitespaceNorSpecials()
modified 18-Feb-19 23:32pm.
|
|
|
|
|
In my case, I think the function is explainable to the team. The goal was to inverse the !string.IsNullOrEmpty to read positive. It is an attempt to follow how nullable booleans, integers, etc.. contain a HasValue function.
Again, the IsNot still sounds "negative" to me which was the goal of the extension method.
|
|
|
|
|
I'd agree with Lopati - IsNullOrEmpty is a specific question (as is IsNullOrWhitespace) which specifies exactly what conditions it checks for: HasValue doesn't, it implies a degree of "valueness" which is not implicit to a string, but is added by context. HasValue could mean "has a valid numeric", "has a name and address" which "IsNullOrEmpty" doesn't - it's a basic generic check which prepares the way for more explicit "value" checking.
I'll stick with IsNullOrWhitespace myself!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: I'll stick with IsNullOrWhitespace myself! Only because you can, it doesn't mean you should
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
You can use extension methods for all sorts of test (e.g. comparisons) to handle null arguments, so you don't have to explicitly test for null (or cause an exception when a null occurs).
This is obviously a good idea only if a null value is meaningful in the context. E.g. rather than
if (middleName != null && middleName.Equals("Peter")) ...
I write
if (middleName.Eq("Peter")) ...
with the Eq extension method checking the this argument for null before using it in an Equals test.
|
|
|
|