Skip to content

Instantly share code, notes, and snippets.

Twitter Example With Firebase

A famo.us example app. Showcases our javascript powered infinite scrollview, and multiple pages. All data is sent over firebase.

A Pen by Brian C on CodePen.

License.

var Transform = require('famous/core/Transform');
function ShowModifier(options) {
this.visible = !!options.visible;
this._output = {
transform: Transform.identity,
opacity: 1,
origin: null,
align: null,
size: null,
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]
@akotlov
akotlov / ex1-prototype-style.js
Created October 27, 2015 19:57 — forked from getify/ex1-prototype-style.js
OLOO (objects linked to other objects) pattern explored (with comparison to the prototype style of the same code)
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,"Bar:" + who);
@akotlov
akotlov / EachDirectoryPath.md
Created May 4, 2016 11:31 — forked from granoeste/EachDirectoryPath.md
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@akotlov
akotlov / Date Range Mongo Query
Created July 31, 2016 20:40 — forked from guilleferrer/Date Range Mongo Query
Query for a date range using Mongo Timestamps
db.Collection.find({
created_at : {
'$gte': new Timestamp(new Date(2012, 0, 21), 0),
'$lte': new Timestamp(new Date(2012, 0, 22), 0)
})
@akotlov
akotlov / Iframe.js
Created July 18, 2017 20:46 — forked from msmfsd/Iframe.js
React iframe component
/*
INIT: ensure Babel/Eslint/Flow is configured for ES Class Fields & Static Properties
JSX USAGE: <Iframe src='http://web.site' onLoad={myOnloadFunction}/>
*/
import React, { Component, PropTypes } from 'react'
import ReactDOM from 'react-dom'
class Iframe extends Component {
static propTypes: Object = {
@akotlov
akotlov / gist:3ae1093971b285dfe7d5134408fbdfab
Created July 25, 2017 07:58 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@akotlov
akotlov / check.js
Created July 28, 2017 19:25
Check if downloading a file larger then a limit.
var maxSize = 10485760;
request({
url: url,
method: "HEAD"
}, function(err, headRes) {
var size = headRes.headers['content-length'];
if (size > maxSize) {
console.log('Resource size exceeds limit (' + size + ')');
} else {
@akotlov
akotlov / BytesToSize.js
Created August 6, 2017 18:46
javascript convert bytes to size
function bytesToSize(bytes) {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
if (bytes === 0) return 'n/a'
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10)
if (i === 0) return `${bytes} ${sizes[i]})`
return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`
}