Skip to content

Instantly share code, notes, and snippets.

View josephcc's full-sized avatar
💭

Joseph Chang josephcc

💭
View GitHub Profile
#!/usr/bin/env python
import sys
import logging
from collections import defaultdict
BOLD = '\033[1m'
GREEN = BOLD + '\033[92m'
RED = '\033[93m'
BLUE = '\033[94m'
ENDC = '\033[0m'
from re import *
from sys import stdin
uncnf = lambda g: g if type(g) == str else tuple(map(uncnf, g[match(r'\[X[1-9][0-9]*\]', g[0])!=None:]))
pyfy = lambda l: eval((sub('([^ (]) +', r'\1,', sub('([^() ]+)', r'"\1"', sub('([()])', r' \1 ', l).strip()))))
def _clean(g):
for gg in g:
if str in (type(gg), type(gg[0])):
yield gg
help
transfer-help
variables
documentation
xle-version
create-parser
parse
parse-word
parse-lattice
morphemes
PROJ ENGLISH CONFIG (1.0)
ROOTCAT S.
FILES .
LEXENTRIES (PROJ ENGLISH).
RULES (PROJ ENGLISH).
TEMPLATES (PROJ ENGLISH).
GOVERNABLERELATIONS SUBJ OBJ OBJ2 OBL OBL-?+ COMP XCOMP.
SEMANTICFUNCTIONS ADJUNCT TOPIC.
NONDISTRIBUTIVES NUM PERS.
EPSILON e.

Real-time, Channels, & Subscriptions


Overview

In KA, the private_pub gem enables the pushing of real-time changes from the server to the client via channels.

A model can be set up to push changes to a channel on an ActiveRecord callback (some transaction).

A view's JS can be set up to listen to a channel for those changes.

class FindClipsController < ApplicationController
layout false
def clip_for_option
@option = Option.find(params[:id])
@question = @option.question
render 'clip'
end
def clip_for_source
class Task < ActiveRecord::Base
attr_accessible :name, :taskable_id, :taskable_type, :question_id, :task_role_id, :task_order_id
belongs_to :taskable, polymorphic: true
belongs_to :task_role
belongs_to :task_status
belongs_to :task_order
belongs_to :question
<div class="container">
<h1>Redirecting back to Amazon MTurk...</h1>
<%= turkee_form_for(@dummy, params) do |f| %>
<input type="hidden" name="dummy_data" value="123"/>
<p><%= f.submit 'Create' %></p>
<% end %>
</div>
<script type="text/javascript">
$('form').submit()
seen = {}
count = 0
File.open(ARGV[0]) do |iFile|
iFile.each do |line|
begin
toks = line.split
toks.each do |tok|
tok = tok.downcase
jQuery ->
#
# only execute script on .v-find-clips-feedback context
#
if jQuery('body').find('.v-find-clips-feedback-analytics').length == 0
return
console.log 'init'