A pure JavaScript implementation of Git for Node and browsers - <AUTHOR> https://github.com/isomorphic-git/isomorphic-git <comment><USER2> I think it's interesting how there's two phenomena that seem to be related to me that get posted here and seem to get treated with different responses.

One the one hand, we have software originally written in C/C++ being rewritten in Rust (not often, sometimes just conceptualized), and there's often a real push back by _some_ people about how it's a waste and not useful.

On the other, we have software rewritten in Javascript, which people are generally very accepting of, even if they don't plan to use it.

I understand the goals of these are often different, and the benefits are also often different, and they have a different set of use cases, but the reception seems markedly different (at least in tone).

I'm not necessarily trying to imply that means anything, it's just something that struck me while noting we now have Git implemented in JS.

<comment><USER3> IMO, this is because there's a general attitude about porting to Rust that porting to Rust, by itself, makes a material improvement in the quality of the software (e.g. reliability, performance, readability), and that these improvements that can't be achieved in C/C++. Entrenched C developers then rise to the debate to defend their language.

This debate has happened often enough that any time someone ports something to Rust, even if it's just for fun or for the author to learn more Rust, C/C++ advocates see it as an attack on their language, and bite back.

<comment><USER4> Javascript runs everywhere where there is a browser.

Rust runs everywhere where there is a c compiler, which is funnily enough the sample places that C/C++ run.

<comment><USER5> And with wasm, Rust/C/C++ all can run in the browser too...

<comment><USER6> When people say "The Browser" they mean "that thing which is on literally every computer where you instantly load that one kind of software".

People think the web is a technology, or that JavaScript is a language.

They're not. It's not. The web is an idea: it's the idea that every computer in the world already has the runtime on it that can run your next app. Whatever that is—whatever that runtime is—that's "The Browser".

WASM is not that. Maybe in 10 years.

<comment><USER7> What are you babbling about? The web _is_ technology. JavaScript _is_ a language. And WASM is shipping in all major browsers already.

You don't have to wait 10 years. You can start using WASM today.

<comment><USER6> It hurts my feelings that you think I'm babbling. I'm trying to be as articulate as I can.

I don't want to write software just for people with 2 year old iPhones. I write software for everyone, especially people who can't afford anything but the hardware they're stuck with. That's why I'm not going to target WASM.

That's my point: to me, "The Web" isn't just modern browsers on newish devices. It's the whole world as an audience. I think that's why so many people target the web.

I also think WASM is premature optimization in almost all situations.

That said, I totally support anyone who wants to target it. It's dope technology. If you love Rust and you want to write browser apps with it, and limit your audience a little, knock yourself out. I don't think you're embracing what the web is for, but there's no law that says you have to.

</comment></comment></comment></comment></comment></comment></comment><comment><USER8> This project started when I, wmhilton and another guy started talking on an issue on the js-git repository. Because development on js-git stopped. We all started independent projects to port Git to JS. The third guy did one in type script, wmhilton started this. I began by trying emscripten first with libgit2. While it compiled and simple things worked, I needed to overload its filesystem functionality but it was embedded and complex to do. At any case my git project stalled as I was stuck solving another related problem (indexing highly dynamic tree data). In the mean time wmhilton continued and produced a wonderful project. I talked him earlier on about the fs functionality, since earlier I developed the js-virtualfs to support a git in js. And later he changed the codebase to support fs plugins. So if you want to use this isomorphic-git in the browser or electron, I recommend my js-virtualfs library as its the most comprehensive port of nodes fs api to an in-memory fs. Thanks to wmhilton I can probably stop my git project and just build on top of his.

</comment><comment><USER9> "Any application that can be written in JavaScript, will eventually be written in JavaScript." \-- Atwood's Law

<comment><USER10> we should just implement js in js and go full circle already.

<comment><USER11> Just wait for the Electron browser...

<comment><USER12> Mozilla has used their rendering engine to render their UI for YEARS. Not sure if they're still using XUL with their latest few updates though.

<comment><USER13> XUL is still alive but XBL is at least going away now. XUL will probably eventually go away too.

