Skip to main content

harry palmer

harry palmer's Public Library

  • React & D3.js

     

    In a React component, the text values are typically data-dependent, but in a visualization, the sizes and positions of elements on the screen are also usually data-dependent. D3.js really shines in combination with React, especially when used to find out the sizes and positions of elements in a visualization. D3.js is an interesting library. It’s kind of a “do everything” visualization library in JavaScript, where it has a core set of functionality and then a bunch of name spaces within as well.

     

     

    The image above is an inventory of all the different parts of D3, and what I discovered is that almost all of the parts as you can see highlighted in purple here are actually either pure item-coded functions or something close to it—maybe objects that are stateful, but you can query them for results.

     

    All of these purple items are useable from within a React component without any hoops you’d have to jump through. I’ve gotten a lot of mileage out of D3 in combination with React thanks to this way. However, you’ll notice that selection transitions and drag-in zoom are not included on that list. These are the parts of D3 that are really specific to data binding, so if you’re using D3 to do rendering, those would come into play as well.

May 29, 16

"Integrating D3.js visualizations in a React app
07 September, 2014
A small example exploring how to integrate D3.js data visualizations into a React app.

I've been working with D3.js and React lately, and in this post I wanted to share a few ways I found in building components and the interface between them. I think they help make both libraries work together quite nicely.

