offersgugl.blogg.se

Simple writer xkcd
Simple writer xkcd






  1. #Simple writer xkcd how to#
  2. #Simple writer xkcd code#

The access point is called an Application Programming Interface (API) and there are different types of APIs. Many services on the internet provide a web service so that it is easier for machines to get access to their data.

#Simple writer xkcd how to#

If you want to learn how to fetch JSON data from a REST API, download a file from the internet and display a PNG file in a ultra-simple example, read on! We’ll see if this holds up.Xkcd webcomics is one of the institutions of the internet, especially for the nerd community. More pragmatically, I’ve been using it for only a couple days, but it seems to be working! Blank pages are not very good distractions.

simple writer xkcd

Window.alert("Locking for " + time + " seconds.") ĭocument.getElementsByTagName("body").style.visibility = "visible" Var prefs = require("sdk/simple-prefs").prefs Here is lib/main.js, which is run from the start. The core of the program really is just two files. Actually I’m embarrassed it took as long as that.

simple writer xkcd

My estimate was about right it took me approximately 2.5 hours from start to finish, although I admit that I was also chatting on Google Talk in the meantime. The project (which is very small) is posted on my GitHub. It was actually very straightforward in retrospect, and took only a couple files of actual code. I would inject a script lockdown.js into the page and the send it a signal with the amount of time to lock the page. This took me a while to figure out, but it is essentially a bunch of emit/on hooks provided in Jetpack.

  • A way for the individual lockdown scripts to communicate with the main script and vice-versa.
  • Maybe sometime when I’m bored I will take the time to make this work for arbitrarily many websites. This I did kind of painlessly through the Jetpack simple-prefs, but it was kind of an ugly hack in that I manually defined six settings for up to six websites. I used regular expressions to specify the domain.
  • Something to store the websites and their associated delays.
  • This was easy, I just put = "hidden" in JS.
  • Something to actually lock the webpage.
  • This was conveniently covered under “Listen for page load”.
  • Something to trigger every time a webpage was launched.
  • They had very nice tutorials, too.ĭrilling down, the things I needed to make this thing fly were:

    simple writer xkcd

    A quick Google search led me to Jetpack, which offered to let me build an FF extension quickly using just JS. I’m a Firefox user, so it made sense for me to try and put this together as a Firefox extension.

    #Simple writer xkcd code#

    I estimated it would take me about two hours to read/learn the API and write the code to put this together it turns out my estimate was roughly correct. Sounded like fun! The XKCD version seemed a little extreme, but I could definitely do with a script that would make me wait 50 seconds before reading Facebook. The urge to check all those sites magically vanished–and my ‘productive’ computer use was unaffected. I decoupled the action and the neurological reward by setting up a simple 30-second delay I had to wait through, in which I couldn’t do anything else, before any new page or chat client would load (and only allowed one to run at once). Unfortunately, old habits do not die easily, and I found myself automatically visiting those sites when I wasn’t doing anything.Ī couple days ago while I was reviewing my goals and realizing that I wasn’t following this one, I remembered the title text of XKCD 862.Īfter years of trying various methods, I broke this habit by pitting my impatience against my laziness. The same went for the Art of Problem Solving forums (which I frequently visit) as well as Facebook, so I also tried limiting the number of times I checked each of those each day. I was able to follow this suggestion for a day, and really was impressed by the feeling - I realized that I had started to use email as a distraction, something to prevent my brain from realizing it wasn’t do anything. In this post I’ll talk about the inspiration and development for one of my afternoon projects, which I’ve named wintermelon for no good reason.Ī while back Jacob Steinhardt recommended to the SPARC alumni list that we check our email at most twice a day. I’m not sure what I plan to blog about in general, but I figured I might as well put this domain name to good use :) I also realized that writing things out helped me clarify my thinking a lot (actually Qiaochu Yuan recommended this for math in particular), so I’ll be trying to do that more often this 2014 = 2 * 19 * 53 and onwards. So I guess I can resume blogging now, seeing that I’m done with college applications (at last!).








    Simple writer xkcd