News for hackers. Stuff that matters.

sold

Re:Show HN: Django Secret Key Generator on Tuesday August 09, 2016 @03:51PM (#12257282)
Since Django 1.10 you can simply use get_random_secret_key in django.core.management.utils.

This will not work:

if python3: print (SECRET_KEY) else: print SECRET_KEY

because it's a syntax error in Python 3. Instead, you can just write "print (SECRET_KEY)", this works in both versions and has the same effect.

Re:Django 1.10 released on Monday August 01, 2016 @04:00PM (#12205432)
No, that's 1.11 (a LTS release)
"Monad" in English and "Monade" in German are the same, they can both mean the functional programming concept or the philosophical concept. You can just ignore the philosophical concept, it's not relevant to mathematics.
It's Python - you can do a lot of meta-programming with it, though unlike Lisp and Mathematica there's a division between expressions and statements.
Re:Graph Isomorphism Algorithm Breaks 30-Year Impasse on Tuesday December 15, 2015 @06:35PM (#10741298)
Earlier version was wrong https://cstheory.stackexchange.com/questions/1064/polynomial..., I doubt the current version has any substance.
Re:Graph Isomorphism Algorithm Breaks 30-Year Impasse on Tuesday December 15, 2015 @04:09PM (#10740484)
The algorithm is only of theoretical interest, the situation is similar to primality testing. In practice programs such as nauty are good enough.
Re:Ask HN: Do you find reading increasingly challenging? on Sunday December 06, 2015 @02:33PM (#10686258)
I set up an alarm clock for "detox" every day. I turn off my computer, silence the mobile phone and do nothing but read for hour or two. Resist any temptation to check email.

I've enjoyed this article that was recently on HN http://www.nytimes.com/2015/11/29/opinion/sunday/addicted-to...

I'd like to add this scenario actually happened during the Cold War. Soviets were reusing one time pads and the US army decrypted some of the messages, among other things this lead to discovery of Soviet spies targeting the US nuclear weapon program https://en.wikipedia.org/wiki/Venona_project
Alias often used commands, I have g = git, sl = ls (common typo).

Git: set up aliases. I can type "g co = git checkout", "g st = git status". Git configuration: pull.ff only (then "git pull" does not cause an accidental merge), fetch.prune (then "git pull" = "git pull -p").

Chrome: Ctrl+L for URL bar, Ctrl+T new tab, Ctrl+Shift+T to reopen closed window, Ctrl+W to close tab

Bash: use Alt+. for last argument (e.g. type "vim x.py"; then "python " and press Alt+. to get "x.py"), Ctrl+R to search last commands. "cd -" = undo last "cd"

Gmail: use keyboard shortcuts (enable in settings). ? to see help, most important: "c" compose, "r" reply, "a" reply all, "f" forward

Use a password manager such as keepass, remember only a few passwords.

Re:Ask HN: How often does Git merge make mistakes? on Saturday July 11, 2015 @05:29PM (#9871648)
Yes, ff-only will fail. If C,D are independent and simple, I would go ahead and rebase, otherwise do a proper merge.

Remember you can play a lot with git; if you are not sure how it will turn out, checkout a commit (e.g. git checkout origin/master), create a new throwaway branch (git checkout -b tmp), then you can do rebases, cherry-picks, merges etc., then do "git log tmp" or "git log -p tmp" to see how does the branch look. If you are unhappy, you can always throw it out (git branch -D tmp), it won't affect anything else.

I generally avoid the situation when a branch and origin diverges. The flow I have in my work is: If I need to make a small change (few lines), I pull, do changes, commit and push directly to master; if there are any intervening independent changes, pull --rebase. For anything larger, I create a new branch, and commit there. Once it is ready, I give it to a teammate for code review and do automated build, if everything is OK he merges it to master. Other people generally don't push to my branch, and there is no A-B-C vs A-B-D situation.

If several people work together on the same branch, we coordinate actions face-to-face or via team chat, to avoid conflicts. We pull/push many times a day and the changes are small enough so there are no problems with rebasing in a topic branch. If two people make big conflicting changes to the same branch, it means trouble and we merge or even discard some changes.

Re:Ask HN: How often does Git merge make mistakes? on Saturday July 11, 2015 @03:41PM (#9871277)
I recommend

git config --global pull.ff only

instead, then you can use "git pull" without worries. Or,

git pull --ff-only

> in fact, I think it's better than what languages with far richer type systems offer

Can you explain why? I don't know Kotlin, but from this page it seems to divide types into nullable and non-nullable (correct me if I'm wrong). Is it possible to have a type "T??" that has three possibilities - "null", "wrapped null" and "T"? If not, this approach will not help in the assoc problem mentioned by the parent poster.

> this can lead to unexpected conflicts and can be relatively counter-intuitive to undo.

git merge --abort. Perhaps not intuitive, but it's a single command.

Re:Amazon.co.uk is down/suffering performance issues on Sunday February 15, 2015 @02:01PM (#9053601)
Re:C99 tricks on Friday February 13, 2015 @09:12AM (#9044361)
I see, thanks.
Re:C99 tricks on Friday February 13, 2015 @08:51AM (#9044253)
What is the difference between x ?: y and x || y?
Re:A regular expression to check for prime numbers on Friday February 13, 2015 @08:08AM (#9044090)
Unary representation is useless when speaking about complexity in number theory.

If you take a number N given in unary, convert it to binary and do trial division up to the square root, it will take O(N log N) time for conversion to binary and O(sqrt(N) * log(N)^2) for trial division (depending on your computational model, it could be O(N) and O(sqrt(N)) - I am counting bit complexity). In total, it's O(N log N). The runtime is dominated by reading the input! The complexity of trial division and the brilliant AKS algorithm is the same from this viewpoint.

Even if you had an algorithm that did not have to convert to binary and could tell in time linear to unary represenation whether a number is prime, it would be interesting trivia but nothing worthy a Nobel prize. In practice numbers are given in binary (or some other base>1 number system). To use your algorithm, you would have to convert to unary, which already means trial division would be faster.

Re:Ask HN: How do you take care of your vision? on Tuesday December 23, 2014 @03:32PM (#8790044)
Flux https://justgetflux.com/ or redshift http://jonls.dk/redshift/.

Try setting it to the smallest temperature possible for 30 minutes and then turn it off to see the difference. I have it on all the time (though people working with colors might not be able to use it)

Re:The reason people burn out on open source on Sunday December 07, 2014 @10:20AM (#8712387)
Note it's not a pull request; it's an issue in the tracker. Had it been a prepared patch, I would have more sympathy towards the reporter.
If you ask Mathematica whether x^n + y^n = z^n has solutions for n>2 and x,y,z>0, the system will simplify it to "False", displaying knowledge of Fermat's last theorem. This is taken from documentation (last example in http://reference.wolfram.com/language/ref/FullSimplify.html).

I asked about x^n + 1 = z^n, which is a simpler special case with y=1. The system no longer recognized it to be False. So the theorem was programmed as thoughtless pattern matching. I think one day computers might become authentic "creative" tools for mathematicians (as opposed to "computational" tools), but Mathematica's philosophy seems to be a dead end in this regard.

Re:Guess the Programming Language on Tuesday June 17, 2014 @04:19PM (#7906758)
Re:Try Idris on Monday April 14, 2014 @03:14AM (#7584897)
That's exactly the point of monads - see http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/ba.... Such a system is still pure, btw.
When I write a program, I don't want it to be just correct (true); I want it to be _provably_ correct; I want to be able to be convinced that it is correct, at least in principle, given enough time and whole specification of the system. Programs which are correct, but not provably so, should not pass code review and might as well be lumped together with those which are wrong. It doesn't matter if you are using a full-blown theorem prover or thinking about the code in your head; Gödel's theorems are not really relevant to programming, even when the code uses deep mathematics.

I'm not sure I agree with "theorems that must be verified at compile time can never account for data that are provided only after compilation". At compile time, you prove the assertion "for every x, the program outputs correct answer for x". Now, you don't know that the user will enter say x=5 at runtime, but since you proved a theorem about _every_ x, this includes x=5. You cannot predict the future (the path that will be taken by the program), but once you prepare for all possible futures, you're safe.

Re:0^0 on Thursday April 03, 2014 @03:07AM (#7521358)
I'd like to add x^y is also used other contexts - e.g. for cardinal numbers and ordinal numbers.
Re:Toward a better programming on Friday March 28, 2014 @04:27PM (#7489761)
The standard deviation is a poor example IMO, in many languages you can get much closer to mathematical notation.

    def stddev(x):
        avg = sum(x)/len(x)
        return sqrt(sum((xi-avg)**2 for xi in x) / len(x))

    stddev xs = let avg = sum xs / length xs
                in sqrt $ sum [(x-avg)**2 | x <- xs] / length xs
Re:What it's like to use Haskell on Wednesday March 26, 2014 @01:56PM (#7475084)
To be clear: [] can refer to two different entities, a data constructor (empty list) and a type constructor (the list type).
Re:Ask HN: Where else can we use GPU processing? on Thursday December 05, 2013 @01:02PM (#6855906)
Here's a wikipedia link; maybe someone else will give a better description http://en.wikipedia.org/wiki/General-purpose_computing_on_gr...
Not really; discounting extremely simple programs like print "Hello world", there are many possible stylistic differences and people will write things differently. One person will write for, another while; one i=0;j=0, another j=0;i=0; another will name variables differently; another will take two lines and make them into a procedure; one will write "if x then return y else return z", another "if x then return y; return z;", another "if not x then return z else return y" another "return x ? y : z" etc. If your assignment is at least 50 lines of code, compare it with someone else. You will see tons of differences.

Older »