Skip to content

Instantly share code, notes, and snippets.

View codenamejason's full-sized avatar
:octocat:
🫠

<jaxcoder /> codenamejason

:octocat:
🫠
View GitHub Profile
<body onLoad = "init()">
</body>
@codenamejason
codenamejason / get-api-newsfeed.js
Last active August 29, 2015 14:16
GET api/newsfeed
{
_id: {string}. The id of the newsfeed.
actor: {string}. The name of the actor (the person who performed the action).
action: {string}. The action performed (e.g. 'event::created').
object: {Object}. A JSON(P) object representing the object on which the action was performed.
@codenamejason
codenamejason / post-api-newsfeed.js
Last active August 29, 2015 14:16
POST /api/newsfeed
{
actor: {string}. Creator
action: {string}. Event
object: {Object}. JSONP
}
**add
_id: {Integer}.
- event::create. Event has been created. The object parameter contains the created event.
- event::deleted. Event has been deleted. The object parameter contains the deleted event.
- event::new. The actor has written a new post. The object parameter contains the contents of the post.
@codenamejason
codenamejason / get-api-newsfeed-by-item-id
Created March 5, 2015 21:39
GET /api.newsfeed.:item_id
Get a specific newsfeed item by id. This will return only one newsfeed item where the _id corresponds to the item_id you passed in. **use time/date stamp**
@codenamejason
codenamejason / types-of-actions.js
Last active August 29, 2015 14:16
TYPES of actions
The action parameter is in the format {object_type} : : {operation}. If you have a newsfeed item with action = event : :*, then the object parameter will contain data in the format expected of an event object type. The object types are listed below. When created a new activity, you must make sure the action corresponds with the object type.
- event
{
title: {string},
description: {String},
start: {Date},
duration: {Integer}, // duration in seconds
}
@codenamejason
codenamejason / ad_hoc.js
Created March 6, 2015 02:16
AngularJS for Loopback ad-hoc queries
$scope.products = MyProduct.find({
filter: {
where: {price: {lt: 100}},
order: 'price ASC',
limit: 3
}
});
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
/***************************************************
* Assuming you can't use priorities (e.g. they are already being used for something else)
* You can store the email addresses in an index and use that to match them to user ids
***************************************************/
var fb = new Firebase(URL);
/**
* Looks up a user id by email address and invokes callback with the id or null if not found
* @return {Object|null} the object contains the key/value hash for one user
/*
This example shows how you can use your data structure as a basis for
your Firebase security rules to implement role-based security. We store
each user by their Twitter uid, and use the following simplistic approach
for user roles:
0 - GUEST
10 - USER
20 - MODERATOR