Skip to content

Instantly share code, notes, and snippets.

class WebsocketControllers::PostingsController < WebsocketRails::BaseController
def new_post
puts 'message:' + message
post = profile.posts.create!(content: message)
broadcast_message :new_post, format_post(post)
WebsocketRails[:posts].trigger(:new_post, format_post(post))
end
##format_post is not being called
## Retrieve all posts on dashboard load
ajax1 =
$.ajax
async: true
type: 'GET'
url: '/posts.json'
success: (data) ->
$.when(ajax1, ractive).done (a1) ->
posts = a1[0]
@Woody88
Woody88 / gist:3c6495d25fcd84e8b036
Created July 20, 2015 19:06
Dispatcher at top level cannot be detect in PostWidget.coffee nor Dashbords.coffe
//TradeWidget.coffee
ready = ->
dispatcher = new WebSocketRails($('#TradWidgetWrapper').data('uri'), true)
dispatcher.on_open = (data) ->
console.log('Connection has been established: ', data);
channel = dispatcher.subscribe 'trades'
channel.bind 'new_trade_post', (message) ->
# Uncomment and change this option to override the class associated
# with your `current_user` object. This class will be used when
# synchronization is enabled and you trigger events from background
# jobs using the WebsocketRails.users UserManager.
#config.user_class = User
# Used as the key for the WebsocketRails.users Hash. This method
# will be called on the `current_user` object in your controller
# if one exists. If `current_user` does not exist or does not
# respond to the identifier, the key will default to `connection.id`
@Woody88
Woody88 / dygraph.ex
Last active July 28, 2017 18:48
Dygraph Genserver
defmodule PlotEx.Dygraph do
@derive [Poison.Encoder]
@default_options %{strokeWidth: 1, drawPoints: true, includeZero: true, gridLineColor: "#ddd", drawGrid: false, title: ""}
@options [:strokWidth, :drawPoints, :includeZero, :gridLineColor,
:drawGrid, :series, :dataHandler, :axes, :plotter, :animatedZooms,
:showInRangeSelector, :file, :showRangeSelector, :maxNumberWidth,
:gridLineWidth, :drawAxis, :yLabelWidth, :y2label, :ylabel, :xLabelHeight,
:xlabel, :titleHeight, :title, :panEdgeFraction, :displayAnnotations, :errorBars, :colorValue,
:sigma, :showRoller, :labels, :drawAxesAtZero, :legend, :visibility, :strokeBorderColor,
:logscale, :axis, :width, :height, :delimiter, :rollPeriod, :color, :colors, :connectSeparatedPoints,
@Woody88
Woody88 / PlantIt.hs
Created September 26, 2017 15:40
PlanIt just for learning
module PlantIt where
import Control.Concurrent.STM
import Control.Monad
data Card = Zero
| Half
| One
| Two
| Three
module Widget.Menu exposing (..)
{-| Recreating the menu found here: <https://github.com/nashvail/ReactPathMenu>
Make using:
elm-make FlowerMenu.elm --output elm.js
open index.html
-}
import Time exposing (second, Time)
import Html exposing (..)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Accounts where
-- , createUser, getUser, loginUser,
import Accounts.User (User(..), UserLogin(..), Accounts, users, createUser, getUser, initializeAccounts)
@Woody88
Woody88 / S15.4.4.8_A1_T1.js
Created March 12, 2018 22:14
Lab4: test262
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: |
The elements of the array are rearranged so as to reverse their order.
The object is returned as the result of the call
esid: sec-array.prototype.reverse
es5id: 15.4.4.8_A1_T1
description: Checking case when reverse is given no arguments or one argument
import Data.Aeson
import Web.HttpApiData (ToHttpApiData(..))
instance FromJSON SFId where
parseJSON = withText "Id" $ \i -> do
return $ SFId i
instance ToJSON SFId where
toJSON (SFId i) = object
[ "Id" .= i ]