Skip to content

Instantly share code, notes, and snippets.

View WilCF's full-sized avatar

Wil Stevens WilCF

View GitHub Profile
@WilCF
WilCF / gist:1dd5a76558a1c5358f41
Created May 26, 2015 21:00
JQuery to disallow similar textbox input submissions
require(['jquery-noconflict'], function(jQuery) {
//Ensure MooTools is where it must be
Window.implement('$', function(el, nc){
return document.id(el, nc, this.document);
});
var $ = window.jQuery;
$(document).ready(function(){
$("input.submit").click(function(e){
var bad_answers = false;
$(".cml.jsawesome").each(function() {
@WilCF
WilCF / gist:e97fbb93306e092db98a
Created May 26, 2015 14:10
Only If Not Empty Liquid
<cml:radios name="category" label="Choose the best category for this product:" validates="required">
<cml:radio label="{{pt_1}}" value="{{pt_1}}" />
{% if pt_2 != '' and pt_2 != 'No data available' and pt_2 != empty %}
<cml:radio label="{{pt_2}}" value="{{pt_2}}" />
{% endif %}
{% if pt_3 != '' and pt_3 != 'No data available' and pt_3 != empty %}
<cml:radio label="{{pt_3}}" value="{{pt_3}}" />
{% endif %}
{% if pt_4 != '' and pt_4 != 'No data available' and pt_4 != empty %}
<cml:radio label="{{pt_4}}" value="{{pt_4}}" />
a.clean {
color:#00a6e0;
text-decoration:underline;
font-size: 20pt;
line-height: 18pt;
font-weight: 900;
}
a.clean:link { color:#00a6e0;
text-decoration:underline;
font-size: 20pt;
<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" />
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,
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
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
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
@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.
@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}}