</comment></comment></comment></comment></comment><comment><USER14> I did something similar a few years ago. [https://github.com/ryanackley/git- html5.js](https://github.com/ryanackley/git-html5.js). A lot of the links don't work in the README anymore. It was more of a "this would be cool!" project rather than a library I wanted everyone to use for the next 20 years.

One of things that scared me is the responsibility that bugs in something like this could be catastrophic to someone's work. As I built my git library I realized a lot of the network protocol validation exists in the git client. For example, one bug I introduced caused a force push of a shallow copy of the tip of master intermittently. The server would happily accept it without any kind of "are you sure?" or -f flag. That spooked me.

<comment><USER15> I can't begin to describe how sad I am that we didn't end up using mercurial everywhere.

<comment><USER16> It's really strange to me that nowadays source control seems to be, largely, a monoculture. Back in the day I either used, or knew plenty of people using any of CVS, Subversion, Sourcesafe, Sourcegear Vault, Perforce, AccuRev, ClearCase, along with a few others.

Whilst distributed version control is a huge leap forward over many of those older systems, it's odd that nowadays it seems to be git or, well, nothing. I'm surprised Mercurial hasn't made more headway than it has.

But maybe git is just "good enough" for most people? I suppose that's where I land on it. It has it's frustrations, like anything else, but I can live with them.

<comment><USER17> A large part, I believe, is the ease of moving a git repository around. Back in the day, the central repository was a choice that stuck you to it for a long time. You literally had to setup the server, in many cases. Git, though? You just install the client and you can get started on a repository in your current directory that can easily transition to a remote hosted one.

So, in a way, it is not unlike pathogen spread. Low barrier to get started combined with basically frictionless ability to spread out. Even the hiccups people used to have only slowed individual level adoption. (Complaints about the UI and such.) The spread of currently successful repositories was not really slowed by those events.

I'd be highly interested in if anyone has something like this modeled.

I'd also appreciate challenges to my point. Mercurial, I believe, should have had similar strength in spreading. It just didn't have the bootstrapped successful project like git. (The kernel, is what I'm thinking of.)

<comment><USER18> Mercurial had major projects too. Mozilla still uses it. What it didn't have was GitHub.

<comment><USER17> Good counterpoint! Oddly, in my mind, Mozilla is not nearly as new dev friendly as the kernel is. I suspect that is just a bias in my thinking, though.

I feel that git was winning a lot of mindshare even before github. I know I certainly was using it before github. Big plus for me was the git-svn bridge that existed. Especially since I was working remotely at the time, it was much faster for me to do checkouts with a git-svn clone than to deal with raw svn checkouts. It wasn't even close. Did git beat Mercurial to that?

<comment><USER18> Git was popular in some influential circles before GitHub, but it only became a monoculture several years later. hgsubversion came out in 2008, after git- svn but before most people were using any DVCS. Also, SVK was around before git-svn.

You might be underestimating how much support Mercurial had in the late 2000s. Mozilla, Sun, Google, and Microsoft all picked Mercurial over Git. Even GitHub published hg-git so people could use the Mercurial client with Git repos. Some ecosystems gravitated to Git (Linux, Perl, Ruby) and some gravitated to Mercurial (Windows, Java, Python).

By 2010, DVCS comparisons consistently cited GitHub's UX and network effects as significant advantages for Git. Atlassian, Google, and Microsoft all added Git hosting in 2012. By 2015, Python, Google, and Microsoft moved to GitHub because everyone else was on GitHub.

I think the landscape would look very different if GitHub hadn't come along when it did or had added Mercurial support instead of Subversion.

</comment></comment></comment></comment></comment></comment></comment><comment><USER19> There's a pretty full functioning project from several years ago (seems actively maintained) that has similar goals here:

[https://github.com/creationix/js-git](https://github.com/creationix/js-git)

I think it was initially crowdfunded.

<comment><USER20> Used it, works great. Also really good to understand what git really "is".

</comment></comment><comment><USER21> What I really find interesting is the move to an untyped language for large project while all people talk about the virtues of type systems, Scala Haskell SML and so on.

It seems Lisp was not mambo jumbo after all.

</comment><comment><USER22> First thing I looked at was "did they implement git diff?" The answer is "no." That's something you're going to want to see in a port. I use it daily.

</comment><comment><USER23> JavaScript: Because that's what we know.

<comment><USER24> Possibly; but as someone who maintains a NodeJS native addon in C++, I frequently _dread_ new releases of NodeJS that invariably break my bindings. A shim library called "NaN" has done so much to help with this; I would have given up sooner.

Having libraries implemented purely in the language from which the library is implemented solves many many headaches, irregardless of JavaScript or not.

<comment><USER24> > Having libraries implemented purely in the language from which the library > is implemented

Err, meant to say:

Having libraries implemented purely in the language from which they are used ...

</comment></comment></comment><comment><USER25> Looking at this rewrite I was wondering, but didn't find an answer in the project README: would emscripten successfully compile Git to js/wasm?

<comment><USER26> Git has its claws deep in the file system. On the browser side, JS and wasm have very limited access to the file system. You'd need to somehow bridge that gap. (It looks like isomorphic-git is using indexdb, and not the file system).

There's probably other dependencies (ssh, http, an editor for commits) that need to be resolved to get expected functionality.

<comment><USER27> You're right; when it is running in the browser, isomorphic-git does not have access to the operating system's file system. Instead, it uses BrowserFS [1], which emulates a file system abstraction on top of arbitrary storage backends. It supports IndexedDB, localStorage, and Dropbox, among others. (Disclaimer: I am the author of BrowserFS.)

[1] [https://github.com/jvilk/BrowserFS](https://github.com/jvilk/BrowserFS)

</comment></comment></comment><comment><USER28> I spun up a quick dashboard of this project at Chart.ly [1].

A couple interesting points. Will Hilton is the main guy driving the bus on this project. And... Sunday and Monday are his most productive days.

Keep up the good work!

[1] [https://chart.ly/github-dashboard/isomorphic- git/isomorphic-...](https://chart.ly/github-dashboard/isomorphic- git/isomorphic-git)

</comment><comment><USER29> I've been using this library for a few months and want to give props to wmhilton who's been incredibly responsive with the couple of issues I've encountered.

The thing I like the most is that the API matches very closely to git's CLI, so if you know git, you know isomorphic-git.

I gave other libraries a try before settling on this one (spent a whole daying playing around with the optios). IIRC I decided to use isomorphic-git because the alternatives were either abandoned or simply broken.

</comment><comment><USER30> A few years back, the company I'm currently at started working on NodeGit because a pure JavaScript implementation they tried (not this one? Idk I wasn't there) was far too slow. Right now, we're working on a git server in rust that takes commands and passes data over TCP that ideally could enable git usage in the browser for like hosted development environments and such.

</comment><comment><USER31> This is pretty cool! I'm curious if emscripten/webassembly on the canonical git implementation was considered though? (Or is the environment just too different?)

</comment><comment><USER32> Code in the project looks really well done. It just needs semicolons ;) I don't get the whole no semicolon movement, especially when you probably have to work with C/C++/C#/Java at some point and it means retraining your brain. Also semicolons help visually distinguish commands from control. 2 spaces I can definitely get behind!

<comment><USER33> You're dramatizing the mental overhead needed to not write semicolons. Every serious project uses a linter that can add or remove them based on some flag.

I don't use semicolons. It's an unnecessary character. Life moves on.

I'd say Rust has worst of both worlds, if you want to compare it to something, where having or not having a semicolon can mean two different things (return the value or return void). That's an example of actual mental overhead that semicolons can create that still bites me after more than a year of Rust. And it's not something that tooling can necessarily fix for you unlike Javascript ASI.

Using semicolons in Javascript just to keep my brain trained for semicolons in other languages is probably the worst reason to use them I've heard yet. And every time someone finds out I don't use semicolons in IRC, they seem angry about it. So I wonder how much I avoid semicolons just for the sport of it, now.

<comment><USER32> Yeah, you're probably right on the mental overhead. I guess it is just best to use a linter and whatever style guide you prefer (most argue for semicolons.)

Using semicolons to stay in rhythm with similar languages that mandate them might be the worst reason, but it is a reason none the less (I literally spend equal amounts of time coding in C++/C#/Java/Javascript, so there is no need to 'think' in my case.)

I too like to do things out of spite.

</comment></comment></comment><comment><USER34> With something like this, GitHub will soon become my web app's database (pending that PR). So awesome...

</comment><comment><USER35> I wonder how it works in practice. I've worked with git.js (old and ugly, but works) and js-git (looks nice but is quite complex).

git.js even has a repository browsing demo (think gitk) that works in a browser.

Did anyone use isomorphic git? Does it support smart http protocol?

</comment><comment><USER36> One possible usage is peer net broker for WebRTC. But really I'd like to setup my own private AWS C9. Secure access to a dedicated instance. From any computer / browser. With offline caching. And a rich browser terminal ;)

</comment><comment><USER37> If anything this is a wonderful example of good engineering. Although on the server-side would it not have been easier to delegate commands to the native git binary?

Well done!

<comment><USER38> Perhaps but there's an existing SDK that is the backbone of many Git libraries: [https://libgit2.github.com/](https://libgit2.github.com/)

Of which there is an existing Node package that links to it: [https://github.com/nodegit/nodegit](https://github.com/nodegit/nodegit)

The caveat is that it stopped being a pure-JS library that boasts in-browser support.

</comment></comment><comment><USER39> Soon, there will be a rewrite of the Linux kernel in Javascript.

Finally, a way to run Linux in your browser!

<comment><USER40> [https://bellard.org/jslinux/vm.html?url=https://bellard.org/...](https://bellard.org/jslinux/vm.html?url=https://bellard.org/jslinux/buildroot-x86.cfg)

<comment><USER41> That's a fun place to type "rm -rf /" ;-)

</comment></comment></comment><comment><USER42> With the craziness of Js build tools and build configurations, I love seeing how different project stuff use it. I like how they use both webpack and rollup and even name the rollup export as "for-future".

I write a lot of isomorphic libraries for work and it's not as easy as one might think it is.

<comment><USER43> Definitely. This GIT example reminds me of what some people are doing with the Web Crypto API (see PKIjs). Things I would never have considered a little as a few years ago.

</comment></comment><comment><USER44> Why oh why?

<comment><USER45> "Everything that can be written in JavaScript will eventually be written in JavaScript"

</comment></comment><comment><USER46> Very clever! I particularly like the bring-your-own-filesystem approach.

</comment><comment><USER47> stop writing stuff in javascript (says someone who writes stuff in js)

</comment><comment><USER48> .. but why?

</comment><comment><USER49> Linus Torvalds would hate this

<comment><USER50> Why? It's a clever hack.

They did it because they can.

<comment><USER49> well, this joke didn't go over well ha.

The man went on rants about C++ I can only imagine what he has to say about JS</comment></comment></comment>


Ask HN: What is the most useful script for your business or startup? - <AUTHOR> <comment><USER3> Thank you telling us about what happened. I am sorry to hear that [paraphrase complaint]. We want all our customers to have a great experience and we let you down.

I have [refunded / free upgrade / given some other bonus] your account. We will also make it a priority to [describe how we will improve] to make sure this doesn't happen to anyone else.

Please let me know if there is anything else we can do to make this right or if you have something else to tell us. You can contact me by email firstname.lastname@example.com or phone $phone_number. Those are direct to me personally, not to our helpdesk.

Best regards

$me

<comment><AUTHOR> I have 3 seconds thinking this is a spam lol

<comment><USER4> It's a response to a problem the customer has raised. In that context it won't look like spam.

I'm not keen on the conciliatory tone and going straight to a 'bribe' of a refund/offer/etc, but in some markets that could work. If I had it as a response I'd feel like I was getting a brush-off rather than someone was trying to engage with me and fix my problem. If someone is willing to go to the effort of making a complaint without asking for a refund then they're expressing an interest in continuing the relationship; a refund is often seen as "we don't want your custom so we're paying you to go away." Like I said though, it's very dependent on the market.

<comment><USER5> I think they meant the post looked like automated HN spam, until it 'clicked' that it was just a dump of an email template :)

</comment></comment></comment></comment><comment><USER6> My fellow employees and I are supposed to send a "time sheet" detailing how many hours we work, how much time we spent working on "x" and "y", etc., via e-mail every week (by noon on Monday for the previous week).

I have a cron job that fires off a Perl script at 8:45 a.m. every Monday morning that composes that e-mail and sends it off for me.

On the rare occasion that I was on vacation the previous week (and forgot to disable it), I just text our payroll lady and tell her to "ignore that e-mail, I was on vacation last week".

She knows it's automated and she doesn't care. She's required to receive an e-mail from me before she pays me and that satisfies her requirements. The boss knows too, he just shook his head and laughed when I told him about it.

It sorta reminds me of how, when a "measure productivity by number of tickets closed" policy gets enacted, everyone just starts creating tickets for every menial thing they do.

My second favorite is the one that runs once an hour, deleting any IP addressing / DHCP lease / similar data older than 24 hours (I work for an ISP).

Sorry, IP-Echelon, the company policy (which I wrote and enacted) says we don't keep that (IP <-> User) data for more than a day, so I can't "ensure the user and/or IP address owner refrains from future use and sharing" because I don't know and can't tell who it was.

<comment><USER7> > It sorta reminds me of how, when a "measure productivity by number of > tickets closed" policy gets enacted, everyone just starts creating tickets > for every menial thing they do.

I had a client who did this and so I started logging everything, pasting the commits etc. with the start and end timestamp of each group of actions (e.g. "created X table, met these issues, solved them like this").

Then I looked at the log and realised I was putting in way too many hours compared to the contract because I wanted to get the job done well, and cut back to the hours they were paying for.

</comment></comment><comment><USER8> The one that scans inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - <USER2> script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".

More serious, I have a script that uses gitlab and gitlabci that integrates it with FDroid repo and builds and publishes .apk on internal FDroid repo. Each git branch, tag and release has its own publication in the repo where everyone can test the app, also easy to find regressions by using the app before we use git bisect.

<comment><USER9> For those curious about what he is referencing: [https://github.com/NARKOZ/hacker-scripts](https://github.com/NARKOZ/hacker- scripts)

</comment></comment><comment><AUTHOR> I resize image assets for iOS to @1x @2x @3x with [https://gist.github.com/david90/52a38b6279b7beabd7e8](https://gist.github.com/david90/52a38b6279b7beabd7e8)

<comment><USER10> Would ask my colleague to comment but he's on his honeymoon. He's recently gone from creating App Store screenshots manually to using a script. For each release, creates five or so screens, each for multiple device sizes multiplied by 20+ languages. Can only imagine how much time it saves.

<comment><USER11> I think your colleague is using Snapshot[0], which is a part of Fastlane[1]

[0]: [https://github.com/fastlane/fastlane/tree/master/snapshot#re...](https://github.com/fastlane/fastlane/tree/master/snapshot#readme) [1]: [https://fastlane.tools/](https://fastlane.tools/)

</comment></comment></comment><comment><USER9> These are not mine, but I still enjoyed reading about them and thinking about the ideas behind them.

[https://github.com/NARKOZ/hacker-scripts](https://github.com/NARKOZ/hacker- scripts)

</comment><comment><USER12> Nothing at my current position, but on a previous team we had a rigorous code review policy without a tool (FishEye/Crucible, etc) to facilitate it. I wrote a bash script that accepted a ticket number as a parameter. It scanned SVN for all commits associated with that ticket.

For each file, it would diff the original version with the last version committed against the ticket, and pop the diffs up sequentially in Vim (IE, one end-to-end diff for each source file).

I'm sure there's a better way, but this worked well enough at the time.

</comment><comment><USER13> Its not one specific script. But integrating Slack everywhere to get notifications is almost always worth it.

<comment><USER14> I never got the Slack hype...

<comment><USER15> Problem is, 99% of it is crap.

Slack is okay and there are some really good bots for it.

But everyone jumps on that train and so for every good integration there are 20 bad ones, that spam your channel with stuff no one needs to know :\

Takes a bit time to find the good things.

<comment><USER13> Most of my integrations (except github) are manually crafted. I agree that most bots are just spamming shitholes. Especially the new generation of bots that randomly reminds you to vote for them on some stupid bot stores.

</comment></comment></comment></comment><comment><USER16> I made a small script that uses pattern matching to automatically parse and organise documents I get from various source (bank, clients, google, etc). It renames the docs and copy them in the right location.

<comment><USER17> Genuinely interested in this Do you mind sharing some details ? What kind of documents, does the script fetch them automagically, etc ?

</comment></comment><comment><USER18> We had something like 40 NodeJS projects that were deployed with git or as tarballs. I wrote this bash script, and now they're all Debian packages.

[https://github.com/heartsucker/node-deb](https://github.com/heartsucker/node- deb)

</comment><comment><USER19> I recently wrote a python script that uses selenium/xpath to check the price of items I'm interested in and emails me when they change... has already saved me some money (or cost me, depending on your viewpoint).

<comment><USER20> Link to script?

<comment><USER8> camelcamelcamel.com

</comment></comment></comment><comment><USER21> The shell script that makes a ZIP file containing our code challenge in a candidate's language of choice, uploads it to S3 for record keeping, and reveals the ZIP in Finder, ready for drag/drop into an email.

</comment><comment><USER22> The button that when I press it deploys the new version of my thing. It's nice, I like pressing it.

<comment><USER23> You mean "git push"?

<comment><USER22> nonono it's a button

</comment></comment></comment><comment><USER24> Part of deliverables is for clients to have a list of IP's and base configurations for the hadoop clusters we deploy for them. I have a WIP Ruby gem that takes my ansible hosts and variables file along with the Ambari blueprint, which turns it into a CSV and a neatly formatted Markdown file (the latter I convert into PDF).

The next few steps is to upload these things to Google Drive for the clients.

</comment><comment><USER25> Dayjob - server with intermittent memory issues and no budget to replace. Hosts our primary code base, and corrupts the occasional packfile. I'm in the process of writing a git-surgery script that automatically diagnoses fsck issues and traverses remotes to copy back corrupted/missing objects.

side project - some stuff to import customer data dumps into the db quickly. Not quite self-service yet, but getting there.

</comment><comment><USER26> Our engineers used to spend hours each week manually preparing stat reports in excel to send to our enterprise clients. I wrote a library that is essentially an excel templater that queries the database for the metrics, populates a spreadsheet and emails it to the client. We've been integrating it into every project for 5 years now.

</comment><comment><USER27> Our script to automate deployment: running test, migrate db, collecting files, push to production servers ... Peace!

</comment><comment><USER28> I wrote a bot that tells me when to buy and sell stocks. So far I've made about 10k profit this year.

<comment><USER29> Where do you get the data?

<comment><USER30> indeed tell us more...

</comment></comment></comment><comment><USER31> If I had to chose one, that will be my backup script, without any hesitation. Data is by far the most important thing, nowadays.

After that, I would say the script that updates dependencies in all our projects and make merge requests on gitlab if anything has been updated.

<comment><USER23> Didn't mention a testing/restore script? Found the guy with no backups!

</comment></comment><comment><USER32> rsnapshot

</comment><comment><USER33> Git

<comment><USER34> Git doesn't fit the definition of a script, it's a compiled program.</comment></comment>


Ask HN: Review My App - <AUTHOR>

I wrote http://ajaxtrans.com as an interface concept when I was 15 years old. It's very simple, only took about a day to get up and totally. All it is is a quicker interface to existing Machine Translation websites (i've managed to dodge TOS complaints with google translate--now using their published Ajax Language API--for the last 4 years).
Regardless of the small time commitment it took to create, the application (widget is probably a more appropriate term) now receives 60,000-70,000 unique visitors per moth. I've tried monetizing through Adsense, but my Click-through rate is abysmal (eCPM is ~ $0.40).
I really shouldn't complain. The app requires zero maintenance , has minimal costs, and it more than pays for itself, but I keep feeling like i'm sitting on a ton of untapped potential. <comment><USER2> I don't have much experience with advertisements, but maybe you could try changing the ad based on what they're translating to.

For example, if a user chooses to translation from Spanish to English, you could display an English ad about learning Spanish, or a Spanish ad about learning English.

<comment><AUTHOR> I toyed with this idea back when i first started the site, <http://ajax.parish.ath.cx/ads/> then again more recently with a travel abroad program, I got 0 conversions after two months so i pulled the ads.

</comment></comment><comment><USER3> AjaxTrans seems a bit clunky as a name, even though this is essentially what it does.

I have some spare time tonight and am keen on some design/UI practice, if you're interested?

</comment><comment><USER4> Amazon referrals. Build out a little more to have links to textbooks, guide books, dictionaries, etc. for the language(s) at Amazon.

</comment><comment><USER5> How about contacting someone like Berlitz or other language schools. Maybe they will sponsor the site.</comment>


Towards the Perfect Browser  - <AUTHOR> http://googlesystem.blogspot.in/2012/02/towards-perfect-browser.html

<comment><USER2> Well, I don't think their concept of perfection is in line with mine. Theirs is more like "perfect despite the fact that it still leaves a lot to be desired". See <http://c2.com/cgi/wiki?ObjectBrowser> to get an idea of what the perfect browser could be.</comment>


Someone Used Neural Networks to Upscale an 1895 Film - <AUTHOR> https://digg.com/2020/arrival-train-la-ciotat-upscaled <comment><USER2> I'm sad that this hasn't received much more attention from the HN community - it is shocking in a wonderful way.</comment>


Python or Ruby ? - <AUTHOR> http://blog.cbcg.net/articles/2007/04/22/python-up-ruby-down-if-that-runtime-dont-work-then-its-bound-to-drizzown <comment><USER2> I agree with him that Python is more useful right now as a general programming environment... mainly because it's been around longer, it's a more mature and stable platform, has better libraries in general, better performance, etc.

<comment><USER3> Python is only four years older than Ruby. The rest ... YMMV.

<comment><USER4> Yes, but Python gained a lot more mindshare in its early years than Ruby. Ruby is only now really gaining popularity, and therefore support.

<comment><USER5> Part of the reason that Ruby didn't gain that much traction early on was due to the the lack of English documentation.

</comment></comment></comment></comment><comment><USER6> That's pretty interesting. I'm pretty enamored with rails but just last week I wrote a ruby script for a client to pull some stats out of apache logs and it took forever to run so I'm sympathetic to a lot of his arguments.

His mild attempt at the end to give rails its due suggests it's less black and white than he paints it. There's good reason to have both languages in your toolbox.

<comment><USER7> You're quite right. I love Ruby but I hate it at the same time cuz it's so damn slow! Rails included! On the on the other hand I've heard great things about JRuby. And I got all hot and bothered when I recently found out that they've already integrated JRuby with Rails!<http://docs.codehaus.org/display/JRUBY/2007/03/05/JRuby+0.9.8+Released> I hope this gives Rails a much needed performance boost.

</comment></comment><comment><USER7> I guess it boils down to personal preference and what you want to do with the language. I chose Ruby cuz of Rails....and because Ruby's syntax generally fits my mind set.

</comment><comment><USER7> Funny thing his blog is written in Ruby hehehe but seriously it's good to see that someone is hitting a wall. Never knew it was the runtimes fault that led to issues.

</comment><comment><USER8> Honestly? It don't matter.

There aren't really any apps that would _only_ be possible with one or the other. If you don't know either: just pick one. (for what it's worth I like Ruby)

<comment><USER9> That's true of any set of Turing-complete languages.

</comment></comment><comment><USER10> Rails</comment>


Delta Airlines Breaks with Net Neutrality - <AUTHOR> https://techcrunch.com/2017/09/27/delta-to-offer-free-in-flight-use-of-whatsup-facebook-messenger-and-imessage/ <comment><USER2> Thats a real clickbate title.</comment>


Comcast's New Internet Service Crushes Google Fiber - <AUTHOR> http://www.fool.com/investing/general/2015/04/12/comcasts-new-internet-service-crushes-google-fiber.aspx <comment><USER2> _> Comcast will begin rolling out the service next month in Atlanta, and plans to bring it to its other markets over time._

So it doesn't crush anything - it's not even out yet. And Comcast has to stop using data caps, before boasting with 2 gigabit plans. They are filthy hypocrites if they claim that 2 gigabits are possible, why capping their own users for monthly traffic.

On the bright side, without Google Fiber you'd never see Comcast even talking about anything like 2 gigabit plans. So thanks Google Fiber for giving them a kick.

<comment><USER3> Agreed. Also "twice" isn't really impressive in most technology. If it was an order of magnitude then "crush" might be more appropriate to use here.

<comment><USER2> For Comcast which has the worst ISP reputation it can be impressive. As long as they'll actually roll it out everywhere for prices below $100.

<comment><USER4> Which they won't. It's $400.

<comment><USER5> It seems unlikely that Comcast's 2GB/s service in Atlanta will be anywhere near $400.

> _Comcast hasn't discussed pricing for its new service. The company's XFINITY > Extreme 505 service costs $399.95 per month and offers speeds of about half > a gigabit. However, competition from Google Fiber, which is planned to > expand into Atlanta, may drive down prices in some areas. We've already seen > this from AT &T, which offers gigabit fiber connections for $70 a month in > Austin, Texas, where it competes with Google Fiber, but $110 in Cupertino, > where it doesn't._[1]

1\. [http://www.wired.com/2015/04/comcast-says-itll-bring- ultra-f...](http://www.wired.com/2015/04/comcast-says-itll-bring-ultra-fast- internet-us-2016/)

</comment></comment></comment></comment></comment><comment><USER6> So you can do what, download a movie in 5 seconds rather than 10? Nothing on pricing, nothing on bandwidth caps, and I'd expect it comes with Comcast's traditional customer "service". No thanks.

</comment><comment><USER7> Click bait with misleading headline. A better headline would be "Comcast plans to roll out personal broadband service at a higher fraction of current business plans."

> _" Comcast's new Internet service absolutely crushes Google's offering, with > speeds twice as fast."_ It won't be symmetric like Fiber, so it's going to > be (at best) 2x download and probably 1/x upload. This speed also only > appears to be coming to Atlanta in the near future.

> _" For those who don't live in Atlanta, Comcast plans to offer 1Gbps plans > to almost all of its Internet subscribers in 2016."_ This is bigger news, > though it's still quite far away and not only will this not "crush" Fiber, > where available, but will be strictly worse since it isn't symmetric, > features Comcast customer service, and will surely cost many times what > Fiber does.

</comment><comment><USER8> Google won..this was google's plan all along.... pose as a threat to the major teleco's, and force them to either get w/ the program and improve broadband speeds or don't and let them take of the broadband business. Though I still think comcast is evil, it will definitely move us towards an America where every home can receive Fiber if they desire.

</comment><comment><USER9> ...why do I get the feeling that they're only selling 'up to' 2 gigabit?

In all seriousness, this is a good thing.

</comment><comment><USER10> Two key points:

1) no comment on cost (personally I don't need 2x as fast if it is 10x the price) 2) it it isn't actually available anywhere yet

In other words, hold onto your butts.

<comment><USER4> It's $400. Google Fiber is $70.

</comment></comment><comment><USER11> Lovely bet on 2 vs 1 gbps: the usual consumer won't have 10GbE to take advantage of the extra speed.

</comment><comment><USER12> Looking forward to hitting my bandwidth cap in under 5 minutes.</comment>


Guitar Chord Voicings with Prolog - <AUTHOR> http://www.petecorey.com/blog/2020/04/21/guitar-chord-voicings-with-prolog/ <comment><USER2> Interesting that this intersects with something I've been experimenting with lately. A friend of mine came up with a way of doing 41-tone equal temperament on a modified guitar [1]. One of the tricks is that since 41-TET would require the frets to be so tightly packed that the guitar would be difficult to play, you simply omit every other fret and tune the guitar so that each string has the notes its neighbors on either side lack.

It's a little strange not having all the notes on all the strings, but it actually works out surprisingly well. Chord intonation is a bit nicer than 12-TET, and you get pretty good approximations of the 7-limit just intonation intervals as well.

[1] [https://en.xen.wiki/w/The_Kite_Guitar](https://en.xen.wiki/w/The_Kite_Guitar) (The 7-string Ibanez is mine.)

<comment><USER3> There's a similar trick with a normally fretted guitar: tune the strings in alternating major and minor thirds (something like ACEGBD) and lower every other string by 15 cents. Then any three adjacent strings will be a just intonation major or minor triad, you can mini-barre them on any fret to get more triads, and there are just intonation scales in every key.

<comment><USER2> I haven't heard of that one, but I have heard of simpler tricks like re-tuning one string so the third of certain barre chords comes out right. There's always a bit of a trade-off; some intervals get better and others get worse so in effect you're optimizing the instrument for a particular playing style or key or song.

If you're willing to modify the guitar to put frets in different places, it allows for a lot of options you wouldn't have otherwise. (This is especially true if you're willing to use partial frets.)

Kite tuning is the best scheme I've encountered for having closer-to-just intervals than 12-TET and yet you can play in any key. If you want perfect intervals, plain just intonation is better but then you're locked into a particular key and scale.

The design space of guitar fingerboards is surprisingly huge and open-ended when you stray even a little from the twelfth root of two as the fundamental unit of musical interval width.

</comment></comment></comment><comment><USER4> Once, when I was taking a music theory class, I tried to use the Z3 constraint solver to automatically harmonize melodies… it worked surprisingly well! [https://github.com/kach/recreational- rosette/tree/master/mus...](https://github.com/kach/recreational- rosette/tree/master/music)

</comment><comment><USER5> Always interesting to see logic programming applied to music, it is in my experience a good fit for the musical problem space. I spent some time exploring the analysis of chords using answer set programming. On the surface ASP programs look very similar to Prolog but the semantics differ; you query Prolog to answer a question or series of questions related to your program, whereas ASP produces complete "stable models" of your program (it answers "all questions").

The first version of my analysis program would most likely have been a valid Prolog program, and furthermore the program was completely positive (contained no negation). After several weeks of rewrites, I ended up with a much smaller program that also took advantage of ASP "choice" and "optimization" rules. Much of the complexity was reduced by one fundamental improvement in the representation of internal facts and adjusting the rules to accommodate. In hindsight, the original version used a rather foolish approach, but like many things it took some effort to realize why and how to do better.

This process of rewriting and incremental improvement (and initially struggling in a less-familiar programming paradigm) gave me a great appreciation for logic systems, and also a desire to use them more often. There is something very beautiful in reducing a problem into logical relationships, and instead of focusing on algorithms just focusing on the problem space and how different pieces interrelate. It does take practice and experimentation to produce an elegant solution to a problem, but with experience it gets easier. I have no doubt the author of this article could make it feasible to discover chords and tunings as he describes in the Future Work section. Though I would recommend starting over with this goal in mind; even a naive but viable solution might reveal some property of the system that would transfer over to the original program and increase its versatility.

<comment><USER6> I'd love to see that code. Sounds awesome.

<comment><USER5> I intend to do a proper writeup for this, in the meantime I published a short blog[1] with the program along with some background information.

[1] [https://blog.phazon.xyz/answer-set- programming/2020/04/22/mu...](https://blog.phazon.xyz/answer-set- programming/2020/04/22/musical-logic-program.html)

<comment><USER7> This is great, thanks for posting! I'll definitely take your advice to heart. I've been noticing that finding different data representations of the problem at hand is a big part of finding the "core relations" that describe the problem. My first attempt at the voicing/4 predicate was attempted with a data structure used in a procedural version of the algorithm, and I just couldn't get it to work in Prolog. The second iteration is what you've seen, and I'm working on a third iteration with a simpler data representation that is simplifying the problem even further.

</comment></comment></comment></comment><comment><USER8> Tangentially related; I wrote some python code to come up with every possible pentatonic scale (including some restrictions for musicality) - If nothing else, I learnt a lot about scales and how they relate to one another

[https://github.com/ValdemarOrn/PentatonicScales](https://github.com/ValdemarOrn/PentatonicScales)

</comment><comment><USER9> So I've been interested in learning prolog ever since I found out it was a language used for AI. I am wondering if it is worth picking up now?

Does it change the way one things about interacting with a computer or a problem?

Is it something that will soon grow?

<comment><USER10> Prolog is fundamentally well established (~40 years old), and you can start using it today in several programming languages. For example:

JavaScript [http://tau-prolog.org](http://tau-prolog.org)

Ruby [https://github.com/preston/ruby-prolog](https://github.com/preston/ruby- prolog)

Rust [https://github.com/mthom/scryer-prolog](https://github.com/mthom/scryer- prolog)

Erlang [https://github.com/rvirding/erlog](https://github.com/rvirding/erlog)

If your language is missing one, implementing a basic Prolog is fairly simple. Take a look at the Ruby one: it's core is not even 500 lines of code!

There are also great options like SWI Prolog if you want to build your entire app in Prolog. But I imagine it would be much easier to convince a work boss to pull in a library instead :)

Re AI: It's true that Prolog's origins involved AI, but nowadays Prolog is better suited for more general logic programming tasks (there are better tools out there for AI specifically).

<comment><USER11> > Erlang > [https://github.com/rvirding/erlog](https://github.com/rvirding/erlog)

Fun fact: Erlang started out as a modified version of Prolog. The original Erlang VM was written in Prolog as well.

</comment></comment></comment><comment><USER12> I kinda want to see a riff generator, searchable by chord base/tonality, time signature, and length. Also a scale exercise generator. Lot of space to explore in terms of permutations. I seem to recall some research on probability of usage of a particular set of notes/chords based on information entropy but I can't find that anywhere.

</comment><comment><USER13> It's an interesting problem

An even harder problem is figuring out the chord corresponding to a given set of notes. And it is surprisingly hard (though humans seem to do it "easily" (with experience).

Even harder because for some there is no right answer, or better, the right answer is the simplest. Yes C-E-G is a CMajor chord, but what is D-F-Bb-E ?

</comment><comment><USER14> I'm working n an IDE for music composition. Launching soon. [http://ngrid.com](http://ngrid.com)

<comment><USER15> Redirects to National Grid US.

<comment><USER14> Fuck is [http://ngrid.io](http://ngrid.io).

<comment><USER16> Just so you know - you can edit your previous post.

<comment><USER14> You can't after 2 hours.

<comment><USER16> TIL : Today I learned. I didn't know that.

Although I have made your kind of mistake before.

This is why I do a post-proof read / link test after I post.

</comment></comment></comment></comment></comment></comment><comment><USER17> Re: Future Work: I didn't think about the particular predicates in detail, but the author could consider using the cut predicate (!) to prevent some unnecessary backtracking. Without more thought I can't guarantee that actually could be effectively applied here, though

</comment><comment><USER18> Prolog is rather limiting; that's why Lisp has established itself in traditional AI and especially in algorithmic music composition/generation too (see e.g. Experiments in Musical Intelligence, EMI, or OpenMusic or CLM); even today there are very interesting tools based on Lisp for music generation, e.g. [https://en.wikipedia.org/wiki/Impromptu_(programming_environ...](https://en.wikipedia.org/wiki/Impromptu_\(programming_environment\)).

<comment><USER19> > Prolog is rather limiting;

How is it limiting?

<comment><USER18> Lisp is a general purpose programming language, supports any paradigm and the implementation of domain specific extensions. Tool and library support is very good and there is abundance of tutorials, books and people supporting it. Prolog is not a general purpos programming language, but you have to write relations and queries which are then resolved by SLD. You can implement that in Lisp and it runs very fast e.g. on SBCL which has a JIT compiler; I'm not aware of similar performance with Prolog compilers. Just to name a few limitations.

<comment><USER19> Thanks for your response.

I love Lisps (especially Racket and Clojure) so let me just be clear that I am not going to argue that one is "better" than the other.

> library support is very good

That depends mostly on the implementation. SWI Prolog has a decent number of libraries available. Tau Prolog can interoperate with JavaScript.

> Prolog is not a general purpos programming language

I've made a HN clone in SWI Prolog. You can represent HTML as lists, like you would in many Lisps. In some sense, Prolog can occasionally feel _more_ general purpose because you don't need a separate language (like SQL) for your database.

> but you have to write relations and queries which are then resolved by SLD.

That is true, yet in some sense this is like stating about Scheme that "you have to write functions which are then evaluated". Yep, you _have to do that_ but it doesn't mean the language can't be used for X.

> there is abundance of tutorials, books and people supporting it.

Yup, I dig SICP, The Little Schemer and Rich Hickey's talks. When it comes to Prolog, Markus Triska's presentations are amazing[0].

If it was all about _which language has the most books written about it_ , I'd worry that the "winner" would be Java. (I haven't particularly enjoyed the books I've read about Java though.)

> supports any paradigm

I'm not sure that is necessarily a good thing. JavaScript kinda does this, and I feel like I can never tell if a function or method call is pure or mutates something. Does `foo.sort()` modify `foo` itself, or does it just return an a sorted collection of the elements in `foo`?[1]

I also find it confusing in Common Lisp that `sort` is destructive[2]. I think Clojure fares better there by sticking to immutability.

[0]: [https://www.metalevel.at/prolog/videos/](https://www.metalevel.at/prolog/videos/)

[1]: [https://medium.com/@winwardo/the-principle-of-least- astonish...](https://medium.com/@winwardo/the-principle-of-least-astonishment- and-javascripts-sort-e98a734a30c9)

[2]: [http://clhs.lisp.se/Body/f_sort_.htm](http://clhs.lisp.se/Body/f_sort_.htm)

<comment><USER18> > Prolog can occasionally feel more general purpose

That's subjective; Prolog is/was not intended to be a general purpose programming language, as little as e.g. SQL. And human imagination and perseverance make it possible to reach the goal even under the most adverse circumstances. If you make an effort, you can also build an HN clone in Assembler or Brainf*ck. You cannot conclude from this that the language is intended/suited for this.

> yet in some sense this is like stating about Scheme that "you have to write > functions which are then evaluated"

No. There are different ways to evaluate rules. If you don't like SLD then the tinkering begins if you want to stay in Prolog.

> I'm not sure that is necessarily a good thing

It is. E.g. MOP in Lisp is something extremely powerful. With macros you can do things that languages like JavaScript (or Prologue) can only dream of; but you know that yourself for sure.

<comment><USER19> Lol, it's nothing like assembler or brainfuck.</comment></comment></comment></comment></comment></comment>


Ask HN: Anyone else uncomfortable talking to cloud voice agents? - awinter-py 20% of american households have an alexa now and I get generalized anxiety from being in the same room with one. I don't like driving in a car with G talk / siri. I stay away from samsung TVs.
Should I seek psychiatric help or are these devices truly creepy?
In particular: have you caught yourself watching what you say around always-listening devices. <comment><AUTHOR> I get tired when I talk to machines, it seems to take more mental and physical effort than talking to people. (I have to make whatever adjustments are required so the machine will understand me, multiplied by the number of times I have to repeat it.)

As for the fear of your fellow man, I think the total amount of danger you are exposed to through microphones through

* high-school hackers

* intelligence services of countries other than your own

* identity thieves, bank robbers, etc.

* disgruntled contractors of Amazon.com, National Security Agency, etc.

* people who want to make a sex tape of you, or frame you for some crime, etc.

* your spouse, parents, children, etc.

is vastly greater than the treat of the intelligence agencies of your own country poses to you in most places.

Echo normalizes "always on" behavior; something that looks a bit like a hockey puck can be stuffed under the bed, in either a tidy or messy A/V center and be ignored. For that matter, people are used to seeing strange phones, laptops and other things plugged in around the home and office.

The threat you are up against looks like:

[https://vanderpot.com/Clinton_Cook_Paper.pdf](https://vanderpot.com/Clinton_Cook_Paper.pdf)

</comment><comment><USER2> More people should watch the movie "Das Leben der Anderen"[1], how Stasi thoroughly bugged the living places of people dangerous to "state security".

Now they're buying them for being too lazy.

[1] [http://www.imdb.com/title/tt0405094/](http://www.imdb.com/title/tt0405094/)

</comment><comment><USER3> > Should I seek psychiatric help

No, you should write your representative(s), support privacy groups (such as EFF), and in general lend a hand to establish the legal limits to surveillance and ownership of meta/data produced in course of using a commerical product.</comment>


Parts of earliest genetic material came from the stars - <AUTHOR> http://esciencenews.com/articles/2008/06/13/scientists.confirm.parts.earliest.genetic.material.may.have.come.stars

<comment><USER2> Ahem: "Scientists confirm that _PARTS_ _OF_ earliest genetic material came from the stars." You took an already over-sensationalized article title and editted out even the tiny hint of rationality it had left . Shame on you.

From later in the article: "The materials they have found include the molecules uracil and xanthine". This isn't DNA, it's like finding a clay pit and announcing "Our house came from under the earth!".

Sigh...

[EDIT: I see the article title has been fixed to better reflect the source. Many thanks.]

<comment><AUTHOR> I may have been a little over excited on this one, but its still very significant. This is complex organic molecules, direct precursors of DNA components, found in a meteorite. You can downplay this all you want but this is no clay pit vs house :) Sorry again for the sensationalized title; I think I've been exposed too much to Digg, will do better next time.

<comment><USER2> Truthfully, no, it's not all that significant. Here are the relevant wikipedia entries on those molecules:

<http://en.wikipedia.org/wiki/Uracil> <http://en.wikipedia.org/wiki/Xanthine>

These are simple molecules. Many organic molecules (including some more complicated than this) have been found in space, either in meteorites or spectrally. This are significant only because they're chemically related to what life ultimately ended up using here on earth (or at least Uracil is, being an RNA pair base -- I have no idea what the Xanthine connection is, honestly).

Really, this isn't all that surprising.

</comment></comment></comment><comment><USER3> It's always disheartening that these types of stories don't make major news networks. The fact that our DNA may in fact be extraterrestrial is small beans compared to Britney Spears's 42nd mental breakdown.

<comment><AUTHOR> I agree - if you want to help get this on Reddit and Digg, feel free :)

<http://www.reddit.com/info/6n9fl/comments>

[http://digg.com/space/Confirmed_Earliest_genetic_material_ca...](http://digg.com/space/Confirmed_Earliest_genetic_material_came_from_the_stars)

</comment></comment><comment><USER4> Every element with an atomic number greater than 1 comes from the stars: [http://aether.lbl.gov/www/tour/elements/stellar/stellar_a.ht...](http://aether.lbl.gov/www/tour/elements/stellar/stellar_a.html)

</comment><comment><USER5> No one can stop us now, because we are all made of stars. <http://www.youtube.com/watch?v=Qdb4NyHdFfE>

</comment><comment><USER6> Of course, we are all built from the same explosions that made the cosmos. In fact i have some pretty crazy theories that neutrinos cause all Universal beings to expand (or the container to expand) but I think this is the main reason people love explosions and fireworks. They either signal change AND/OR life being created. Whether you are scientific or religious, you have to believe in multiple dimensions and particles or elements beyond Earth is what makes up the human and the planet we reside on.

The HLC is hoping to find more about this. The same elements that started the big bang, morphed and advanced into us. Amazing what else they can build with lots of time.

<comment><USER7> _i have some pretty crazy theories that neutrinos cause all Universal beings to expand_

No you don't. That's not coherent enough to be a theory, not even a crazy one. It's just some big words you managed to put together, one after the other, without any apparent understanding of what any of them means.

<comment><USER6> Well I tried to spill too much in one thread. You have no idea what you are saying because you are judging by one thread. I have studied neutrinos intently and I hope the LHC will reveal more about them as a building block. But go ahead be a hater, I can use you for fuel. btw if those are big words I am sorry.

<comment><USER8> Honestly, "people like explosions because of the big bang" sounds like (too much) THC, rather than LHC.

<comment><USER6> Funny. But yep welcome to America where if you say anything that is too passionate about something or if you have an artistic, natural take on things people quickly identify you and say you are smoking the funny stuff. Keep that mindset and never create something new or a new take on things.

Tell me why you like explosions and fireworks? I personally think that if we come from stars or the cosmos it has greater meaning than just bright lights, big color, sensory overload. It could mean life or the start of this whole system.

Or we could all just not think too far out of the box because it is safe and we wont' be marked for smoking the reefs because it is not the normal way to look at things.

Now go back to your pharma meds that are acceptable because they shut down passionate thinking or pondering.

<comment><USER7> I'll make you a deal. You leave the physics to me, and I'll leave the drugs to you.</comment></comment></comment></comment></comment></comment>


Mincss "clears the junk out of your CSS" - <AUTHOR> http://www.peterbe.com/plog/mincss <comment><USER2> Too bad I didn't catch this while it was still on the front page.

I wrote Helium CSS a few years ago, <https://github.com/geuis/helium-css>.

There are many problems with the approach being taken with MinCSS that are reflected in how Helium was constructed.

1) Server-side parsing is brittle. Using regex's for this is a no-no. Helium uses document.querySelector _in the browser_ to really test if a selector matches or not. It even has Sizzle for older browser support.

2) Different css is used to target different browsers, or at least different capabilities. Running this server-side doesn't tell you which browser some totally valid css is meant to be used for.

3) Removing un-matched css rules by default is a no-no. Again, tools like this can be clever but they're never smart. It takes the engineer's eye to say, "This is something I actually need to keep" or "Yup, remove this".

4) Helium works in the browser. This lets you easily run it across multiple browsers that you need to support.

You _could_ make a headless browser that uses Helium, but you're going to be limited to Webkit (phantomjs). Its a thought I've had, but never really thought it was worth the trouble of building such a limiting system.

I encourage anyone who needs a versatile tool to try Helium. Feel free to contribute patches and stuff.

</comment><comment><USER3> The problem I have with these CSS mini programs is that a 'dynamic' site might not always load the css on each page, unless under certain specific circumstances.

i.e. what about ajax calls that result in a new div showing?

or a responsive CSS file with media queries depending upon the size of the screen?

<comment><USER4> How about running it as a background to the website, over say, a month, at the end of which you'd have pretty good confidence that you'd have hit all paths.

<comment><USER5> This is an idea I am currently working on, similar to SitePoint's old "Dust Me Selectors" plugin for Firefox, but running in the background for all selected sites until a set amount of time or the user is happy that they have exhausted all dynamic functionality on the site.

<comment><USER6> How about running it as a plugin or something for a suite of functional specs for the website ( if it has one! ). Functional spec's by definition should run all the paths that a user can take, so it should give a pretty good idea of the css that is used.

</comment></comment></comment></comment><comment><USER7> A few years ago I wrote a python script which does this and more. It inlines the CSS to the page and reduces it to only the used CSS rules [1].

Additionally, my version can also inline the page images as base-64 encoded blocks.

Cheers!

[1] <https://github.com/jaytaylor/python-inlineify-html>

<comment><USER8> BTW, I like your wget.py. Did you write that? I suspect I've seen it before.

<comment><USER7> Thanks! I did write it, and I think I've also seen somebody else's "wget.py" in some other python project before, though I can't recall where. At any rate, I've found it an extremely useful tool in a multitude of different contexts.

Here is a link to my latest version of it:

<https://gist.github.com/4596861>

At this point it has become less simple and more versatile.

Enjoy!

-Jay

</comment></comment></comment><comment><USER9> I literally hacked a small script that did this 1 hour ago, but using data from Dust-me Selectors[1].

Having a proper tool to do this is great news!

[1] [https://addons.mozilla.org/en-us/firefox/addon/dust-me- selec...](https://addons.mozilla.org/en-us/firefox/addon/dust-me-selectors/)

</comment><comment><USER10> To echo other sentiments on this page, how does this work with a one page, ajax application?

The other issue, is that it is all to often that user events trigger the adding, subtracting or refactoring selectors.

How does this handle these scenarios?

<comment><USER11> This is exactly the point I was coming to make. I like the idea of Mincss, I have even considered making something like it before, but the problem is that if you are adding and removing dom elements with JS then I doubt this program would be able to correctly identify them all and would accidentally clear out CSS that your site needed.

That said, I am sure that static sites/non-JS intensive sites might be able to use this.

</comment></comment><comment><USER12> I wrote something simliar a while back called CSSess[1]. It's entirely JS and runs in the browser. It's based on yet another project called Helium[2]. The primary difference is that it crawls your site and checks over multiple pages. This is a must have feature for pretty much all sites.

I've been meaning to port it to node and run it with a headless browser. Contributions are always welcome.

1: <http://cssess.com>

2: <https://github.com/geuis/helium-css/>

<comment><USER13> Have you considered combining it with a headless browser, like phantomjs, or with node.js + jsdom (a js based DOM that can run jquery)?

<comment><USER12> I've been wanting to make it headless for a while, just haven't gotten around to it yet.

</comment></comment></comment><comment><USER14> I was thinking about this earlier today and how helpful it would be to just not worry about deleting CSS I didn't need. Nice!

</comment><comment><USER15> I am using the CSS Usage extension [1] for Firebug as a tool for this.

Quote:

How does it work?

\- Open up the first page of the site you want to check and press the "Scan" button in the "CSS Coverage" Firebug tab.

\- In case of a rich (Ajax or DHTML) site, open up as many divs/popups/tabs in the page as possible and press "Scan" again.

\- Visit other pages of your site and press "Scan" again.

Each time you press "Scan", the CSS files that are included in the current page are shown with the number of times the rules has been found applied on your page before it.

[1] <https://addons.mozilla.org/en-us/firefox/addon/css-usage/>

<comment><USER8> That looks really cool! I'm impressed. That looks like a great tool for manual inspection when there's a lot of Javascript and conditional loading at play.

I installed it.

</comment></comment><comment><USER16> Heh, I had pretty much the exact same idea in december as well, and produced a system based on Compass/SASS which does a final pre-process step before CSS output, which attempts to remove any unused rules.

Managed to get 100kB of CSS down to about 2kB for the single-page site I was using it on.

Like the author here, I didn't get into exploring how to make this work effectively on a large site with a number of dynamic pages - the only thing I added for this type of approach was to provide a whitelist.

</comment><comment><USER17> Very cool project!

Would be nice if you could browse through the proxy for a bit and have it record the overall usage of CSS for your site.

</comment><comment><USER18> Firefox will show me what CSS applies to each entity and what attributes result. I'd like something that gave me the same information textually so I can tweak the CSS, e.g. simplifying specificity without intending to change the end result, and check for changes, e.g. diff(1). Anyone know of such a thing?

</comment><comment><AUTHOR> Hey just fyi, I didn't develop this, just found it online and wanted to share here. I'll let the developer know.

<comment><USER8> Thanks for sharing.

</comment></comment><comment><USER19> Is it feasible to find superfluous statements?

Ex: A line of CSS that sets text color of li tags to something, but every li tag already would be that color because of a CSS statement for body.

I'm guessing it'd be hard to build something useful and correct, but I think it'd be an interesting extension of this idea.

</comment><comment><USER20> So if I have a large site driven by a web content management system and each page uses different parts of the css, how can we leverage this? Does it mean we have to generate different css files for each page? or have a dynamically generated css file for each page?

<comment><USER8> Your choice.

You can feed mincss a bunch of different URLs and or different .html files and it'll work out the CSS in that. (Note: even if you feed it the raw HTML as a string you need to give it a URL) Or, you do one page at a time. However that's slow and will only be an option if you have serious caching. See <http://www.peterbe.com/plog/mincss-in-action>

</comment></comment><comment><USER21> This used to be common practice for front-end developers, back when Firefox was the most popular browser: [https://addons.mozilla.org/en- us/firefox/addon/dust-me-selec...](https://addons.mozilla.org/en- us/firefox/addon/dust-me-selectors/)

</comment><comment><USER22> SitePoint made an extension that does this years ago. It will try and scan your whole site too, making it a bit more useful than this: <http://www.sitepoint.com/dustmeselectors/>

</comment><comment><USER23> So awesome! Our project at work is quite a big web-based app and we've been developing it for the past 2 years. So you can imagine there is always things to clean up. Will definitely try this!

</comment><comment><USER24> I've been looking for something like this, but with support for styles added using JavaScript. I have found anything yet, and it doesn't appear that this would do it either?

<comment><USER25> I started a similar project before Christmas. It has a whitelist feature, where you can list styles added using JavaScript. It may not be the perfect approach, but it's at least one way of getting around the problem.

It also supports lists of HTML and CSS files to search through. It can perform login, find duplicates, list used rules as well as unused rules, as well as count how many times each rule is matched in the markup.

Requires Node, can be installed with npm.

<https://github.com/operasoftware/ucss>

<comment><USER24> The only thing I could think of was to have some kind of browser extension, that works something like this:

      1. Start the extension scan

      2. Scan all external CSS currently in use (page load)

      3. Scan all inline CSS currently in use (page load)

      4. Monitor (this is the missing piece of the puzzle): Developer uses the app and extension monitors new AJAX or JavaScript added CSS rules

      5. Developer clicks a Finish and Report button:

        a) Warning for inline CSS that could be moved externally

        b) Warning for external CSS that is never used

        c) Export (per CSS file, or combined and minified) CSS files, with unused CSS removed.

</comment></comment></comment><comment><USER26> This looks a lot like <https://github.com/begriffs/css-ratiocinator>

</comment><comment><USER27> Great work! Thank you. I've been wanting something like this. Would be great to see it evolve to handlebars templates someday.

</comment><comment><USER28> Not very sure if it good tool, for sites with one css file applying to all pages.

Very possible, some css rules are only used in 1 or 2 pages.

<comment><USER8> If you CAN use it for one page at a time, excellent. If not, you have to be more careful.

Here's an example of using it on just one page at a time <http://www.peterbe.com/plog/mincss-in-action>

</comment></comment><comment><USER29> Holy crap. I had this same idea around the same time (Christmas break). Unfortunately I didn't get further than setting up the scaffolding and a name (NoClass), but I'm glad you did. Awesome and thanks!

</comment><comment><USER30> thank you, I was looking for something like this, have to keep the label "use with caution". but great work

<comment><USER8> Yeah, unfortunately you have to know what you're doing with a tool like this. Know, as in, you need to know what's going on in your app/site.</comment></comment>