News for hackers. Stuff that matters.

localhostdotdev

started using stimulus and loving it so far, got sick of react and jquery (trying to use plain js + underscore + my own "utils")
Re:JQuery 3.4.0 Released on Thursday April 11, 2019 @01:39PM (#19637101)
it doesn't export to the global namespace though:

    <script src="https://www.googletagmanager.com/gtag/js"></script>
    <script>$</script>
    ReferenceError: $ is not defined

    <script>jQuery</script>
    ReferenceError: jQuery is not defined
Re:Ask HN: Best place to start learning about Markov Chains? on Thursday April 11, 2019 @08:25AM (#19633660)
markov chains are very simple at their core (e.g. simple version could be: take the probability of the next word given the known probabilities of words that follow the previous word)

it can be implemented in a few lines of code, that's the beauty of it: https://github.com/justindomingue/markov_chains/blob/master/...

obviously then you could take the previous n words into account, tweak the starting word, add randomness, etc.

now replace "word" with "state" and "probability(next state | previous state)" to edges of a graph: https://static1.squarespace.com/static/54e50c15e4b058fc6806d...

and you got a generic markov chain :)

footnotes: p(A | B) is probability of A given B, e.g. p(rain | clouds) > p(rain | sun) :)

Re:Julian Assange arrested in London on Thursday April 11, 2019 @07:50AM (#19633321)
it's going to be interesting to see what is in all those insurance files https://legalinsurrection.com/2013/08/whats-behind-wikileaks...
Re:JQuery 3.4.0 Released on Wednesday April 10, 2019 @11:42PM (#19630980)
just a simple reminder:

    Top 1m 77.15%
    Top 100k 87.37%
    Top 10k 88.83%
https://trends.builtwith.com/javascript/jQuery
Re:The Urgent Quest for Slower, Better News on Wednesday April 10, 2019 @08:42PM (#19630081)
my take on this is that's it's better focus on major actions taken during a mandate (and that's what people who don't care too much about politics do) to then inform the next vote.

that's why politics before the rise of the internet were much more formal, people remembered what was done and said.

now there is just so much noise it's very hard to distinguish the signal, which leads to people being influenced and directed into "identity politics" (are you yellow or green, blue or red, left or right, good or bad?)

yes and google does it too, which is very creepy and not useful to the user at all.

unlike the location history where I understand the use case and maybe search history. but all those should be disabled by default.

that was for shadowsocks I think (e.g. a powerful tool to escape the chinese firewall).

they even tried to DDoS github as far as I remember.

additionally for passwords that are already stored, it's not too costly to check the hashes against the blacklist and revoke those existing passwords.
Re:Unveiling the first-ever image of a black hole [video] on Wednesday April 10, 2019 @02:11PM (#19627301)
Thanks a lot for the explanation and the better sources, the TIFF image should probably be a torrent because it's not downloading very fast, the PNG image does give much nicer renders: https://i.imgur.com/zZcD5Na.jpg
Re:The Problem with ‘5 Whys’ (2016) on Wednesday April 10, 2019 @12:32PM (#19626319)
after experimenting for a while, I now prefer "for what purpose?" instead of "why?".

"why?" easily leads to cycles and going back down the abstraction hierarchy, where "for what purpose?" always goes up the abstraction ladder.

- why are you eating? because it's 7pm

- for what purpose are you eating? to satisfy my hunger

Re:Unveiling the first-ever image of a black hole [video] on Wednesday April 10, 2019 @12:22PM (#19626200)
editing that image reveals all kinds of details: https://imgur.com/a/TvQsgbA (and I don't even know what I'm doing)
Re:DNS-over-HTTPS Policy Requirements for Resolvers on Wednesday April 10, 2019 @09:24AM (#19624376)
pretty cool, I wished chrome did that. firefox is probably going to choose cloudflare (1.1.1.1).

I wonder how this plays out with local DNS (e.g. my ISP has some custom domains for me to use, and internal company network addresses)

Re:Itinerant – a fuzzy weather forecast app on Wednesday April 10, 2019 @08:14AM (#19623839)
quite amazing, would love this as a background on both phone and desktop
Re:Privacy Pass on Wednesday April 10, 2019 @07:26AM (#19623590)
getting closer everyday to a global "login" to access the internet
reddit's code formatting is its own story, it supports both 4 spaces and triple backticks (but only on redesign web).

> On redesign, a slightly-edited version of CommonMark. On old reddit, it's still snudown.

(and mobile apps have their own markdown)

> New Reddit note: Indented code blocks are the only form of code block that works on Old Reddit. Use them for compatibility

https://www.reddit.com/wiki/markdown#wiki_code_blocks_and_in...

maybe in a few years there is going to be syntax highlighting, one can hope :) (slack doesn't have it either, but even discord has it...)

Re:A fork() in the road on Wednesday April 10, 2019 @04:21AM (#19622801)
"every other system has a feature except us, and we are not going to add it (because reasons) even if it's very widely used"

also:

> When a fork syscall is made on WSL, lxss.sys does some of the initial work to prepare for copying the process. It then calls internal NT APIs to create the process with the correct semantics and create a thread in the process with an identical register context. Finally, it does some additional work to complete copying the process and resumes the new process so it can begin executing.

https://blogs.msdn.microsoft.com/wsl/2016/06/08/wsl-system-c...

Re:Announcing Building Git on Tuesday April 09, 2019 @10:33PM (#19621281)

   def f(&block)
     block.class
   end

   f { } # => Proc
   f(&-> { }) # => Proc
   f(&lambda { }) # => Proc
   f(&:something) # => Proc

   lambda { }.class # => Proc (I think you get the idea)

   method(:f).class # => Method

   lambda { |i| i + 1 }.call(10) # => 11
you don't typically return in a block, there is implicit return. you would do "next" or "break" depending on what you want to achieve. as far as I know that's the main difference between procs and methods.

(not that anybody would do what I do, most people just use blocks, some people use yield, few people use the &block argument, but that's exactly the same)

Re:Announcing Building Git on Tuesday April 09, 2019 @07:59PM (#19620283)
blocks are the same as passing a function or a lambda in python:

    [1, 2, 3].map { |i| i + 1 }

    [i + 1 for i in [1, 2, 3]]

    def plus(i):
      return i + 1

    map(plus, [1, 2, 3])

    map(lambda i: i + 1, [1, 2, 3])
Re:Announcing Building Git on Tuesday April 09, 2019 @07:07PM (#19619904)
github uses libgit2 https://github.com/libgit2/libgit2 (in C) but I'm pretty sure they have a lot of wrappers around it (maybe a ruby gem with native extensions, maybe using ffi)

edit: ruby gem: https://github.com/libgit2/rugged which has a native extension written in C to bind libgit2 functions to ruby methods.

Re:Announcing Building Git on Tuesday April 09, 2019 @07:03PM (#19619867)
if you go through the files in the repo they are very easy to read (I would recommend starting with the test/ folder): https://github.com/jcoglan/jit

obviously the lib folder requires a lot of git-specific knowledge but I didn't see any use of features that don't have exact or very similar equivalent in more popular programming languages.

I think the most "complex" might be things like Struct.new(*Inputs::ATTRS) where it's creating a new anonymous class from a list of attributes which becomes the class instance attributes (nothing crazy :) )

Re:Announcing Building Git on Tuesday April 09, 2019 @06:41PM (#19619687)
the linked repository is amazing, I don't think I ever saw such nice code and such neat organization: https://github.com/jcoglan/jit (everything uses standard ruby libraries or default gems like minitest)

I'm trying it out and doesn't work very well on macOS (git add has issue with the lockfile, but all tests pass).

I might use it as it's a very easily customizable implementation of git.