Skip to content

Instantly share code, notes, and snippets.

@WilCF
WilCF / gist:8345802
Created January 10, 2014 02:08
Liquid If Loop Example
{% if country == 'United Kingdom' %}
<div class="borderhash"><a target="_blank" href="http://www.linkedin.com/vsearch/p?firstName={{first_name}}&amp;lastName={{last_name}}&amp;postalCode={{zip}}&amp;openAdvancedForm=true&amp;companyScope=CP&amp;locationType=I&amp;countryCode=gb&amp;distance=100">2.Search UK's LinkedIn for {{first_name}} {{last_name}} 100 miles from their zip code</a></div><br />
{% elsif country == 'Australia' %}
<div class="borderhash"><a target="_blank" href="http://www.linkedin.com/vsearch/p?firstName={{first_name}}&amp;lastName={{last_name}}&amp;postalCode={{zip}}&amp;openAdvancedForm=true&amp;companyScope=CP&amp;locationType=I&amp;countryCode=au&amp;distance=100">2.Search Australia's LinkedIn for {{first_name}} {{last_name}} 100 miles from their zip code</a></div><br />
{% else %}
<div class="borderhash"><a target="_blank" href="http://www.linkedin.com/vsearch/p?firstName={{first_name}}&amp;lastName={{last_name}}&amp;p
I added an "aggregation=avg" to the cml:checkboxes element. I copied the job and ran it on the internal channel and submitted my judgments. The results came out in the hidden field "results_percentage", so at least that part works.
As for making test questions, I don't know how to do that, because as they said in their email, the choices are created dynamically in javascript. If he wants to completely re-do the way he's built the job, here's one idea I can think of.
For each unit in their csv, create new columns titled
"category_1_name"
"category_2_name"
"category_3_name"
"category_4_name"
Then split out the contents of the column "categories" into those columns. In the cml he would do
<cml:checkboxes label="" validates="required" instructions="" name="" class="" gold="true" aggregation="agg">
<cml:group name='my_task' label='' only-if='skip:unchecked'>
YOUR TASK CML
</cml:group>
<cml:checkbox label="I didn't find any information" name='skip'></cml:checkbox>
@WilCF
WilCF / gist:8584353
Created January 23, 2014 18:41
I have a csv file that contains one master value and 1-8 possible matches. What i would like to do is only show the number of matches that exist. So, for example, if there are only 4, just show the 4 options. Is there a way to do this in CML? Currently I just show all 8 which leads to some rows displaying 'No data available' which doesn't look g…
{% if column_1 != 'No data available' %}
{{master_column}}
{% elsif column_2 != 'No data available' %}
{{master_column}} {{column_1}}
{% elsif column_3 != 'No data available' %}
{{master_column}} {{column_1}} {{column_2}}
{% elsif column_4 != 'No data available' %}
{{master_column}} {{column_1}} {{column_2}} {{column_3}}
{% elsif column_5 != 'No data available' %}
{{master_column}} {{column_1}} {{column_2}} {{column_3}} {{column_4}}
@WilCF
WilCF / gist:8605219
Created January 24, 2014 20:07
Wil's Shreddy Pork
Ingredients: 3 lbs of boneless pork spare ribs, 1 package bacon, 1 white onion, 1/2 bottle of BBQ sauce of your choice
Dry rub ingredients: 4 tbsp smoked paprika, 2 tbsp sea salt, 2 tbsp chili powder, 2 tbsp ground cumin, 1 tbsp ground black pepper, 1 tbsp dried oregano, 1 tbsp ground white pepper, 2 tsp cayenne pepper,
I used a little over 3.3 lbs of pork shoulder to make this, you could also use spare ribs or something similar.
Cut the meat into medium-sized meatlets
Take the dry rub ingredients and mix them together in a bowl and use this to liberally coat each of the pieces of meat. Once that is done, wrapp them tightly in plastic wrap and leave them in the fridge overnight.
There's a script you can run that divides an audio clip into small segments.
The following code splits an mpeg into optionally overlapping snippets of audio for transcription or whatever...
#NOTE! you must install ffmpeg in your system first (http://ffmpeg.org/download.html): $brew install FFmpeg
overlap = XX #overlap between snippets in seconds
total_length = XX #total length of file in seconds
step_size = XX #length of snippets in seconds
file_path = "" #path to audio file
curl https://api.crowdflower.com/v1/jobs/425038/units/448518368.json?key=KEY
{"agreement":1.0,"missed_count":0,"results":{"item_price":{"agg":null,"confidence":0},"price":{"agg":"","confidence":1.0},"discount":{"agg":"","confidence":1.0},"include_yn":{"agg":"","confidence":1.0},"judgments":[{"reviewed":null,"worker_id":26078288,"unit_state":"finalized","golden":false,"started_at":"2014-04-17T20:28:13+00:00","created_at":"2014-04-17T20:29:32+00:00","data":{"item_price":"$7.49","item_quantity":"1"},"job_id":425038,"tainted":false,"rejected":null,"judgment":1,"unit_data":{"unit_type":"item_unit","filename":"http://karasic.com/crowdflower/Costco-001.jpg","upc":"805573"},"worker_trust":1.0,"unit_id":448518368,"region":"MA","external_type":"cf_internal","country":"USA","webhook_sent_at":null,"id":1245319265,"trust":1.0,"city":"Lexington","missed":null}],"discount_price":{"agg":"","confidence":1.0},"quantity":{"agg":"","confidence":1.0},"item_quantity":{"agg":null,"confidence":0},"not_readable":{"agg":"","confidence
when I use the /jobs/{job_id}/units/{unit_id} endpoint to create or update a unit to add gold, I am having trouble specifying more than one answer 2:09
the whole array ends up quoted
or should I just repeat unit[data][field_golden]=x&unit[data][field_golden]=y to give both answers?
I have been doing unit[data][field_golden]=[x,y] 2:10
Wil Stevens sure - I know we separate them by a newline character 2:11
which is often /n
Christopher Hundt you mean unit[data][field_golden]=[x\ny] ?
or rather unit[data][field_golden]=x\ny?
Wil Stevens the latter 2:13
Christopher Hundt that did not seem to work 2:15
I'm using curl on PHP the request parameters are these:
$defaults = array(
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => count($data),
CURLOPT_POSTFIELDS=> json_encode($data, JSON_FORCE_OBJECT),
CURLOPT_HEADER => 0,
CURLOPT_URL => $this->url.$uri.'.json?key='.$this->key,
CURLOPT_FRESH_CONNECT => 1,
<cml:group only-if="able_to_classify:[Yes]">
<cml:select label="Please choose the best classification for the company from the following choices:" id="drop" name="drop">
<cml:option label="Please select one of the following choices..." />
<cml:option label="*****MOST COMMON CLASSIFICATIONS*****" />
<cml:option label="Investment Advisor" />
<cml:option label="Corporation" />
<cml:option label="Hedge Fund Manager" />
<cml:option label="Bank" />
<cml:option label="Government" />