Skip to content

Instantly share code, notes, and snippets.

William Bowers willurd

Block or report user

Report or block willurd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rust-play
rust-play / playground.rs
Created Jul 25, 2018
Code shared from the Rust Playground
View playground.rs
trait Json {
fn to_string(&self) -> String;
}
trait Xml {
fn to_string(&self) -> String;
}
#[derive(Debug)]
struct Point2 {
@sararob
sararob / data-structure.js
Last active Aug 3, 2019
Role-based security in Firebase
View data-structure.js
/*
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
@raganwald
raganwald / record.js
Last active Aug 29, 2015
Records, Values, and Structs
View record.js
function Record (template) {
if (Record.prototype.isPrototypeOf(this)) {
var struct = this;
Object.keys(template).forEach(function (key) {
Object.defineProperty(struct, key, {
enumerable: true,
writable: true,
value: template[key]
});
View overload.js
var __slice = [].slice;
var __noop = function(){};
function typeOf(x) {
return {}.toString.call(x).slice(8,-1);
}
function overload(fs) {
return function() {
var types = __slice.call(arguments).map(typeOf);
@debasishg
debasishg / gist:8172796
Last active Nov 18, 2019
A collection of links for streaming algorithms and data structures
View gist:8172796
  1. General Background and Overview
@ahmedelgabri
ahmedelgabri / gist:8122545
Last active Oct 17, 2018
Shell function to open a static server (Python, Ruby or PHP)
View gist:8122545

Static server shell function

A Modified function of Paul Irish's StaticServer shell function, according to this gist You can run static servers for many languages.

How it works

$ staticServer <lang> <port> #port is optional, default is 8000
@katowulf
katowulf / 1_using_queries.js
Last active Mar 11, 2019
Methods to search for user accounts by email address in Firebase
View 1_using_queries.js
/***************************************************
* Simple and elegant, no code complexity
* Disadvantages: Requires warming all data into server memory (could take a long time for MBs of data or millions of records)
* (This disadvantage should go away as we add optimizations to the core product)
***************************************************/
var fb = firebase.database.ref();
/**
* @param {string} emailAddress
@katowulf
katowulf / 1_query_timestamp.js
Last active Nov 19, 2019
Get only new items from Firebase
View 1_query_timestamp.js
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active Nov 18, 2019
A badass list of frontend development resources I collected over time.
View frontendDevlopmentBookmarks.md
@anantn
anantn / firebase_first_item.js
Last active Mar 4, 2016
Firebase: Get the first item in a list. This snippet retrieves only the first item in a list.
View firebase_first_item.js
function makeList(ref) {
var fruits = ["banana", "apple", "grape", "orange"];
for (var i = 0; i < fruits.length; i++) {
ref.push(fruits[i]);
}
}
function getFirstFromList(ref, cb) {
ref.startAt().limit(1).once("child_added", function(snapshot) {
cb(snapshot.val());
You can’t perform that action at this time.