Ask HN: Turning client project into a business - <AUTHOR>

A few months ago I was hired to write a web application for a client to manage charity events.  I did the project and they loved it, got paid, and everyone lived happily ever after.
Just recently though, I started thinking to myself that if they had the problem and my software fixed it, there has to be other non-profits with the same problem that my software could help.
If I take the program, do some work on it to generalize it a bit (to make it more broadly applicable to others), and put a product site around it, would I be able to legally resell this?  Also, let's say I wanted to make it SaaS or cut a percentage off of registration fees or something, what options should I look into for charging?  Lastly, what are some other considerations here?
I'm currently working on another project that will take me a while to finish (started documenting at blog.spkto.us), but I figured I could have the event software ready to roll within a month, and maybe I should get that going first to generate a little extra income.
Thoughts? <comment><USER2> Depends on the contract you had with party - it all comes down to who owns the IP. If they own it, you cant sell it unless you have their permission.

Even if they own it, you can contact them and ask if they mind you selling a modified version of it.

<comment><AUTHOR> We didn't cover that in the contract unfortunately. I would assume we own the IP. Either way, whether I own it or not, I didn't know if it might cause problems if I rebuilt it to be more general and then charged a small fee to use it when they paid me a lot of money to build it originally.

<comment><USER3> Do you have a good relationship with the client? The best thing to do would be to call them up and ask.

<comment><USER4> I couldn't disagree with this more. Never call someone up and ask them what _your_ rights are with respect to intellectual property. How do you think the client is going to view it? Many clients assume ownership of intellectual property, simply because they don't understand it. By calling them and asking them, you're transferring the judgement to them. Consider that many people view code like they do any thing else they buy. If I pay someone to construct a building for me, I assume that I own the building when it is completed. But do I own the rights to the design (plans) for the building? This question is far less clear unless defined in a contract.

Rather, a better strategy would be to talk to a legal professional who understands the law in this area. Because the contract did not spell out who will "own" the code, he (the author) must gain an understanding of the legal perspective in these situations before he squanders his opportunity to reuse the code.

Even if the conversation with the client resulted in their agreement that the bherms can do whatever he likes with the code, that doesn't clear up the legal issue. What happens a few years from now when this charity is under different leadership and they notice the similarity between their management system and the one that sells for $30/month from whatever business bherms starts?

Talk to someone who knows these answers before you proceed. Nothing is worse than putting years of effort in to something, only to have it dismantled by something from your past that you could have taken care of easily.

</comment></comment></comment></comment><comment><USER5> I would highly recommend talking to a patent attorney or someone similar first. The fact that you built it on their time originally can throw all kinds of complications into the issue, especially if you didn't explicitly cover that in the contract.

There's a good chance you're fine to do that, but that's the kind of thing that can come back to bite you in the ass really quickly if you haven't looked into it.

</comment><comment><USER6> I think that's probably fine. Plain re-selling of the same code depends on the contract (probably you can't), but if you make lots of changes (and you would have to), it should be fine.</comment>


Functions: To Split or Not to Split - <AUTHOR> https://blog.jonstodle.com/to-split-or-not-to-split/ <comment><USER2> John Carmack has some thoughts on this issue: [http://number- none.com/blow/john_carmack_on_inlined_code.htm...](http://number- none.com/blow/john_carmack_on_inlined_code.html)

I personally prefer style C with occasional comments serving as guidelines for the reader.

</comment><comment><USER3> Nice post - thanks. I'm guilty of sometimes splitting and other times not, making the choice mostly on feel. Never modifying local state when splitting functions is an easy rule of thumb to follow.</comment>


Ask HN: Father of the Computer – Charles Babbage or Alan Turing? - <AUTHOR> My impression is that Charles Babbage is at best the father of the calculator. It was Alan Turing who deserves the full credit of the state of computing today. <comment><USER2> Pick up a copy of George Dyson's _Turing 's Cathedral_, and you may be left wondering whether this notion even makes sense.

Before even Babbage, Leibniz was obsessed with developing a notation for a universal language that could be used to program a mechanical structure using marbles.

</comment><comment><USER3> Every giant stands on the shoulder of other giants. Basically, the idea of "Father of so and so" doesn't make any sense.

</comment><comment><USER4> Turing takes my vote.

</comment><comment><USER5> Zuse?</comment>


