sebleblanc
Re:Technical report on DNC hack [pdf]
on Thursday December 29, 2016 @05:51PM (#13280905)
"If Microsoft forced either SmartScreen OR AppLocker"
Meh, just add a button or clickable link that allows the sysadmin to swiftly disable such warnings. Just make sure to put a scary-enough disclaimer that doing so can expose you to very bad, malicious stuff, from ill-intentioned people. It might get more application publishers to implement signing, just as Vista and 7 got rid of the "run everything as administrator" mentality through the use of UAC warnings.
Re:Newly discovered earliest draft of a Unix manual (1971)
on Sunday December 27, 2015 @09:13PM (#10799505)
Tuple support, which in essence are anonymous structs, would have been very nice in C, too.
Re:Ask HN: Examples of good code?
on Sunday November 15, 2015 @02:24PM (#10570712)
SQLAlchemy[1] is a large project with a very solid codebase; it is very well documented and the API is exemplary.
Re:How necessary are var, let, and const?
on Monday June 01, 2015 @02:52PM (#9641196)
That behaviour is not exclusive to standards committees. The government and private companies do it all the time.
Re:Windows Hello – Biometric authentication to Windows 10 devices
on Tuesday March 17, 2015 @02:41PM (#9220257)
Great! Now the FBI does not even have to arrest me to get my fingerprints and retina scanned!
Re:Algorithms Every Programmer Should Know: Reservoir Sampling
on Friday March 06, 2015 @09:45PM (#9160751)
Regarding the C++ code:
/* This is standard modern C++ random number generation.
It means, using the random generator "engine", return
a number according to distribution "dist". In this
"dist" is a uniform distribution from "i" to "max-min".
"auto" is the new way to type variables in C++: it
infers the type of the variable from the type of the
expression */
22: auto index = dist(engine);
/* The following lines are a bit more complex, as they
contain a nested expression. Let us focus on the inner
expression:
(index < size ) ? array[index]
: map.insert({index, min + index}).first->second
This is in the form:
test-expr ? when-true-expr
: when-false-expr
This expression is a ternary condition. What it means
is that the expression before the question mark is
computed (index < size), and if it evaluates to true,
the overall expression will resolve to the result of
the expression between the question mark and the colon,
otherwise it resolves to what is after the colon.
Here, it means that if "index" is smaller than "size",
use "array[index]", otherwise insert a new entry in the
map, with key "index" and value "min+index", then reuse
the result of the operation by accessing member "second"
of the member "first". I am not familiar with STL maps;
here is an explanation of the map::insert method from
cplusplus.com:
The single element versions (1) return a pair, with
its member pair::first set to an iterator pointing
to either the newly inserted element or to the
element with an equivalent key in the map. The
pair::second element in the pair is set to true if
a new element was inserted or false if an equivalent
key already existed.
*/
23: std::swap(array[i], index < size
24: ? array[index]
25: : map.insert({index, min + index}).first->second);
/* Then, the std::swap operation simply swaps the two indicated
values in the array. */
Re:Why is perl losing its touch?
on Sunday February 22, 2015 @06:02PM (#9091628)
And if you want to emulate static variables in a function, you can do that:
def counter():
counter.x += 1
return counter.x
counter.x = 0
counter()
> 1
counter()
> 2
Beware! singleton variables, mutable state, etc.
Re:Tough Times on the Road to StarCraft
on Sunday January 25, 2015 @04:40PM (#8944370)
But it is an implementation, albeit a non-standard one.