We'll be building a small example to illustrate this, and you can find the full code on GitHub, as well as a running version of the app. I'll also assume that you have some basic knowledge of React and D3.js."

  • I find that making D3 components play nice inside a React app becomes easier when you follow these simple guidelines:

      

    (1) "One Source Of Truth": The D3 visualization should get all of the data it needs to render passed down to it. In this example, we'll see that the single source of truth is in the main <App> React component's state, and it is used by the D3 component (d3Chart) and other React components (for example <Stats>).

      

    (2) "Stateless All The Things": This is related to (1). D3 and React components alike should be as stateless as possible, i.e. they shouldn't hide/encapsulate something that makes them render differently given the same "input". In this example, you'll notice that if you call d3Chart.update() at anytime with the same arguments, you always get the same result on screen.

      

    (3) "Don't Make Too Many Assumptions": This is related to (1) and (2). Components shouldn't make too many assumptions about how they will be used. In this example, we'll see that d3Chart doesn't prescribe when tooltips should show, it only shows whatever it receives in the tooltips array. This allows us to show tooltips on hover, but also to easily create a "show/hide all tooltips" toggle.

      

    Enough "theory", let's write some code.

  • aigon is no nomad paradise. But it still manages to attract all kinds of people who stay for a long time. There are various communities and it's still really cheap. Living here is comfortable. Chiang Mai is also a comfortable place for new nomads. It's open to newbies, and is an "Asia-lite" compared to the edgier environment of Saigon. The digital nomad to local population ratio is quite high. There are more options for employment, entertainment / nightlife, dating, events, diaspora communities, etc. in Saigon, but more choice can also be confusing or distracting. Saigon can be more stressful whereas Chiang Mai promotes stress relief in its scenery, less hectic traffic, and massages. Chiang Mai can be a few degrees less hot compared to the hottest times in lower altitudes. Does "digital nomad" define who you are? Do you need to be a member of a digital nomad community above all other concerns? Then maybe Chiang Mai is sufficient. If you seek more, and want to be exposed to variety, insanity, and unexpected things daily, then start discovering Saigon.

     

    Some other comments:
     1. Chiang Mai is a clean city, but there are random poop smells. Saigon has random urine smells (where guys pee on the street).
     2. Chiang Mai has an uncomfortable "burning season" from February til April when the air is full of smoke from fires in the surrounding farmland and people leave the city. The smoke in the air is so bad that there are days the planes can't fly in Chiang Mai causing the airport to shut down and stranding anyone trying to leave, so it's best to stay out for that season.
     3. Thailand uses Thai script to write their language, a script similar to Khmer, but undecipherable to most foreigners. Signs are often not translated into English. Chiang Mai street names are hard to find. Vietnam is the opposite in that even Vietnamese names can be written and read (letter by letter) by foreigners and every building on every street has its address marked outside making it easy to always know where you are (this mostly works).
     4. Chiang Mai is a small and compact city, but increasingly full of cars. The traffic isn't too bad yet but can still back up at intersections. There is basically no bus system or public transit, besides individual trucks. There are also few taxis (making it unreasonable to hail one on the street) but many tuk-tuks.

  • A friend of a friend finally received a supply of etizolam (brand name Etilaam) made by Intas in India, and he took etizolam 2 mg. This had the effect of making him feel calm, happy, and very pleasant indeed. Etizolam also has antidepressant properties, according to the manufacturer's label, and the reason it does not cause the somewhat woozy feeling caused by diazepam is because it has an affinity for the a2 sub-type of the GABAa receptors. According to the leaflet, it is therefore less likely to result in dependence -- the leaflet also states that there have been no cases of abuse on record (although I dispute this).
     
     It has antidepressant properties because it blocks the turnover of norepinephrine and 5-HT (see the literature for more on what this means). It is therefore suitable for anxiety with co-morbid depression. Withdrawal does not cause up-regulation of a4 sub-unit when compared to lorazepam, and this supposedly makes it much less likely to become addictive or to cause dependency and / or tolerance...
     
     Given these properties, I am surprised that etizolam has not been approved for usage in the US and / or the UK.
     
     My friend of a friend then experimented with etizolam 1 mg, lorazepam 1 mg, and diazepam 10 mg, ingested simultaneously. He reported euphoria and a sense of well-being such as he had never experienced from any other benzodiazepines. (Technically, etizolam is a thienodiazepine, not a benzodiazepine, because the benzene ring is replaced by a thiophene ring).
     
     Other accounts would be most interesting!

  • Abstract

    This study evaluated the effects of flurazepam 30 mg, lorazepam 4 mg, triazolam 0.5 mg, and placebo upon sleep and memory in eleven normal male subjects continuously monitored for nighttime EEG, EOG, and EMG recording. Subjects received each drug or placebo for two consecutive nights per week for 4 weeks in a repeated measures, double-blind, Latin Square design. Three hours post-administration, subjects were awakened and presented with a series of tasks. Recall was assessed immediately following task presentation and after the final morning awakening. The results showed that every drug significantly decreased stage 1, increased stage 2, and produced no change in stage 3--4 sleep in comparison to placebo. Only lorazepam significantly decreased REM percent. Post-drug recall was significantly decreased in comparison to placebo at night and was further decreased in the morning. Morning recall was significantly poorer when the return to sleep was 2.5 min or less than when the return to sleep was greater than 5 min following the nighttime awakening in all drug conditions. These results indicate that 1. failure of memory consolidation rather than failure of retrieval is the most likely explanation for the morning memory loss and 2. hypnotic drug properties, measured by latency to fall back asleep, affect memory consolidation.

  • Email confirmation

     

    When a new user gives us their email, we generally want to confirm that they gave us the right one. Once we’ve made that confirmation, we can confidently send password reset links and other sensitive information to our users without wondering who is on the receiving end.

     

    One of the most common patterns for confirming emails is to send a password reset link with a unique URL that, when visited, confirms that user’s email address. For example, john@gmail.com signs up at our application. We register him in the database with an email_confirmed column set to False and fire off an email to john@gmail.com with a unique URL. This URL usually contains a unique token, e.g. http://myapp.com/accounts/confirm-/Q2hhZCBDYXRsZXR0IHJvY2tzIG15IHNvY2tz. When John gets that email, he clicks the link. Our app sees the token, knows which email to confirm and sets John’s email_confirmed column to True.

     

    How do we know which email to confirm with a given token? One way would be to store the token in the database when it is created and check that table when we receive the confirmation request. That’s a lot of overhead and, lucky for us, it’s unnecessary.

     

    We’re going to encode the email address in the token. The token will also contain a timestamp to let us set a time limit on how long it’s valid. To do this, we’ll use the itsdangerous package. This package gives us tools to send sensitive data into untrusted environments (like sending an email confirmation token to an unconfirmed email). In this case, we’re going to use an instance of the URLSafeTimedSerializer class.

  • The ideal way to go about getting pretty much any Python object into a JavaScript object is to use JSON. JSON is great as a format for transfer between systems, but sometimes we forget that it stands for JavaScript Object Notation. This means that injecting JSON into the template is the same as injecting JavaScript code that describes the object.

      

    Flask provides a Jinja filter for this: tojson dumps the structure to a JSON string and marks it safe so that Jinja does not autoescape it.

  • Bruce: Actually yeah, I'm kinda keen on formal methods for writing. But I don't stick to one in particular; I like to use them like fuzz tone boxes or wah-wah pedals. If you're big on this, you ought to read about the Oulipo Group, the "Workshop for Potential Literature." Italo Calvino used to work with them. They had all kinds of off-the-wall stunts, like writing novels without the letter "e" in them.

     I've used a lot of software tools for writing. Outside of a basic work processor to help with the brute labor of typing, a lot of these "tools" just get in the way. Way too many value-add bells and whistles. Lately I'm thinking that turning off the wifi signal is a pretty good idea in writing.

      Search engines are a major research aid for writers, but in the past few years, they've all been turning into surveillance-marketing engines. Now it's like trying to get some fiction done, while Google is all like, "So! Finish that Coke yet? Hey, how about a six-pack?" It's like Larry and Sergei are right in the room now, staring with Google Glass, and holding their breath.

    • <form class="usertext" id="form-t1_czqaasczxu" action="#" onsubmit="return post_form(this, 'editusertext')">

      "North Vietnam" and "South Vietnam" were an invention of 1954 which only persisted for two decades, because the Americans supported the southern puppet ruler Diem in breaking the original agreement of holding national elections in 1956 which Ho Chi Minh would easily have won which would have re-united the country after just two years of artificial division.

        

      The "Vietcong" were just the same as the "Vietminh" of pre-1954 times, a national movement for liberation that was as present and locally rooted in the south as it was in the north (though due to the foreign-backed Diem government in the South, it remained underground there).

        

      The renewed revolt in the south that started in earnest in the late 1950s and turned into the American war was actually instigated by the local Vietminh cadres, not the northern leadership, though the latter quickly seized on it and took direction. Either way, it was always a national movement for liberation from foreign powers in a long Vietnamese tradition that fought the Chinese, the Cambodians, the French and finally the Americans.

        

      To try and equate the Americans and their pathetic, venal, disgusting southern puppets who had virtually no popular support, with the Vietminh/Vietcong forces and the northern national government is, I am sorry, just completely wrong-headed. The terrible tragedy of the entire affair was how pointless the war was as the Vietnamese in the 1950s could have turned into a quasi-ally of the United States as they had much more to fear from China than the US (Ho Chi Minh actively approached the US on a number of occasions for a settlement in the 1940s/50s, but was rebuffed, because US Policymakers just couldn't wrap their head around the idea that communism may not just be a single block, and Ho may be an Asian Tito).

        

      Give another viewpoint a chance and read "A bright shining lie" (or listen to the audio-book), it's a really great biography of one of the most prominent American soldiers in Vietnam and describes well how it all went wrong due to this central misperception.

       
       
      </form>
Feb 03, 16

"A rhythmic, deeply compassionate portrait of two neighbouring towns on opposite sides of the US-Mexico border, Western immerses viewers in the day-to-day lives of residents and lawmakers alike, so that by the time gangland violence begins to encroach upon their existence, our understanding of the threat posed is informed by our understanding of the people most affected, rather than the other way around. While fiction films such as Sicario offer glossy, morally indifferent depictions of life at the border, Western zeroes in on the delicate patterns of life in any small town, to underline the absurdity of the steel and paperwork that divides these two communities.

If the film was always an unlikely prospect for UK distribution, maybe that’s because documentary discourse in Britain so brazenly favours provocative subjects and worthy causes over artistry and execution, a bias that damages an understated film like Western and rewards a bombastic alternative like Cartel Land. The latter film’s sensational title betrays its flashier, hollower treatment of US-Mexico relations, but still it garnered a UK cinema release last September and a Bafta nomination earlier this month, in a category dominated by worthy but inelegant docs."

  • Bruce Sterling's Idea of What Every Well-Appointed "Cyberpunk SF" Library Collection
    Should Possess (circa June 92)

    The Canon:

    BURNING CHROME William Gibson
    Gibson's short stories.

    NEUROMANCER, COUNT ZERO, MONA LISA OVERDRIVE William Gibson
    The "Cyberspace Trilogy."

    MIRRORSHADES THE CYBERPUNK ANTHOLOGY Bruce Sterling ed.
    Useful pointer to actual no-kidding Movement Cyberpunks.

    MINDPLAYERS Pat Cadigan
    Her best novel. An absolute must-have.

    HEATSEEKER John Shirley
    Shirley's short-stories. His most significant and influential work.

  • Abstract

    Over the last decade there has been a rapid expansion in the use of peptides as drugs. Nowadays, they are being used therapeutically in such diverse areas as endocrinology, neurology, haematology and some types of allergies. In the field of autoimmunity, a few candidates have emerged. Thus, in the pipeline of novel strategies designed to treat patients with systemic lupus erythematosus, the 21-mer peptide P140/Lupuzor raises hopes for the generation of an efficient, specific and safe treatment. This phosphopeptide has successfully completed a phase IIb clinical trial and will enter into a multi-centre, double-blind, placebo-controlled phase III clinical trial. The phase IIb trial showed that after three months of therapy (three subcutaneous injections of 200 µg peptide/patient in addition to standard of care), Lupuzor improved Systemic Lupus Erythematosus Disease Activity Index score of lupus patients under active treatment by 67.6% versus 41.5% in the placebo group (p < 0.025). After three additional months of follow-up, the improvement rate was 84.2% versus 45.8% (p < 0.025). The side-effect profile was unproblematic and the drug was well tolerated as evidenced by a very low drop-out rate. P140 does not behave as an immunosuppressant, it acts primarily as a fine immunomodulator of autoreactive CD4(+) T cells. Its underlying mechanism of action involves autophagy, a cellular process that implicates lysosomal-dependent recycling of intracellular components and controls the pool of major histocompatibility complex class II-displayed peptides that is presented to CD4(+) T cells.

  • I've also read this somewhere "tip for primaloft jackets - wash in tech wash at 30 degrees, hang up outside and spray liberally with Graingers XT. Let it drip for a few minutes then tumble dry on a cool setting for 2 hours. Makes them waterproof in all but the heaviest downpour, but they still retain the breathability."

  • With the nights drawing in and the weather getting cooler and wetter, getting out running can feel more of a challenge than usual. With the right kit you can stay warm and have fun, and it’s often even more rewarding than fine-weather running too. We’ve been lucky enough to have spent the past few months testing out and reviewing lots of different items of running kit. Here Sim shares his top items of running clothing for winter. You can read Jen’s round up here.

     
1 - 20 of 8660 Next › Last »
20 items/page

Diigo is about better ways to research, share and collaborate on information. Learn more »

Join Diigo