FAQ Database Discussion Community

## Conditional execution of resources

chef,condition,chain
I have the following 2 resources defined within a cookbook that makes HTTP requests. I essentially need to execute action 2 based on checking a condition from the result of action 1. If the condition from action 1 does not match I need the cookbook to sleep for a period...

## Is there a way of avoiding so many list(chain(*list_of_list))?

python,list,nested-lists,itertools,chain
If I have a list of list of list of tuples of two strings. I want to flatten it out to a non-nested list of tuples, I could do this: >>> from itertools import chain >>> lst_of_lst_of_lst_of_tuples = [ [[('ab', 'cd'), ('ef', 'gh')], [('ij', 'kl'), ('mn', 'op')]], [[('qr', 'st'), ('uv',...

## How do I reuse an intermediate value in chain of Haskell Either binds?

I'm sure this has been answered but apparently I don't know what to search for. I am working on my first non-trivial Haskell program -- a simulation of a card game I enjoy. I have the program working but there is a situation that I am certain can be handled...

## Parse.Cloud.httpRequest httpresponse does not match cUrl response

curl,parse.com,bitcoin,chain
I would like to get the same HTTP response from Parse.com cloud code calling Parse.Cloud.httpRequest as I've got from cUrl. But I can't get it. Does anybody know what am I doing wrong? cUrl example: curl https://api.chain.com/v2/bitcoin/transactions/917673efa435b483343ddfe373995df365260c617107d3f9de68abd4e97c981b/confidence?api-key-id=e8d5ed773cf24e31c149ae874eb23c74 response from cUrl: { "transaction_hash":"917673efa435b483343ddfe373995df365260c617107d3f9de68abd4e97c981b",...

Sometimes I'd like to add class in chain, under some condition. What value would be semantically most appropriate to add no class? Example: $(".element").doSomething().addClass(condition ? "special-class" : undefined).doSomethingElse(); Or:$(".element").doSomething().addClass(condition ? "special-class" : null).doSomethingElse(); ...
After reading How to connect nodes with TikZ?,I am thinking about how to convert below simple example to use TiKz chain. Current MWE: \documentclass[tikz]{standalone} \usetikzlibrary{arrows,positioning,calc} \tikzset{ block/.style={draw,text width=2em,minimum height=1em,align=center}, arrow/.style={->} } \newcommand\connect[2]{\path[draw,arrow] (#1) |- ($(#1)!1/2!(#2)$) -| (#2)} \begin{document} \begin{tikzpicture}[>=stealth'] \node[block] (N1) {N1}; \node[block,below=1cm of N1,xshift=-1cm] (N2) {N2}; \connect{N1}{N2}; \end{tikzpicture}...