Skip to content

Instantly share code, notes, and snippets.

@joeriks
joeriks / FileAttachmentController.cs
Created September 13, 2012 12:46
Use webapi to download file as attachment (using AttributeRouting)
[RoutePrefix("files")]
public class FilesController : ApiController
{
[GET("somepdf/{id}")]
public HttpResponseMessage GetSomePdf(string id)
{
var path = MyApp.PathToSomePdf(id);
if (path!= null)
return FileAsAttachment(path, "somepdf.pdf");
@katowulf
katowulf / 1_query_timestamp.js
Last active September 21, 2023 20:28
Get only new items from Firebase
// 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());
});
@staltz
staltz / introrx.md
Last active July 19, 2024 22:21
The introduction to Reactive Programming you've been missing
@thmain
thmain / MyReactComponent.js
Last active October 15, 2022 18:58
Skeleton React Component with descriptions for all of its lifecycle methods
/**
* @jsx React.DOM
*/
var React = require('react'),
MyReactComponent = React.createClass({
// The object returned by this method sets the initial value of this.state
getInitialState: function(){
return {};

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@nfabian13
nfabian13 / MyReactComponent.js
Created May 16, 2016 20:05 — forked from thmain/MyReactComponent.js
Skeleton React Component with descriptions for all of its lifecycle methods
/**
* @jsx React.DOM
*/
var React = require('react'),
MyReactComponent = React.createClass({
// The object returned by this method sets the initial value of this.state
getInitialState: function(){
return {};
@kurtkaiser
kurtkaiser / divisionCalculator.asm
Created April 24, 2019 01:55
Simple division calculator written in MASM Assembly language for the x86 processors
; Simple Division Calculator
; Kurt Kaiser
INCLUDE Irvine32.inc
; .data is used for declaring and defining variables
.data
codeTitle BYTE " --------- Math Magic --------- ", 0
directions BYTE "Enter 2 numbers.", 0
prompt1 BYTE "First number: ", 0