BDDon't: The Practice and Tools of BDD - <AUTHOR> http://thoughtworks.github.io/p2/issue12/bdd-dont/ <comment><USER2> I made a similar argument several years ago, after being part of Ward Cunningham's Fit project (a precursor to tools like Cucumber): "The Problems With Acceptance Testing." [http://www.jamesshore.com/Blog/The-Problems-With- Acceptance-...](http://www.jamesshore.com/Blog/The-Problems-With-Acceptance- Testing.html)</comment>


First mutations in human life discovered - <AUTHOR> http://exactlyscience.com/archives/11655.html <comment><USER2> blogspam of

[http://www.sanger.ac.uk/news/view/first-mutations-human- life...](http://www.sanger.ac.uk/news/view/first-mutations-human-life- discovered)</comment>


Investing in a cleaner, more accountable web with spider.io - <AUTHOR> http://doubleclickadvertisers.blogspot.com/2014/02/investing-in-cleaner-more-accountable.html

<comment><AUTHOR> [http://seekingalpha.com/news/1584203-google-buys-click- fraud...](http://seekingalpha.com/news/1584203-google-buys-click-fraud- prevention-startup)</comment>


The Zen of Gradient Descent - <AUTHOR> http://mrtz.org/blog/the-zen-of-gradient-descent/ <comment><USER2> The author mentions Trefethen-Bau, "Numerical Linear Algebra" as a good reference. I couldn't agree more, it's a great resource.

<comment><USER3> Yes, but the second half dealing with iterative algorithms is pretty much useless, especially the chapter on conjugate gradients which is the one most relevant here. There isn't really a book that offers as easy an intro to iterative algorithms as Trefthen does for direct ones. In this case I would recommend to fall back on trusty old Golub and Van Loan (recently released in a new edition).

</comment></comment><comment><USER4> Throwing in my personal goto reference on gradient descent : [http://www.cs.cmu.edu/~quake-papers/painless-conjugate- gradi...](http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf) "An Introduction to the Conjugate Gradient Method Without the Agonizing Pain" \- Jonathan Richard Shewchuk.

<comment><USER5> This Shewchuk dude is one acceptable Canadian!

</comment></comment><comment><USER6> I must be confused, but isn't stochastic gradient descent a bit of an oxymoron? A stochastic search space implies independent points in the search space, so the Lipschitz condition doesn't hold.

Does gradient descent apply to problems with many local extrema, or is it restricted to purely globally convex problems?

<comment><USER7> Stochastic gradient descent is a "crappy" method that works. Theoretically, it ought to be slow to converge and often involves annoying tuning parameters because you want to slow learning with each iteration. In practice, though, it works quite well. Quite a large number of successful neural-net/deep-learning implementations use SGD rather than second-order (quasi-Newton) or even momentum methods.

Pointwise SGD tends to be uncommon and too noisy. Mini-batch sampling is more common. Each iteration, you train on a bootstrap subset (say, 10,000 points chosen with or without replacement from the full dataset). If you have less than 10k data points, you generally don't need to use stochastic algorithms at all.

 _Does gradient descent apply to problems with many local extrema, or is it restricted to purely globally convex problems?_

There are a variety of approaches:

* Multiple starting points. Often gets the job done and finds a good local minimum. The idea is that, usually, better (lower) local minimums will have larger drainage regions, a sort of "deep is usually broad" hypothesis that is often but not always true.

* Momentum. Instead of moving with a velocity proportionate to the gradient, it's proportionate to a smoothed average of previous gradients. This makes it far less likely that you end up at a bad local minimum or some other stationary point (at a local maximum or saddlepoint, the gradient is zero).

* Other stochastic devices such as simulated annealing or (for neural nets) drop-out.

* Dimensionality reduction and regularization (weight decay) don't necessarily solve the "multiple local minima" problem but often make the search space smaller and the problem, therefore, more tractable. (The main purpose of DR and regularization, however, is to improve generalization performance.)

<comment><USER8> Any favourite books/resources on the above?

</comment></comment></comment><comment><USER8> ah but descent is such a luxury! Zen comes only from knowing when it is time to _ascend_ the gradient, there to find new descending vistas that made the old valley look like a mountain!

would that all problems were so conveniently convex.

<comment><USER9> As a wise woman once said to me, "You can approximately solve the exact problem, or exactly solve an approximation of the problem." Truly these were wise words, and wiser yet are those who can choose correctly between these two (meta-)paths.</comment></comment>


Enlarging Pixel-Art without pixelation degradation - <AUTHOR> http://research.microsoft.com/en-us/um/people/kopf/pixelart/

<comment><AUTHOR> This appears to be an improvement over the hq4x algorithm used in emulators

<http://en.wikipedia.org/wiki/Hqx>

[http://research.microsoft.com/en- us/um/people/kopf/pixelart/...](http://research.microsoft.com/en- us/um/people/kopf/pixelart/supplementary/multi_comparison.html)

mouse over "hq4x" and then "ours" - but look at the "control panel" icon example - Microsoft results are inferior (clock hands etc) - the keyboard though is very "artistic"</comment>


Turning web design mockups into code with Deep Learning - <AUTHOR> https://blog.floydhub.com/turning-design-mockups-into-code-with-deep-learning/ <comment><USER2> A lot of people in this thread seem to think that this is a neural network that takes an image and produces HTML, when that's not the case here at all.

This is a neural network that takes an image and predicts very simple blocks (like BODY, TEXT, BTN-GREEN in the bootstrap example) and then uses a map to convert them to well-formed HTML. While I think it's a great learning example I think it's important to note that this does generalize at all to any other websites -- you are NOT going to replace an actual person writing HTML with anything like this.

You can see the mapping here: [https://github.com/emilwallner/Screenshot-to- code-in-Keras/b...](https://github.com/emilwallner/Screenshot-to-code-in- Keras/blob/master/floydhub/Bootstrap/compiler/assets/web-dsl-mapping.json)

<comment><USER3> You are correct. But like the other comment mentioned, the cool part about this is it automatically learns the mapping from image to sequence of tokens. To handle arbitrary html, we just need to extend it a little bit and convert all possible html input into tokens. I think the take away is this might be a feasible approach towards automatic UI code gen.

<comment><USER2> Automatically learning the mapping from an image to a sequence of tokens is a very fundamental task for CNNs and not particularly new.

I don't think it's clear, or likely, that this can extend to all possible html input tokens. As you add more tokens, it becomes more difficult for the network to choose among them accurately. Additionally, as the token set becomes more fine-grained the size of the output space will grow exponentially and the network will likely struggle to learn from the training examples as well as output valid structure.

I think you can compare this to approaches that receive an image as input and provide a caption of the image as output. Works surprisingly well in simple cases but no where near fully functional or actually capable of understanding all inputs.

I agree that this _might_ be a feasible approach toward automatic UI code generation eventually, but this is several significant levels of complication away from that.

<comment><USER3> Agree with you that this is by no means a complete solution and there is a long way to go to make it actually usable.

I think one big problem with image captioning could be lack of high quality training data. While in this case we can generate lots of good training data. Whether we will be able to generate enough good data and have enough compute power to train on them is something that we need to find out.

Playing go was considered a problem too complex to solve couple years ago, but it's now a solved problem. So I am hoping we can get a breakthrough on this sooner than we think.

<comment><USER4> Not wanting to dampen your high hopes, yet, the rules of Go seem a lot simpler than the rules and grammar of the current hypertext markup "language", particularly if taking the "browser dialects" into account, which are crucial for professional pages....

</comment></comment></comment></comment></comment><comment><USER5> Well, this seems like it could be useful for the times you just want a quick prototype mocked up and can't be bothered to code it, or when you're dealing with sites that don't need much in the way of dynamic functionality.

However, it also makes me think that:

A: Maybe developers (and software engineers in general) should stop thinking their own jobs are necessarily safe from automation, since something like this could be the first step to the field going the same way as lorry or taxi driving will in future.

B: That agencies might start seeing their basic web development work start drying up in the not too distant future.

<comment><USER6> B. Yes.

A. No. Good developers can run up the abstraction chain to keep providing value at a higher level. Most good devs fundamental value prop isn't "I can make something in HTML".

If anything, this will mean that more people can do the redundant stuff faster.

As a frontend guy, I can't wait for the day that a tool can generate presentational stuff.

<comment><USER7> I agree with your response to A in the short term. In the long term, however, much like a mountain in a flood people can only scramble so high before they run out of oxygen, or run out of room.

<comment><USER6> To take your metaphor a bit too far, it's fortunate that we have more than one mountain. ;)

Sure, the days in which the web guy was viewed as a special guru won't last forever. But even with auto-generated mockups, we're still a long way from computers taking over everything.

</comment></comment></comment></comment><comment><USER8> This is really great.

Many years ago, I was neck deep in frontend coding. I got so good that when given a mockup, I could code the skeleton of the page "blind" without viewing it in the browser. I would load the page at the end and grade myself on how accurate I was. I've always wanted to do a contest with other frontend coders to see who could get closest to a complex layout—like the NYTimes—in one go.

One day, this type of skill will become a curiosity—a relic of the past similar to horseback riding. I would be happy to see the automation of pure translation of boxes into code.

<comment><USER9> Sorry if this is OT, but these types of contests exist! I went to one of these[1] maybe two years ago in Stockholm and I had a blast. I think the format was 32 people competing, 8 on stage at a time being shown a design which they had 15 minutes to mimic without previewing, then the crowd voted for winners using their smartphones. Two winners from each group of 8 went on to the finals. The competitors screens were mirrored on screens facing the crowd, so everyone could see how people tackled the problem in real-time. One guy did an ASCII representation of the design, which the crowd enjoyed enough to send him to the finals.

A large audience, smoke machine and lots of lasers, hard techno, and free beer. They did an amazing job setting the mood. They even have their own IDE[2] that everyone competing is required to use (with combo-counter and cool rave-y visual effects).

[1] [http://codeinthedark.com/](http://codeinthedark.com/)

[2] [https://github.com/codeinthedark/editor](https://github.com/codeinthedark/editor)

<comment><USER8> That is incredible! I knew there would be the off chance that someone would have put something like this on, but this looks like they went all in.

</comment></comment></comment><comment><USER10> I'm still waiting for the generation of tools that are native to the medium—fluid, responsive, interactive, and aware of the final context for the design. So we don't start with static mockups that have to be converted, but rather build web-native from the beginning.

There are some promising moves that direction (such as responsive resizing in Sketch and projects to automatically convert sketch files to React components), but we're not there yet—most designers I know are still producing largely static designs that have to be put through development cycles.

And I know you _can_ live design with HTML and CSS, skipping the static mockup phase. That's my preferred method at the moment, but I'm here to tell you it's still pretty slow and tedious and makes me long for better web design tooling.

<comment><USER11> Honestly, I actually find it really really fast. I don't know how long you've been doing this and I suspect that may be the issue here, but for me it just comes so naturally now that I can't think of any other tool someone could use to outrun me using CSS/HTML.

More broadly, to me, that combo is one of the tools that makes me feel most connected to the output, as the results are near instantaneous.

<comment><USER12> Have you ever watched a good designer mockup something using Indesign, PowerPoint or a Wordpress Theme like Divi? They're superfast with the visual tools. I doubt you can match that in CSS/HTML.

There's a reason Visual Basic was so popular in the 90s. That sort of development kind of got forgotten when the web overtook everything. And it's why Alan Kay made Smalltalk a visual environment, and not just raw code in an editor, because human beings are faster designing UIs with visual tools.

</comment></comment></comment><comment><USER13> While cool I am not sure if this is genuinely useful. I can now take my design and convert it to HTML- now what?

I still have to integrate my api, handle responsiveness, add JavaScript and other animations/actions etc. So I'll probably end up rewriting most of it anyway.

What I actually get out of this is not much better than emebedding the original image in an img tag, in fact it might be worse, because it creates technical debt that I now have to maintain.

<comment><USER14> I think the potential is in converting images (sketches) into ux source files that you can edit immediately and then convert those to HTML, PDF, DOCS, etc. I can see that the HTML would more likely used for a clickable prototype than the real thing, but it could still be a neat way to save some time. I'm working on a (text-command) ux tool and have been thinking about such a machine learned import feature, but lack those skills and time at the moment to build it.

</comment></comment><comment><USER15> Wow, really cool article!

I am not a huge fan of front-end dev, so I am really excited about the great opportunities behind this work/research. It will be another major step in the democratization of UI and less work at maintaining the web views.

My biggest concern is the model capacity. My question is: in your opinion, will it be able to handle very long HTML page? not to mention when it will be added a lot of CSS or JS. Even with more layers, will the model be able to generate corrected syntax(for really long pages)? will it need some additional modules(not only layers) to handle this? maybe a different problem formulation?

<comment><USER16> The model uses 48 tokens at a time to make the next prediction. As long as it can keep track of where it is on the design image, it's not a problem. In the final version, it has roughly the same accuracy (~97%) on short and long websites.

The tougher part is integrating JS or adding hover effects in CSS. In theory, this can be done with an attention layer, but I haven't seen any papers on it.

</comment></comment><comment><USER17> Another step closer to my dream: a cross-compiler that takes as input a Powerpoint presentation, and outputs the enclosed-described mobile app, cloud- hosted website/backend, and Delaware C Corporation.

<comment><USER18> Or just ICO whitepaper.

</comment></comment><comment><USER19> I'm not sure about the usefulness of coding UI prototypes.

When I owned a web design firm, if the UI wasn't polished, clients had a hard time wrapping their head around the design or what the final product might look like. In every case I remember we had to make it pixel perfect in the design phase and then again in the development phase.

It was a huge pain and an area ripe for innovation but I think the problem like other posters have mentioned is a lack of quality responsive design tools that are better than simple HTML/CSS design in the browser.

</comment><comment><USER20> This is a cool idea. I think this technology could potentially assist front- end developers and the designers who work with them even though there's still a fair amount of craft involved. Browser compatibility has gotten better on the desktop in recent years but the mobile appearance of websites is as diverse as ever. It might be interesting to explore "mobile-first" or "progressive enhancement" applications of this technology.

<comment><USER21> Did you see any of the output source? I wonder if it's clean enough to be understood by humans, or if it's one of those situations where it's been optimized to work but not be understood.

Then again, if you used some additional inputs like "readable code", it theoretically could optimize both the resulting application and the source code.

<comment><USER20> Yeah I believe it's about 2/3rds down the page under the heading "Links to generated websites." It's a far cry from the old Dreamweaver days. I could see running into some complexity with CSS. Things like which units to use (em, vh/vw, %, px, rem, etc), building a readable selector hierarchy, or using newer CSS technologies like CSS grid or animations.

</comment></comment></comment><comment><USER22> In the short-term, this approach will struggle to compete against WYSIWYG editors. But as soon as they can match them in output, they'll improve exponentially faster. WYSIWYG editors has a ton of code to maintain, while a model is simple to improve.

</comment><comment><USER23> It's awesome to see how people have picked up and built on top of pix2code (original author here). Very exciting time for front-end development in general!

</comment><comment><USER24> If the goal is to recreate the _layout_ of a site then the context text isn't really important. You could represent each letter with a filler character e.g. . Then, you only need as many tokens as you have words with distinct numbers of characters. This approach (similar to how we use lorem ipsum for prototyping) would dramatically reduce the complexity of the model.

<comment><USER25> Why wouldn't you be able to train it to recognize expected behavior from a mockup? You could easily create a nomenclature of symbols to define standard behavior (⇑ could mean draggable upload for example). Even if you can get it to take you 80%, that would be huge.

</comment></comment><comment><USER26> When an AI does create a web page successfully in terms of replacing what a human can do completely, it will probably make the code in such a way that it is unmaintainable because why make it maintainable? We would not have to maintain it anyway. It would be like spaghetti code yet would look amazing on the presentational side. No one would give a damn anymore about coding styles or elegant frameworks like react, you could just bark at it and it would morph around. Sites/apps would just be thoughts you could construct on a whim that typically changed frequently or autonomously to produce the maximum desired result. Meanwhile we're sucking down nutrient packs floating in stasis in our travel pods spending the majority of our time in virtual consciousness.

<comment><USER27> That is just a further step in the training that could be undertaken. Many of the advances in machine vision come piecemeal for instance. One team advances one idea that does some thing(s) very well, but has some drawback(s) which another team comes up with a solution for at a later date. Maintainability of code could be something the AI is eventually trained to take into account.

<comment><USER28> maintainability is irrelevant if the whole site can be regenerated in seconds with the new changes required.

I'm okay with this though. Creating websites is tedious and is most analogous to cranking a handle as it is a learnable skill. After a while it is clear it is just banging characters and seeing what changed on the screen this time.

Bear in mind I'm only talking about implementing the layout, colors, texts and responsiveness. Any dynamic functionality such as forms, buttons, dialogs, integrations and talking to servers is still potentially very complex and difficult taking.

</comment></comment></comment><comment><USER29> _> Currently, the largest barrier to automating front-end development is computing power._

Actually, it's poorly though-out web technologies that don't allow for reasonable WYSIWYG editing.

</comment><comment><USER30> Stack Overflow answer iterator + genetic build algorithm = 90% of software development

<comment><USER31> You'd be right, because most software development creates more code dept than features.

<comment><USER32> I think you mean "debt" \-- I first read your comment as "code department" and was trying to figure out what that was.

</comment></comment></comment><comment><USER33> I have worked mostly on frontend development and have to say that the quality of pixel perfect code being generated will make many a designers happy!

Super awesome!

</comment><comment><USER34> I know alot of you smart ones think this isn't that great, but I think this is incredible. I'd love to see someone host this someplace so I can just upload an image and see what it spits out.

I'm not smart enough to take the code and get it running...

<comment><USER16> It's not rocket science, I think you can figure it out. To get started:

git clone [https://github.com/emilwallner/Screenshot-to-code-in- Keras](https://github.com/emilwallner/Screenshot-to-code-in-Keras)

pip install -U floyd-cli

(login to floydhub.com, a super simple platform for cloud GPUs)

cd Screenshot-to-code-in-Keras/floydhub

floyd init picturetocode

floyd run --gpu --env tensorflow-1.4 --data emilwallner/datasets/imagetocode/2:data --mode jupyter

Then, navigate to the folder floydhub/Bootstrap/test_model_accuracy.ipynb in your Jupyter Notebook and click on Cell > Run all

Now you can see the prediction and the correct markup for all the evaluation images. Ping me on twitter: @emilwallner, if you get stuck.

<comment><USER34> Thank you sir, I'll try that out!

</comment></comment></comment><comment><USER35> Cool work! I'm very interested in this topic. Just wondering, how good does it generalize your training data other than just remembering strict input-output mapping?

<comment><USER16> The bootstrap version generalizes with 97% accuracy on a new image. Because the vocabulary is limited, you can train the model overnight. To make the model generalize with all the HTML/CSS markup you need significantly more compute.

</comment></comment><comment><USER36> This is, approximately speaking, useless. Which is not to say it shouldn't have been done; you have to make a lot of useless prototypes with any new technology before you can actually make something useful. So long as one considers it in this light, it's cool. Just don't get too excited about not having to do this work yourself (if you need it done) for at least the next several years (perhaps decades).

<comment><USER37> I don't think it will be decades. AI and DL are on a very fast pace the last 2-3 years and progress increases exponentially.

</comment></comment><comment><USER38> This is great example of deep learning that is applied to real world problem. I am just curious if that can be done more easier and more robust by using simple image processing algorithms? Box detection and OCR can work well and may produce better results with different types of mockups. Sometimes I feel like we are making problems even more complicated trying to solve them by using popular concepts.

</comment><comment><USER39> "Nothing made sense until I understood the input and output data. The input, X, is one screenshot and the previous markup tags. The output, Y, is the next markup tag. When I got this, it became easier to understand everything between them. It also became easier to experiment with different architectures."

Thanks a lot for a great write-up. Truly a good browse for anybody learning Neural Nets.

</comment><comment><USER40> You didn't turn anything into "code", you converted an image to markup; you've just "described" the image. This doesn't work for any sort of web app. A flat image from a designer does not convey enough information to build a proper interface. What of responsiveness? Or hooking it up to an API? Or accessibility? Or animations?

<comment><USER41> I would agree. However, most websites start out as such a design image. Getting the markup for the design, and adding onto the generated html/css template could speed things up.

-edit Also who is to say that it will not be able to do more in the future. More features could be added.

<comment><USER40> Markup is more than how it looks like. Some times a <p> tag should actually be a <span> or a <div>. Sometimes a button should be an <a> tag, sometimes it should be a <button>. I wouldn't use the <article> tag if the content wasn't standalone (a blog post, newspaper article, etc.).

You need to _understand_ what has been designed and the goals of the project to know which tags to use. I need to actually read the content to know if I should use <article> or <section>. There's not much time saved if I have to go back and readjust everything, I may as well have written it the way I wanted it in the first place.

It won't be able to do more in the future, computers can't _understand_ things.

<comment><USER21> Do humans understand things, or does our inner voice merely tell us we do? Without more concrete answers to some very vague/often infuriating questions, it's a very bold and unsupported position to suggest that computers cannot understand something.

To me, it's still up in the air whether we understand things, or if we're just applying a lot of simple, low level, information processing networks. Recognizing objects in vision, for example, turns out to be a serious of clever organizational and optimization tricks around simple mathematics.

<comment><USER40> That's a fair point! Part of understanding something is being able to explain it in different terms. We tend to create metaphors to display our understanding of things. Merely rearranging the words in a sentence does not mean you understand it, my grade school teacher would dock me marks for that.

So in order for a computer to understand something, it has to also understand _something else_ , otherwise it can only regurgitate back what you've given it. If I tell a computer "there is snow covering a hill" and it responds "a hill is covered in snow" I am not sure it really understand what I said. But if it responds "snow blankets the hill"... Ohh! Now it understands!

This begs the question, what was the first thing we understood? I don't know! Maybe we're born with a certain level of understanding? Maybe our biology imparts a baseline understanding-of-things? If that's the case, then computers can never understand something; they have nothing to build off of, only what we tell it to regurgitate.

<comment><USER21> So, if I understand you correctly, being able to generate context-aware comparisons from similar knowledge is understanding? (I promise I'm not trying to trap you -- I think this is interesting and would like to explore more.)

What do you think about the classic example from computational linguistics[0]? Is that approaching understanding?

That seems like a neat trick, not actual comprehension, but I don't know why.

[0] King + Women = Queen, see [https://cacm.acm.org/news/192212-king-man- woman-queen-the-ma...](https://cacm.acm.org/news/192212-king-man-woman-queen- the-marvelous-mathematics-of-computational-linguistics/fulltext)

</comment></comment></comment></comment></comment></comment><comment><USER42> Really cool. I wonder what a differentiable HTML renderer (akin to [https://www.researchgate.net/publication/270158331_OpenDR_An...](https://www.researchgate.net/publication/270158331_OpenDR_An_Approximate_Differentiable_Renderer)) would look like, since it could be used in a similar manner.

</comment><comment><USER43> I'm curious about how it handles design changes. Will it just rewrite from scratch? or adjust the code it has already written?

<comment><USER16> This approach rewrites everything from scratch.

However, it's an interesting technical problem to adjust the code. Does anyone have a rough idea how to implement it?

</comment></comment><comment><USER44> This is great to see!

It's popular to apply AI to healthcare, transportation and legal work. However, these fields are heavily regulated, require domain expertise and data is hard to get. The nature of front-end dev and other digital skills make them more ripe for automation. I'm surprised there is so little progress in this area.

<comment><USER16> I agree, researchers tend to focus on more academic problems and industry goes where the money is, leaving some areas without innovation. I've come across few papers that cover frond-end development.

</comment></comment><comment><USER45> I worked on a similar project but was generating graphics code with both java and ruby: [http://www.jtoy.net/projects/sketchnet/](http://www.jtoy.net/projects/sketchnet/)

<comment><USER16> This is rad, thanks for sharing it.

</comment></comment><comment><USER46> It's just the loud title. Generated templates are consist from ready components in examples. It's quite simple to do with minimum knowledge about code and usually useless, because people need more from interface

</comment><comment><USER47> So... it recognizes text (OCR), detects style (bold, italic, etc.), maybe font face, and outputs the result? No pictures, nothing else, of course.

Props for the marketing though.

</comment><comment><USER48> From reading the comments, it looks like a lot of people are bored of mundane web design. I'm right there with you. Give me something interesting to do!

</comment><comment><USER49> If this can get one step further and generate a layout from a hand-drawn sketch, it would really be a gamechanger!

<comment><USER50> Check out [https://airbnb.design/sketching- interfaces/](https://airbnb.design/sketching-interfaces/)

</comment></comment><comment><USER51> Can you make the page "pop" more?

</comment><comment><USER52> Would be nice if this was in some adobe product. Then you can go from illustrating straight to web site.

</comment><comment><USER53> This is phenomenal.

</comment><comment><USER54> didn't Dropbox also recently blog about this?

</comment><comment><USER55> I love this! Hope no one turns this into some SaaS startup though :(

<comment><USER41> You know business people of course someone probably will try. That recurring revenue stream is what they drool over.

</comment></comment><comment><USER56> this would go well with a template language that maps objects to markup rather than having to put template code within the markup.

</comment><comment> dh-g HTML is not code, its markup.

<comment><USER57> It is code, it is not a programming language.

</comment></comment><comment><USER58> But, in today's workflow, it is trivial for designer to generate the code or even animation with their mockup tools, right? This is useful in a sense if you only have an image of the design, like to quickly copy a competitor's work, but not really that groundbreaking for company's internal design workflow, the hard part of which is to figure out what is good design, not given a design layout then translate into markup</comment>


Apple Magic Toolbar – Trademark Exclusive – New Macbook Details - <AUTHOR> http://thetrademarkninja.com/2016/10/19/apple-trademark-exclusive-new-macbook-details/ <comment><USER3> Interesting. I just Google imaged searched for "Apple Magic Toolbar" and I noticed one of the images had the power button as part of the bar... So I'm assuming it's a touch screen bar, so if your computer freezes or acts up how do you force it off? unless the bar would be a separate CPU/device which talks to the rest of the comp...

Can't remove the battery, and if the power button is part of the GUI and not a actual button seems like it could lead to some problems in theory unless they engineered a way around it...

Otherwise this seems cool. Another pic had the F1, F2 keys, etc so probably would be a way to switch between them for apps that need the F Keys. Will be interested in learning more about this.

</comment><comment><USER4> Yes, it most likely the rumored OLED strip above the keyboard in the new MacBook Pro. From what I have heard, it acts as an extra toolbar for the current app, as opposed to a more system wide toolbar.

<comment><USER5> I don't quite get the justification of something like this over simply having more screen real estate. It's undoubtedly more expensive; is it just supposed to be a marketing gimmick to woo people? Or is there are reason why I'd want something like it?

<comment><USER6> More screen estate in the same space would mean a denser panel - <USER2> hardware cost. Also would mean lower battery life - higher user cost.

<comment><USER5> I implied a bigger panel. Same width, but 16:10 instead of 16:9. This toolbar thing isn't free either wether it's literal money we're talking about or power consumption.

<comment><USER6> Well, if it's e-ink, there's no power consumption except when it changes. Plus it's probably a lot cheaper to find a small strip of e-ink panel (given the number of Kindles etc.) than to find a Retina-class 16:10 panel.</comment></comment></comment></comment></comment>


Open Sourcing of Windows Calculator - <AUTHOR> https://blogs.windows.com/buildingapps/2019/03/06/announcing-the-open-sourcing-of-windows-calculator/#EU3JU7lh75oW8J4X.97 <comment><USER2> Comments moved to [https://news.ycombinator.com/item?id=19321217](https://news.ycombinator.com/item?id=19321217).</comment>


Tethered Jailbreaks Are Back - <AUTHOR> https://blog.trailofbits.com/2019/09/27/tethered-jailbreaks-are-back/ <comment><USER2> Yay!

I have fond memories of my friends (and eventually me, on the family iPad) jailbreaking our devices and doing stuff with them.

A _lot_ of the things I saw from jailbreaks were incorporated into later iOS updates- I'm curious (and excited!) to see what develops out of this wave.

<comment><USER3> What's the point now that we have Android?

<comment><USER4> So far, only iOS can run on iDevices, which means if you want to use Apple hardware you have to use iOS.

<comment><USER3> I hardly see any compelling reason to stick to Apple hardware.

<comment><USER5> Well it appears Apple are really working towards user privacy as their main sell where android is locked in with Google Play services so though I do not personally have a preference I do know why some people choose Apple devices.

<comment><USER3> You can disable Google Play Services on a rooted Android. Besides I'm pretty sure all baseband CPUs have backdoors the carriers can tap into at any time.

<comment><USER6> I keep hearing this argument, but if I'm buying an Android device I'm still supporting Google and Android. The thing is, I don't want to support them at all.

</comment></comment></comment></comment></comment></comment></comment><comment><USER7> Honestly, if there's a real security risk, I'm surprised Apple hasn't recalled the phones or offered to repair them. Unpatchable firmware flaws are (or should be) no different from hardware flaws in this respect.

<comment><USER8> > if there's a real security risk

There is, but it's not that great. You need physical access to the device and it won't be persistent (a reboot will clean it).

<comment><AUTHOR> It certainly will _feel_ persistent if you're successfully attacked with this technique.

If your iOS software is swapped out for a version with a backdoor, then the attacker will have collected your passwords and authentication tokens to services you use. If you reboot to clear the backdoor (and let's be honest: no one reboots their phones), then you won't also "clear" your attacker's memory of all your passwords.

<comment><USER9> I reboot my phone once in a blue moon, but my phone reboots itself roughly every other day (usually because I space on charging it). Am I that unusual, or is "the phone is rarely going to reboot" not really a reliable predicate for attackers?

<comment><USER4> I similarly reboot my phone rarely, but my phone never runs out of battery. I never charge it during the day (except if I'm using it for GPS in my car), and it's just a routine to charge it at night. I don't think my current phone, which I've had for about a year, has ever run out of battery.

</comment></comment></comment></comment></comment><comment><USER10> Interesting that the writers of this article are a company that sells a library to help developers detect their app running on jailbroken devices. [https://blog.trailofbits.com/2017/10/12/ios-jailbreak- detect...](https://blog.trailofbits.com/2017/10/12/ios-jailbreak-detection- toolkit-now-available/)

<comment><USER11> >library to help developers detect their app running on jailbroken devices

How does this work? I thought iOS apps are sandboxed to an extent where it shouldn't be possible to snoop around to determine which processes are running and such.

<comment><USER12> A jailbroken device allows apps to do things that a non-jailbroken device does not.

I maintain my company's in-house mobile app crash reporting system and I had to remove jailbreak checks from our iOS SDK. It turned out that some of the checks were causing crashes themselves due to buggy anti-jailbreak-detection code some jailbroken devices had in place. e.g. checking whether a file could be accessed that normally iOS disallows would end up causing a crash instead of just a permission error.

Instead, I just do some basic server-side detection. Basically, looking for libraries loaded into the app (e.g. cydia) that are only present on jailbroken devices. Some jailbreaks don't even try to hide their presence.

I don't know what iVerify does. I hadn't heard of it before. I'm curious how it avoids crashes though... perhaps it avoids invoking any dynamic system calls.

<comment><USER13> Out of interest, why do you care if your users run your application on a jailbroken device? It's been a question I've had for a while..

<comment><USER14> Same reason as why rooted Android devices get blocked by certain applications. Security for the user's sake. Usually it's financial applications (banking etc.) and stuff with sensitive user information.

<comment> yjftsjthsd-h As an Android user, this is super annoying: I rooted the device because I want to control it. Now some stupid app comes along and claims that, for my own protection (supposedly), they're going to break for me. It's insulting, really.

</comment></comment></comment></comment></comment></comment><comment><USER12> Prior discussion:

[https://news.ycombinator.com/item?id=21099996](https://news.ycombinator.com/item?id=21099996)

</comment><comment><USER15> I jailbroke my old iPhones but that was in an earlier less featureful iOS era. I wonder what hackers will be able to provide such that I'd do it on an SE. Curious now as much as I am skeptical.

<comment><USER16> All I wanted is a mirrored CarPlay option with a cursor for people who use a joystick instead of a touchscreen. I know this exists in the jailbreaking community (minus the cursor).

</comment></comment><comment><USER17> > We strongly urge all journalists, activists, and politicians to upgrade to > an iPhone that was released in the past two years with an A12 or higher CPU.

This makes no sense. The data of these VIPs is not in (more) danger due to this new jailbreak appearing. It sounds like a cheap trick to make people buy new phones.

<comment><USER18> "checkm8 doesn't allow law enforcement to decrypt the phone, but it does allow them to rootkit it with 30 seconds of unattended access. Once it's unlocked by the user they'd get everything they need."

That sounds like something more than a little worrying to the listed groups of people, no?

<comment> yjftsjthsd-h So if the phone is out of your sight, reboot. And now you're clean again.

</comment></comment></comment><comment><USER19> This will delight the one person in ten thousand who wants to jailbreak their own phone, and the border police in Australia (mandatory scans of phone required on demand), or China, or stalkerware retailers, or repair shops who like to rat around on customers' phones.

Guess which will be the more common use?

<comment><USER20> You can already assume that states are sitting on exploits that they've found or bought, and that they can compel companies to provide some form of access via NSLs or secret courts.

<comment><USER21> only more advanced states.

<comment><USER20> Nah, anyone with a pile of money can buy exploits and hire professionals to discover them.

Kingdoms in the desert have had access to root certificates for almost a decade now.

</comment></comment></comment></comment><comment><USER22> If anything this should be a boon to users. It allows them fully to use their devices they own. Honestly, it is inexcusable that apple makes users have to hack their own devices. You should have the option similar to enabling or disabling secure boot on your PC.

</comment><comment><USER23> Are there potential disadvantages involved with "demotion" to enable JTAG? From what I understand the process is permanent (eFUSE?) but it seems like a fun thing to play around with

<comment><USER24> Jailbreaking is software based and doesn't actually void your warranty. Demotion will.

</comment></comment><comment><USER25> Oh, here's a biz idea: build exploit into device, then when you've got something better/stronger/faster to sell, you leak the exploit and let the press urge people to buy your latest.

</comment><comment><USER26> As I see it, the effect of this is twofold. While it's bad for (at least some of) the iDevice users who carry sensitive data - it might also be just the thing that makes those users buy a new device. I guess that would be a "good" security issue in Apple's book.

And no, I'm not implying that Apple has designed this security flaw in order to sell more devices.</comment>


Another New Form of Carbon - <AUTHOR> https://blogs.sciencemag.org/pipeline/archives/2019/11/15/another-new-form-of-carbon-its-a-weird-one <comment><USER2> A bit of a tangent, I think the following part is gold and really captures the moment:

> ... It comes over you when you're suddenly faced with a new result that > shows you just how strange and unexpected the physical universe can be. At > first, all you can do is just stand there and wonder what the hell just > happened (and whether you can do it again!) The feeling is an intense > version of the amazement you feel at watching a particularly good magic > trick, intense because _it's not a trick_.

</comment><comment><USER3> I like this writer, recognized his headshot from Things I Won't Work with [1]. He's able to write about dead serious chemistry and make you laugh your ass off.

EDIT: If you like that sort of stuff he has a whole category of TIWWW: [2]

[1] [https://blogs.sciencemag.org/pipeline/archives/2010/02/23/th...](https://blogs.sciencemag.org/pipeline/archives/2010/02/23/things_i_wont_work_with_dioxygen_difluoride) [2] [https://blogs.sciencemag.org/pipeline/archives/category/thin...](https://blogs.sciencemag.org/pipeline/archives/category/things- i-wont-work-with)

</comment><comment><USER4> This is actually interesting, if true. The headline should be something like "semimetallic, reflective form of carbon discovered" though, for the HN audience. "It's a weird one" just doesn't catch here.

<comment><USER5> Click bait headlines are rather dishonest.

<comment><USER6> It's actually a version of Carbon that has interesting and strange behavior, so I'm not sure it's inaccurate.

</comment></comment></comment><comment><USER7> There is a better article at DOI 10.1126/science.366.6467.782, if you know where to find such things.

When Chemical Vapor Deposition is used to produce simple structures like diamond or graphene, the carbon source is typically methane, with one carbon atom.

These scientists instead used molecules with 6 carbon atoms in a † shape, which deposit to form a more complex structure. Their unofficial name is "U-carbon" (for "unusual"). They suspect that variations of the process could produce hundreds of new allotropes.

Edit: The article from the DOI is also at [https://www.sciencemag.org/news/2019/11/next-graphene- shiny-...](https://www.sciencemag.org/news/2019/11/next-graphene-shiny-and- magnetic-new-form-pure-carbon-dazzles-potential)

<comment><USER8> >if you know where to find such things.

sci-hub.tw

<comment><USER9> ;)

</comment></comment></comment><comment><USER10> "The group has not yet settled on a name for the mystery material. Jena calls it U-carbon—U for unusual. But Therrien, inspired by medieval alchemists who sought in vain for "adamant," an unbreakable lodestone, is calling it adamantia."

Is adamantium trademarked?

[https://www.sciencemag.org/news/2019/11/next-graphene- shiny-...](https://www.sciencemag.org/news/2019/11/next-graphene-shiny-and- magnetic-new-form-pure-carbon-dazzles-potential)

<comment><USER11> Is that how trademarks work? Can I not name a newly discovered species a trademarked name as well?</comment></comment>


Show HN: My First Portfolio Site - <AUTHOR> http://www.stolarsky.com

<comment><USER2> Responsive needs some work on mobile device size.

Since your title says "web and mobile" I immediately judged you by scaling my browser down.

</comment><comment><USER3> One of your projects gave me an idea for a future project for myself. Thanks!

P.S. Typo: "intreseted".

</comment><comment><AUTHOR> Any feedback would be very much appreciated!</comment>


The Football Genius of F. Scott Fitzgerald - <AUTHOR> http://online.wsj.com/articles/the-football-genius-of-f-scott-fitzgerald-1414166403

<comment><USER2> So what this is saying is that Fitzgerald may have helped to shape the "old sport".</comment>


Python: copying a list the right way - <AUTHOR> http://henry.precheur.org/2009/2/11/Python%3A_copying_a_list_the_right_way.html <comment><USER2> DO NOT replace [:] with list() next time you see it.

While the article explains some concepts well, [:] is no less pythonic than list(), though the latter might be more readable for people completely new to the language. In fact, it would be helpful to become very comfortable with python slices early on, because they allow you to easily manipulate any sequence, not just lists. For example, you can reverse a string using slices in one line:

      reversed_string = orig_string[::-1]

Staying away from slices, you're leaving that power behind.

<comment><USER3> Programming shouldn't contain 'neat tricks'. (Incidentally, one of Python's guiding principles is "explicit is better than implicit": <http://www.python.org/dev/peps/pep-0020/>)

Every single instance of "reversed_string = orig_string[::-1]" should be preceded with a comment saying "reverse the string", because it's not immediately obvious what [::-1] does. You can _learn_ what it does, but it's not _obvious_ , the same way a cryptic regex isn't obvious. So why not write reversed_string = orig_string.reverse()? (Or reverse( orig_string ) if that's more Pythonic.)

<comment><USER4> But [:] and [::-1] are not neat tricks, they're basic features of the language, and are immediately understandable once you've learnt about slices. Practically the opposite of a cryptic regex.

The purpose of comments should not be teaching the reader the language, that just makes the code noisy.

<comment><USER5> But regular expressions are not neat tricks, they're basic features of Perl, and are immediately understandable once you've learned about them.

<comment><USER4> Are you suggesting that a cryptic regex is as easy to read as [:] or [::-1]? If you know python, that syntax is clear at a glance, dense regular expressions are not comparable.

Basic language features don't need comments, difficult to read lines do.

<comment><USER6> And that depends on if regular expressions are a basic language feature. The proper way to "explain" or "comment" a complex regular expression is not to include a single line comment near it, but to use the /x modifier that allows you to "extend your pattern's legibility by permitting whitespace and comments". That is, of course, assuming you're using a language where regular expressions are first class types and has syntax to support regular expressions as literals (if you have to include your regular expression in a quoted string, your language doesn't), and uses PCRE.

</comment></comment></comment></comment></comment></comment><comment><USER7> Huh, I've almost never seen [:], would never think of it. Do people really use that? I mean it takes a lot of work to make python cryptic but I guess if you're determined anything is possible.

use deepcopy or list().

I don't even use [] or {} to create empties anymore. I much prefer explicit esp since there is proliferation of container types and it's silly, inconsistant, and confusing that dicts and lists have syntactic exceptions.

        newlist = list()
        newdict = dict()
        newdict = defaultdict(str)

etc.

And to anuraggoel. not using [:] is not avoiding slices. just as not using string += "ext" (esp in loop) is not avoiding strings.

<comment><USER8> Creating empties with {} takes just 58% of the time as dict() [0.25 us, 0.39 us] because there's no need to LOAD_GLOBAL and CALL_FUNCTION.

'not not variable' is similarly faster than bool(variable).

(not that I've run into this often in Python.)

<comment><USER7> > takes just 58% of the time

Whoopee fucking doo, _really_.

</comment></comment></comment><comment><USER9> Nice, clear explanation of something that drives Python beginners crazy-- especially if it's their first programming language.

It would have been worth mentioning the 'copy' module. 'copy.copy' for shallow copies of _any_ object, 'copy.deepcopy' for recursive copies.

<comment><USER10> I'm guessing, but a function that can copy any object is unlikely to be as efficient as one that works with known types.

Of course, even if true, that may not matter.

See, I'm all about the weasel words today.

<comment><USER11> It would be a little faster. The first part of copy.copy looks like

      def copy(x):
        """Shallow copy operation on arbitrary Python objects.

        See the module's __doc__ string for more info.
        """

        cls = type(x)

        copier = _copy_dispatch.get(cls)
        if copier:
            return copier(x)

        # more after this point but it's not relevant for lists

So calling copy.copy on a list over using list() will check for the type, look up the type in a dictionary after which it will proceed as if you called list() yourself.

<comment><USER10> Mental memo. :)

</comment></comment></comment></comment><comment><USER12> I thought this was going to be a talk on performance issues. I think most python people dealing with production code would understand either.

</comment><comment><USER13> _This is confusing for beginners and should be avoided._

That doesn't follow.

Beginners need to learn list slicing to get anywhere with Python, and by the time they've got through [1], [0:10], [2:], [:5], [:-1], [0:10:2] and so on then [:] is just another use in the same pattern.

<comment><USER3> Drat, the only one I don't know is [0:10:2]. I guess it's back to The Python Tutorial for me. <http://docs.python.org/tutorial/>

Followup: The tutorial didn't seem to mention what [x:y:z] does, so I checked:

      >>> range(15)
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

      >>> range(15)[0:10]
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

      >>> range(15)[0:10:2]
      [0, 2, 4, 6, 8]

      >>> range(15)[0:10:3]
      [0, 3, 6, 9]

So the third argument is the number of elements to skip (minus one) between each item in the new sequence. Neat.

<comment><USER14> I also found this: <http://www.python.org/doc/2.3.5/whatsnew/section- slices.html>

These are "extended slices" and the third argument is the step. This link also explores deletion and the __getitem__ method:

 _One can also now pass slice objects to the __getitem__ methods of the built- in sequences:

>>> range(10).__getitem__(slice(0, 5, 2))

[0, 2, 4]

Or use slice objects directly in subscripts:

>>> range(10)[slice(0, 5, 2)]

[0, 2, 4]_

</comment></comment></comment><comment><USER15> Is this more immediately obvious? I would have expected list to be defined as list(*elements) and called like this list(1, 2, 3)

I guess that this allows me to type help(list) and figure it out, but I would have done that anyway to identify an operator.

Clearly the answer is a .clone() or .copy() method...

<comment><USER16> > Clearly the answer is a .clone() or .copy() method...

if you want Python to smell like Java or Ruby. :->

<comment><USER17> <http://docs.python.org/library/copy.html>

Seems to disagree with you.

<comment><USER18> By putting it in a module, you avoid having to add the method to every single class.

<comment><USER16> Hmm, no. You have to add __copy__ and/or __deepcopy__ to every class.

<comment><USER19> Only to override the default implementation.

</comment></comment></comment></comment></comment></comment><comment><USER20> <moody> "a[:] feels a bit too much like Perl" - doesn't feel like Perl at all!</comment>


The tech world is wrong about marketing - <AUTHOR> http://techcrunch.com/2016/04/12/everything-the-tech-world-says-about-marketing-is-wrong/ <comment><USER3> On the one hand: Yes, there is too much BS in marketing. There always has been, but today the barrier to calling yourself a "marketer" is close to nothing. These self-proclaimed marketers use a veil of buzzwords (eg, "growth hacking") to deceive and cover up.

On the other hand: "The four P's" is a man-made concept, too. So is the entire framework the author shows off. So why is "inbound marketing" a sham while "the four P's" is gospel? That whole part is a rant about terminology more than anything else.

There needs to be more skepticism and calling-out-BS within marketing, but that doesn't mean rejecting every new idea because it doesn't fit a decades- old mold. Rejecting everything is just as intellectually lazy as accepting everything.

To give an example: I'm an engineer-turned-marketer and now consult tech companies. I never received a "traditional" marketing education so I'd get schooled on theory by a first-year marketing student, but I can automate marketing operations, increase conversion rates, deploy code, turn more trial users into customers, and so on. Between those things and "The Four P's," which do you think matters more to a startup?

Theory is useful but dismissing an entire industry (tech) because they don't subscribe to an old theory or choose to use new terminology is ignorant.

<comment><USER4> And inbound marketing is now used to refer to what used to be called SEO if you have seen as may mistakes as I have a competent inbound marketing person can improve your site.

I wont mention any names but I saw a mistake with canonical tags cost a major UK company 1/2 a mill in less than a week.

<comment><USER5> Out of curiosity, how would a mistake in canonical tags be so catastrophic?

<comment><USER6> Those are RIAA losses probably. I.e., pick some outrageous high number, point to a perceived flaw, and calculate the difference between actual revenue and your "target".

edit: the GP didn't specify any units though. He could have been talking about visitors or micromorts, not pounds or dollars.

<comment><USER4> Nope it was based on the cost of buying the lost organic traffic via CPC - They are a big *ie millions of pounds monthly) user of ad words budget

</comment></comment></comment></comment></comment><comment><USER7> The last few sentences of the article:

> _Whenever marketers claim that "everything has changed" or that something is > "dead" or that some new buzzword "is the future of marketing," ask for > evidence. Make them cite their sources and explain their reasoning. Most of > the time, they are just full of it._

Somehow I don't think the author fully grasped the irony of his statement given the title.

<comment><USER8> I'm feeling a little bit dense today, I just can't see the irony :( Not being flippant, but can you help point this out to me?

<comment><USER9> The title of the author's article is in the same vein of the ones being lambasted in his closing paragraph.

<comment><USER8> You do realise that article authors normally don't chose the title for their articles? That's the job of the subeditor, and they don't always listen to the author of the article.

<comment><USER7> I don't think that's actually obvious to the HN crowd, most of whom are not in publishing or journalism.

</comment></comment></comment></comment></comment><comment><USER10> This might be a bit naive, or just wrong, but I feel like there's a difference between "content marketing" and non-content marketing.

Content marketing, to me, means marketing where the 'content' of the marketing is actually valuable in itself. It could be an educational blog post, or a discussion started on Twitter, but it's something that I might reasonably choose to consume in its own right.

Non-content marketing I would see as banner ads, TV ads, etc, where I would never choose to see the content if I had a choice. I only see the adverts because they tag on to another piece of content in order to get any exposure.

<comment><USER11> I think the author of the blog post would argue that traditional ads should also endeavor to be valuable in itself. Like how people search out ads like "Office Linebacker" or other high production value ads.

Where I disagree with the author is that he makes it sound like absolutely everyone has forgotten traditional marketing 101. I personally haven't seen that, but then again I'm not in Silicon Valley...

</comment></comment><comment><USER12> Overall sentiment of this article is generally correct. Lots of minor errors throughout. One major one that caught my eye:

> to increase brand awareness and thought leadership (and those cannot be > measured).

Brand awareness and thought leadership absolutely can be measured through polling, search volume changes, etc. Be wary of any marketing that is being sold to you where the claim is the benefit can't be measured.

<comment><USER13> There are certainly things you can do to measure these things. The difficulty is that these measures aren't as neat as the ones you use for direct marketing, and are less likely to capture the whole value of the brand and thought leadership spend. This means they can be used against each other, but at a high level it's risky to use them to assign resources to the different strategies

</comment></comment><comment><USER14> Uh... Aren't the spread of buzzwords like "inbound marketing" and "content marketing" the result of _insanely brilliant_ marketing? Isn't touting that the Modern Internet makes old school marketing irrelevant a _genius_ marketing strategy to take over the market of marketing?

Sure, the new product might be worse, but these "tech world" companies have managed to take over, and I'd bet they'll keep repacking old wisdom in shiny new phrases and blog posts until they push the ivory towers of marketing into obselence. Hell, Brian Halligan, Hubspot's CEO, is even a senior lecturer at MIT...

</comment><comment><USER15> I think this hits the nail on the head for a lot of "tech" businesses at the moment:

> "You don't get rewarded for creating great technology, not anymore," says a > friend of mine who has worked in tech since the 1980s, a former investment > banker who now advises startups. "It's all about the business model. The > market pays you to have a company that scales quickly. It's all about > getting big fast. Don't be profitable, just get big."

<comment><USER16> In cases where network effect is important and the cost of being a follower is high, yeah, just get big. How soon do you think Amazon should do otherwise?

</comment></comment><comment><USER17> Marketing is about raising interest. Interest is one of the 8 basic emotions, with the other being joy, trust, fear, suprise, sadness, boredom and anger. If you can bootstrap interest into joy, you get optimism. Interest and anger bring aggression, on the other hand.

When someone say "everything some other people says about marketing is wrong", what they are really saying is "what they are saying isn't interesting to me and therefore everything they are saying is wrong", which is the well known ad hominem bias. Biases are good in this context because they bring efficiency to systems. For example, when a marketing person uses buzzwords without context to describe their business, you get the expected "bored" responses from people. Does the Intercloud interest you? What if I told you the Intercloud was a cloud of clouds and it needed a high trust federated network backed by the blockchain to operate? Does it interest you now?

To be successful at marketing X, one must ignore everything anyone is saying about X and try to understand two basic things: 1. What people (Ys) are interested in X? and 2. What makes X equally interesting to more Ys?

Keep in mind sometimes those answers fall outside what you may already know about X. This implies you must learn more about X and get to know the Ys to raise interest in them with the stuff you know they don't.

If you pour a lot of resources into #2, don't expect all the Ys to respond well. Part of what can make something interesting is others aren't interested in it as much as you are. And, if you understand that, you will begin to understand marketing.

<comment><USER18> > _Marketing is about raising interest._

That's one component, but marketing is bigger than that. In fact, this is seems to be a major point of confusion, that "marketing" is advertising.

Marketing encompasses bringing a product to market, perhaps even _creating_ that market. According to Wikipedia's definition:

"This way marketing satisfies these needs and wants through the development of exchange processes and the building of long-term relationships."

</comment></comment><comment><USER19> the raison d'être for a bus stop is not to sell cellphones, purfume or clothing. It is exists to establish and protect a pickup/dropoff point. The bus stop would exist even if the no ads were ever sold for it.

On the other hand, the rambling, first-hand, poorly-worded 4 page review the latest sous vide exists solely to sell you that device. This is "content marketing". The text and graphics are inseparable from the intent to sell.

Somewhere in the middle is the Slate webpage that links to the sous vide review. It wasn't written to sell that particular appliance, yet ad revenue is very much top of mind.

<comment><USER20> Let this comment be a manifestation of my intent to subscribe to your newsletter.

</comment></comment><comment><USER21> Good article. Also, great content marketing for that book I'm already sick of noticing at HN homepage.

<comment><USER22> I agree. It seems so forced!

</comment></comment><comment><USER23> Seems ironic that, as a marketer, it took this much verbiage to make his point. Must have gotten paid by the word. On a serious note, the tech industry in general suffers from non standard language when it comes to describing roles. Consider pm for product manager, project manager, program manager. In some cases these labels refer to overlapping roles and responsibilities, in other cases they don't. Same with marketing, where u have different labels meaning the same thing or partially expressing the same thing. Or take bd, where in some startups it means sales and in others it means, well, bd.

</comment><comment><USER24> Marketing and Technology are two ways to solve the same thing - <USER2> problems. Technology is better at it.

<comment><USER20> Marketing is the exploitation of information asymmetry. Firms are selective with their message to maximize perceived value. Truth is hidden.

</comment></comment><comment><USER25> "Creativity cannot be scaled." Actually, in the book The Song Machine, they pretty clearly show otherwise, with teams of topliners, beat makers, etc. churning out hits in a machine-like format: [http://www.amazon.com/Song- Machine-Inside-Hit-Factory/dp/039...](http://www.amazon.com/Song-Machine- Inside-Hit- Factory/dp/0393241920/ref=sr_1_1?ie=UTF8&qid=1460998698&sr=8-1&keywords=the+song+machine)

<comment><USER26> I thought that was more about maximizing your hits, given that you have found some creative geniuses at specific parts of the process, like Ester Dean, Max Martin, etc.

<comment><USER25> They are, but in the process have created a serious song and hit generating machine. You have these hit factories that churn this stuff out at scales that were previously unseen through the division of labor described, among other things.

</comment></comment></comment><comment><USER27> TYPO: Missing an "e" in "the".

<comment><USER28> We eliminated that by de-baiting the title.

</comment></comment><comment><USER29> As usual, this article makes the very critical mistake of thinking marketing = advertising.

Given that, I can expect the entire article to be bullshit.

<comment><USER28> If you are so much more knowledgeable than the author and most of us here, it would be better to post a comment that teaches us some of what you know. This one just makes a grand claim with no explanation, surrounded by name-calling. That's not a good fit for HN. We're going for thoughtful discussion here.

This is a good description which you might (re-)read: [https://news.ycombinator.com/newswelcome.html](https://news.ycombinator.com/newswelcome.html)

Many of your comments here have breached civility in similar ways. That's a problem. On HN, please post civilly and substantively, or not at all.

<comment><USER29> My sincere apologies.</comment></comment></comment>


Ask HN: When you can't fall asleep, what do you do? - <AUTHOR> If you can't sleep, do you get right back at whatever project you're into? If not, then what do you do while waiting to be tired enough to sleep? <comment><USER2> As someone who has always had issues sleeping I hope I can be of some help.

I take 6mg of melatonin. Every night. I have found it allows me to fall asleep within a half hour instead of it taking two hours.

Maintaining good sleep hygiene is often very helpful. Avoid blue light before going to bed. Physical activity and exercise are important. Try not to eat right before going to bed.

When I am really stressed out and just can't sleep, I lie in bed and daydream, (often it's some type of fantasy where I get to live in the future where mankind is living throughout the solar system, I digress). I find doing this calms me down, making it easier to fall asleep.

<comment> martin-adams I don't have trouble sleeping, but when you refer to daydreaming, this is exactly what I do. I play out stories in my mind where I'm in a fictional fantasy (not related to my life in anyway).

Another thing I experienced was when I cut out sugar and caffeine, I'd be able to fall asleep in almost any place. Again, that may only be my experiences.

<comment><USER3> ^^ when I quit coffee, falling asleep comes easy also.

</comment></comment></comment><comment><USER4> Melatonin[1][2]

I just have to be careful about taking it too late, if I really need to be up the next morning. I find that when I take melatonin, I _really_ need my full 8 hours (or more) of sleep, or I feel pretty groggy for quite a while after waking up.

[1]: [https://en.wikipedia.org/wiki/Melatonin](https://en.wikipedia.org/wiki/Melatonin)

[2]: [http://www.webmd.com/sleep-disorders/tc/melatonin- overview](http://www.webmd.com/sleep-disorders/tc/melatonin-overview)

<comment><USER5> This And don't consume any stimulants that will keep you awake in the evening. Flux, and avoid blue light. Works good.

<comment><USER4> Yeah, the avoiding stimulants is big as well, at least for me. Strangely enough, I feel like that's one thing that's changed as I've gotten older - when I was younger, I could drink coffee right before bedtime and still fall asleep. Now, I find that if I don't cut out the caffeine well in advance of bedtime then it affects my ability to fall asleep.

I'm not very good at the "avoiding blue light" part, I really need to start doing that. But I'm really bad for surfing the 'net or reading some kind document on the computer, right up until time to close my eyes. :-(

</comment></comment></comment><comment><USER6> Not really what OP asked, but I think it's far more important to try and fix the cause of why you can't go to sleep, instead of working on the symptoms.

1\. Try to go to bed at the same time every day (and sleep the same amount of time). I'm a night owl and can easily move my day on, but moving it back is very difficult.

2\. Sleeping ritual. Mine is pretty simple, I turn the lights off, climb in bed and lie on my right hand side. After a bit (1-10 minutes) I will turn over and then I'm pretty much immediately asleep. If you repeat something it will become ingrained (and will work most of the time).

3\. Fix all sources of disturbances. Partner, pets, light, noise etc.

4\. Learning to switch your brain off. Try not to watch/read something that's too emotionally charged before bed.

5\. After that everything else that has already been mentioned, eating too close to going to bed, having drunk something so you need to get up to pee etc.

For most people sleep shouldn't be a problem, they just have terrible habits and/or environment.

</comment><comment><USER7> I find that I need a cutoff point where I'm not allowed to do any more work. Otherwise I'll be thinking about work and productivity up until the point where I literally become unconscious (fall asleep).

Sometimes I read/listen to educational stuff. I try to keep it on the lighter side. Sometimes I listen/watch comedy. Right now I've been watching Seinfeld before bed. Before that was Khan Academy history.

I remember hearing advice from some credible source (that I can't remember) that it's not good to keep trying to fall asleep when you are struggling. I think 20 minutes was the point where it was recommended to get out of bed and do something else for a bit. Anecdotally, it works reasonably well for me.

</comment><comment><USER8> When I can't sleep, I do something which I call the '1 2 3 4 5'-exercise.

While still in bed, lay on your back and think of something you can 'see' (imagine it), anything as long as it's something that physically exists. For example: your car, a guitar, a chair. Imagine it and try to describe it to yourself in the best possible detail. 'My guitar is surf green, it's a Fender Carbonita, it has 22 frets, it has a maple neck, ...' Do this for five things.

Then move on to "things you can feel". Physically feel. For example, describe how your couch feels, how your blanket feels. Again, every little detail. Five times.

Then think of five things you can hear: not at that exact moment in your bed, but things you might have heard throughout the day. Something I think of often is the sound of a train arriving or leaving. Again, try to describe it to yourself in the best possible detail. Do this, again, five times.

Then start over at describing something you can 'see'. Do it four times, move on to feeling, 4 times, move on to hearing, 4 times. Then all over again, except this time 3 times. Then 2, then 1.

I have never made it past the first 5 descriptions of 'see'. I usually fall asleep after describing two objects to myself.

It might help you fall asleep.. Might not. Worth a try, perhaps?

<comment><USER9> As a kid I had a hard time getting to sleep (small home, could hear everything). I eventually learned to block everything out and sleep using the following routine: 1\. Start breathing as slow as possible. 2\. Count breathes, starting at 100 and working back. That usually did the trick.

<comment><USER3> What happens when you hit zero? Do you go to negative numbers? =)

<comment><USER9> I don't remember ever hitting 0.

</comment></comment></comment></comment><comment><USER10> Read.

As i understand, when you can't sleep your mind is active and / or is receptive. Mostly its receptive to new ideas, and hence reading aids in thinking and churning ideas.

In case your mind is active and has too much noise like worries / anxiety etc. i find it best to watch videos i saved for later on youtube or ted.

</comment><comment><USER11> Most importantly I try to take my mind off thinking about the day/problems in general. If I'm a 'little awake' I make movies/stories in my head in as much detail as I can conjurer. Usually some adventure story I play out. Kinda amuses me until I drift off.

If I'm really awake and don't want to go back to work I put on a movie onto the TV I've already watched a few times, ideally something a bit boring. Usually that makes me drift off.

There's also the more personal option I'm surprised no-one has mentioned yet. That tends to help the boys sleep at least.

</comment><comment><USER12> I can't sleep when my mind is racing with ideas or replaying the day.

First, I'll write down all my ideas, thoughts, etc. Even if just a few words, I think that action helps me brain turn off.

If I'm still awake, the big guns, I'll read a fiction book in another language. A few minutes of that and I'm exhausted. The kindle is great for that, because it's got an easy dictionary for looking up unknown words. Just make sure you're wearing orange tinted glasses or you're on a non-lit screen, otherwise the blue in the phone screen will wake you up further.

</comment><comment><USER13> Get up, eat a small amount of cooked oatmeal or other complex carbohydrate cereals (the tryptophan link), go back to bed, read a novel and you'll likely drop off after a few dozen pages.

</comment><comment><USER14> I think falling a sleep at will can be done by either getting too tired or too bored. I generally watch / read something really boring (e.g. I cannot stand biology related books or youtube video teaching biology. Sometimes I force my self to watch / read a boring books / videos and in 15min I start yawning and soon sleep.

Another thing I do is I climb stairs to my house (I stay on the 6th floor and have to climb more than 100 steps)

</comment><comment><USER15> Just relax.

Assume that this is probably going to be a bad night, you will not sleep much and tomorrow you will be tired. First of all accept that, or you will feel even more anxious. The good part is that tomorrow night you will be tired, so it will be easier to fall sleep.

Then, try to do something to distract yourself. It is really boring to spend the night laying on the bed and feeling miserable because you cannot sleep. Grab a book or watch a film, at least you will do something profitable during the night. Finally, at some point, you will fall asleep. It will be probably too late, but at this point there's nothing you can do about that.

IMPORTANT: Wake up at your time. You will feel extremely tired, and it will be really hard to wake up; but if you sleep until late, you will be altering your internal clock and next day you won't be able to sleep early neither.

If you cannot sleep for several days in a row, probably you should see a doctor. He will be able to help you.

</comment><comment><USER16> I read a book. I have trouble reading books lately because I keep falling asleep, but that makes them perfect cures for insomnia.

But more seriously, reading some fiction (not news!) is a great way to clear the mind and distract your thoughts from all the stuff that's keeping you awake.

</comment><comment><USER17> At this point I no longer understand what "can't fall asleep" feels like. Especially after having a child my concern is how to stay awake rather than not fall asleep. Not that I regret it but it has taken a toll on my personal projects.

</comment><comment><USER18> I mostly get restless when I'm excited about something (much like kids on Christmas Eve).

Its particularly bad tonight/this morning; I found Elixir a few days ago, and I keep thinking about doing things with it.

Often I'll try to go to bed, get in some weird thought-state, and "wake" back up with a fully planned project in my head I just absolutely have to get worked out.... or.... rather, usually, some really weird/dumb idea that I thought was great and probably shouldn't have wasted the night on.

</comment><comment><USER19> If I have specific thoughts or concerns swirling around in my head, I find it is sometimes helpful to jump out of bed, find a pen and paper, and write them all down. Often this lets me get to sleep more easily afterwards, as I no longer have to worry about "remembering things for the morning".

Getting a period of decent exercise (walking, jogging, etc) between work-time and sleep-time also seemed to help break up the day for me, and ensure I am both somewhat physically tired as well as mentally tired.

</comment><comment><USER20> Stop trying to fall asleep!

Lie on your bed. Relax. Instead of trying to fall asleep (and thinking about it) think about making yourself as comfortable as possible. Turn this way, move your arm that way,... Once you've done it, the sleep usually follows. In short, think comfort not sleep.

P.S.

I've used to have troubles falling asleep, but that simple method helped me to solve the problem. I would give the credit to the original author, but I can't remember where I read it.

</comment><comment><USER13> Get up, eat a small amount of cooked oatmeal or other complex carbohydrate cereal, return to bed and read a novel; after a few pages you'll likely drop off.

</comment><comment><USER21> Take an antihistamine which makes me drowsy, and then I sleep. Sleepiness is often a function or two things: (a) feeling comfortable (b) not being too busy minded about things

In my case, sometimes I just don't feel comfortable enough. However, I think even a sugar pill would help some, because in some cases it's just a matter of deciding to stop thinking about things enough to settle down.

</comment><comment><USER22> To fall asleep I do mindfulness meditation and hypnosis videos on YouTube.

Sleeping with blinds open is pretty important for the next day. If you don't have any natural light then getting sunlight as early as possible helps.

If I do take melatonin, I don't take it past 1 AM... I feel like it messes up my circadian rhythm even worse if I do.

</comment><comment><USER23> Pretty simple thing that I learned through yoga:

Breathe deeply & concentrate on making your exhale longer than your inhale.

</comment><comment><USER24> Once I reached my 30's, not being able to fall asleep wasn't a problem for me anymore. YMMV.

</comment><comment><USER25> Read a physical book (not a computer, phone, or tablet screen) — I've been reading this monstrous tome lately, and it's been a great change from Facebook and Twitter: [http://www.amazon.com/Aperture-Magazine-Anthology- Minor-1952...](http://www.amazon.com/Aperture-Magazine-Anthology- Minor-1952-1976/dp/1597111961). A Kindle is an ok fallback (for me at least)

Get some exercise — I feel way better after running even just 1 mile. I did 3 earlier tonight, and can barely keep my eyes open right now.

Don't drink — Your sleep isn't as restful: [http://time.com/3671777/drinking- sleep](http://time.com/3671777/drinking-sleep)

Don't drink coffee after _x_ PM — I always cut myself off from caffeine by 4pm, and try to do it by 2pm. Find out what's right for you.

Take some melatonin — It did me a lot of good when I used to have trouble sleeping.

Address the sources of anxiety in your life — A comparison of how well I sleep now vs. when I had a lot of anxiety in my life (stress from working at Microsoft, stress from trying to drag along my faltering startup, etc.) is stark. I don't fall asleep with much or any worry most nights.

Worst case scenario: ask a doctor to prescribe you Ambien or the like. Re- establish a decent sleeping pattern, and then figure out how to address everything else.

Edit: There's one thing I want to mention about exercising. I started running only two months ago after what essentially amounts to a lifetime of non- exercise. I wasn't overweight by any means—I was just plain skinny. Like, sort of the way you expect your average nerd to be skinny. After my first run of barely a mile (walking about half of it), I wondered if I was going to have a heart attack. I didn't, thankfully. And now, two months later, I can run a longer distance than my first run/walk with basically no trouble whatsoever. I feel great, have more energy, and sleep better.

You don't even have to start running. Just start walking. Here's a better story than I can offer you at the moment on the value of this: [http://www.loopinsight.com/2015/06/16/apple-watch-my-most- pe...](http://www.loopinsight.com/2015/06/16/apple-watch-my-most-personal- review-ever/) and [http://www.loopinsight.com/2015/06/18/follow-up-to-how-i- los...](http://www.loopinsight.com/2015/06/18/follow-up-to-how-i-lost- over-40-pounds-using-healthkit-and-apple-watch/)

You don't need an Apple Watch. You don't need a health tracker. Just move. It feels better every day, and—I promise—within a month or two you'll start craving it. It's an awesome feeling.

<comment><USER26> Great advice. Especially the part about anxiety... he said as reading hackernews at midnight to avoid sleeping.

<comment><USER25> I was waiting for a build to finish ;) I _was_ planning on getting to bed before midnight, but got wrapped up in some fun 'work'. Thought I'd come back here once to see what folks had said on this thread, and then call it a night.

Are you _this_ Tim Schumann? [http://projectskyhook.com](http://projectskyhook.com)

edit: to be clear, not that I'm previously familiar with your work; just noticed that you must be another left-coaster, and decided to Google you. And, assuming you are the aforementioned Tim Schumann, hi from a somewhat near neighbor in Seattle.

</comment></comment></comment><comment><USER27> I pop a couple benadryl usually works in about 30 mins

As far as drugs go benadryl is pretty innocuous. You could always buy that ZzzQuil stuff but it's the same thing for more money.

</comment><comment><USER28> I read Murakami's books. I fall asleep in no time.

</comment><comment><USER29> Read a _book_. It'll wind you down until you get drowsy. When you start drifting off while reading, hit the hay.

</comment><comment><USER30> I listen to podcasts or lectures. If I _want_ to stay awake to hear the whole thing, I almost certainly won't.

</comment><comment><USER31> when i can't sleep, i read HN.

this list is pretty good, considering the source:

[http://www.buzzfeed.com/nataliebrown/charts-that-will- help-y...](http://www.buzzfeed.com/nataliebrown/charts-that-will-help-you- sleep-better)

* exercise

* wake up earlier

* stop using all electronics after 9

</comment><comment><USER32> I usually look at my phone. Yes, I know that's the last thing I should be doing.

</comment><comment><USER33> meditating to sleep has helped me a lot. Personally I find that having trouble sleeping is related to not letting go of certain things that happened during the day or event from before.

</comment><comment><USER34> I pay close attention to my breath and heart beat at the same time.

</comment><comment><USER35> Try not to fall asleep! Works.

</comment><comment><USER36> I am not a doctor, and this is not medical advice. Follow it at your own risk.

Make sure you're going to bed at the same time every night (notice: that's _every_ night. Not just weeknights.), and getting up at the same time every day (ditto), and make sure the delta between those two times is long enough. Not "I feel rested after 30 minutes of sleep" long enough: start with 9 hours and maintain that until you're getting up < 30 minutes before your alarm by yourself and feeling rested. At this point, you can more or less consider your sleep debt paid off. Then, back off the duration of sleep in ~90 minute intervals (that's the average REM cycle in humans) using the same criteria (note that average time to fall asleep is about 15 minutes). Most people won't get past a 7.5 hour sleep time.

Another thing that really helped me is cutting most processed sugar and all caffeine. As somebody who had a serious coffee and energy drink addiction, this was really hard to do, but it makes a big difference. If you "can't" cut caffeine, then try cutting it after 2pm or so. The biological half life of caffeine is 3-7 hours in adults, so when in doubt, go earlier than 2pm if you can. If you're a smoker, quit that too. Generally, stop putting stimulants into your body. Given that most of those stimulants also come with all kinds of sugars and other less-than-desirable additives, you'll be more healthy for it in the long run.

Along that same line, alcohol, despite being a depressant, is a good thing to avoid, especially in excess around bedtime. It might help you sleep, but long term dependence on alcohol puts you firmly in the "alcoholic" category, and even worse, it can cause or exacerbate insomnia.

When you're doing all of ^, you shouldn't need anything else unless there's some kind of disorder in play. I had [https://en.wikipedia.org/wiki/Delayed_sleep_phase_disorder](https://en.wikipedia.org/wiki/Delayed_sleep_phase_disorder), which the article likens to "Social Jet Lag". It's correctable over time, though, in part by following the rules I put up there ^, and in part by following these next ones (these apply to other sleep phase disorders, including mild insomnia):

0) This is optional, but keeping a log of anything related to your body will provide you with useful data down the road should you need it. Treat this like a personal log file: timestamped entries for when/what you ate, what meds you took, when you laid down in bed, when your alarm goes off, when you get out of bed (those times are usually different for me :P ), your rating of your sleep on some consistent scale, and how long you exercise. The more data, the better.

1) Start with 6mg of melatonin 15 minutes before laying down in bed. Keep doing that for a week. If you are still having problems falling asleep:

2) 6mg of melatonin and 25mg diphenhydramine (Unisom). Note that this is an antihistamine, and that in some cases, they can react poorly with SSRIs (depression medication). I know somebody that ended up sleeping for about 48 hours straight as a result. They're otherwise pretty safe. After a week, if you're _still_ having problems, and you're being honest with yourself about following the rules at the top of this post:

3) 6mg melatonin, 50mg diphenhydramine. This is about the most potent OTC sleep cocktail available. After a week and really, _really_ making sure you're following the rules at the top - see how I keep coming back to that? They're important - if it's still not working:

4) Go to a doctor armed with the log from step 0 and get a prescription for Trazodone, which can (I'm told by my doctor) be safely layered on top of the Melatonin and Diphenhydramine. If you stay awake through this, there are other options too. Zolpidem didn't do anything for me, but I'm told it works wonders on other people.

In any case, start with the minimum effective dose of these things because they can really mess you up.

</comment><comment><USER37> A bit of weed helps me a lot.</comment>