Skip to content

Instantly share code, notes, and snippets.

@rosem
rosem / ListSortingViewController.m
Last active October 9, 2015 16:54
Instrument view controller. Handles logic to control views (UI) and record the user's response (via bluetooth keyboard). Next item is then requested from the engine.
//
// ListSortingViewController.m
// mss-cognition
//
// Created by Mike Rose on 11/22/14.
// Copyright (c) 2014 Northwestern University. All rights reserved.
//
#import "ListSortingViewController.h"
@rosem
rosem / StaticVisionViewController.m
Last active October 9, 2015 16:54
Instrument view controller. Handles logic to control views (UI) and record the user's response (via bluetooth keyboard). Next item is then requested from the engine.
//
// StaticVisionViewController.m
// tbx_Sensation
//
// Created by Mike Rose on 4/8/15.
// Copyright (c) 2015 Mike Rose. All rights reserved.
//
#import "StaticVisionViewController.h"
//
// MSSGatedSequenceEngine.m
// tbx_Sensation2
//
// Created by Mike Rose on 7/6/15.
// Copyright (c) 2015 Mike Rose. All rights reserved.
//
/*
def geolocated
address_point = origin = [params[:lat].to_f, params[:lng].to_f]
if params[:ne] && params[:sw]
sw_lat, sw_lng = params[:sw].split(/,/)
ne_lat, ne_lng = params[:ne].split(/,/)
bounds = GeoKit::Bounds.new(GeoKit::LatLng.new(sw_lat,sw_lng),GeoKit::LatLng.new(ne_lat,ne_lng))
current_user.update_region(bounds)
# use the center of the search region for distance calculation
address_point = origin = bounds.center
def geolocated
address_point = origin = [params[:lat].to_f, params[:lng].to_f]
if params[:ne] && params[:sw]
sw_lat, sw_lng = params[:sw].split(/,/)
ne_lat, ne_lng = params[:ne].split(/,/)
bounds = Geokit::Bounds.new(Geokit::LatLng.new(sw_lat,sw_lng),Geokit::LatLng.new(ne_lat,ne_lng))
current_user.update_region(bounds)
# use the center of the search region for distance calculation
address_point = origin = bounds.center
User-Agent: Mapchat* 2.0 rev:197 (iPhone; iOS 11.2; en_US)
^[[1m^[[36m (0.1ms)^[[0m ^[[1mBEGIN^[[0m
^[[1m^[[35mUser Exists (0.2ms)^[[0m SELECT 1 AS one FROM "users" WHERE ("users"."uuid" = '6092AA9E-E11E-48F4-B189-FCF6D1F487FF' AND "users"."id" != 26) LIMIT 1
^[[1m^[[36m (0.3ms)^[[0m ^[[1mUPDATE "users" SET "ne_lat" = 38.368435, "ne_lng" = -121.911602, "sw_lat" = 37.454332, "sw_lng" = -122.695866, "updated_at" = '2018-03-05 23:22:51.713157' WHERE "users"."id" = 26^[[0m
[paperclip] Saving attachments.
^[[1m^[[35m (0.6ms)^[[0m COMMIT
^[[1m^[[36mRoom Load (0.6ms)^[[0m ^[[1mSELECT "rooms".* FROM "rooms" WHERE ("rooms"."deleted_at" IS NULL) AND (rooms.lat>37.454332 AND rooms.lat<38.368435 AND rooms.lng>-122.695866 AND rooms.lng<-121.911602) AND (private = 'f') AND (rooms.archived_at IS NULL AND (rooms.active_since IS NULL OR rooms.active_since <= '2018-03-05 23:22:51')) LIMIT 50^[[0m
^[[1m^[[35mMessage Load (0.8ms)^[[0m SELECT id, content, created_at, user_id, room_id, photo_file_name, photo_upda
Started POST "/rooms/geolocated.xml" for 174.230.18.33 at 2018-03-05 18:32:57 -0500
Processing by RoomsController#geolocated as XML
Parameters: {"ne"=>"38.162181,-121.881439", "res"=>"high", "sw"=>"37.057131,-122.825671"}
^[[1m^[[36mUser Load (0.6ms)^[[0m ^[[1mSELECT "users".* FROM "users" WHERE "users"."authentication_token" = 'SurFrddosuQcXV5ct7d4' AND ("users"."deleted_at" IS NULL) LIMIT 1^[[0m
User: 382b4b34
User-Agent: Mapchat* 2.0 rev:197 (iPhone; iOS 11.2; en_US)
^[[1m^[[35m (0.1ms)^[[0m BEGIN
^[[1m^[[36mUser Exists (0.2ms)^[[0m ^[[1mSELECT 1 AS one FROM "users" WHERE ("users"."uuid" = '6092AA9E-E11E-48F4-B189-FCF6D1F487FF' AND "users"."id" != 26) LIMIT 1^[[0m
^[[1m^[[35m (0.3ms)^[[0m UPDATE "users" SET "ne_lat" = 38.162181, "ne_lng" = -121.881439, "sw_lat" = 37.057131, "sw_lng" = -122.825671, "updated_at" = '2018-03-05 23:32:57.764121' WHERE "users"."id" = 26
[paperclip] Saving attachments.
Started POST "/rooms/geolocated.xml" for 174.230.18.33 at 2018-03-05 18:54:02 -0500
Processing by RoomsController#geolocated as XML
Parameters: {"ne"=>"38.364919,-121.857899", "res"=>"high", "sw"=>"37.036102,-122.994726"}
^[[1m^[[35mUser Load (0.6ms)^[[0m SELECT "users".* FROM "users" WHERE "users"."authentication_token" = 'SurFrddosuQcXV5ct7d4' AND ("users"."deleted_at" IS NULL) LIMIT 1
User: 382b4b34
User-Agent: Mapchat* 2.0 rev:197 (iPhone; iOS 11.2; en_US)
^[[1m^[[36m (0.1ms)^[[0m ^[[1mBEGIN^[[0m
^[[1m^[[35mUser Exists (0.2ms)^[[0m SELECT 1 AS one FROM "users" WHERE ("users"."uuid" = '6092AA9E-E11E-48F4-B189-FCF6D1F487FF' AND "users"."id" != 26) LIMIT 1
^[[1m^[[36m (0.3ms)^[[0m ^[[1mUPDATE "users" SET "ne_lat" = 38.364919, "ne_lng" = -121.857899, "sw_lat" = 37.036102, "sw_lng" = -122.994726, "updated_at" = '2018-03-05 23:54:03.001998' WHERE "users"."id" = 26^[[0m
[paperclip] Saving attachments.
def notify_room(room, sender)
alert = "#{sender.pseudo} created #{room.title} nearby"
notifyees = User.within(prefered_distance, :origin => [room.lat, room.lng]).where(["prefered_distance is not null and lat is not null and lng is not null and id != ?", sender.id])
#notifyees = User.geo_scope(:origin => [room.lat, room.lng]).where(["#{User.distance_sql(Geokit::LatLng.new(room.lat, room.lng))} < prefered_distance and prefered_distance is not null and lat is not null and lng is not null and id != ?", sender.id])
# select users who haven't blocked the room owner
notifyees = notifyees.where('users.id not in (select user_id from blocked_users where blocked_users.blocked_id = ?)', room.user_id)
if !Room.with_deleted.find(room.id).deleted_at.nil?
class EventsController < APIController
# GET /events.xml
def index
@events = current_user.events.one_per_user.non_blocked(current_user.id)
if client_build_number < 171
@events = @events.where("event_type = 'create'")
end
@events = @events.order("max(events.created_at) DESC").limit(25)