Skip to content

Instantly share code, notes, and snippets.

View MarkMurphy's full-sized avatar
:octocat:

Mark Murphy MarkMurphy

:octocat:
View GitHub Profile
import React, { Component } from 'react'
import { View, Text } from 'react-native'
import Tabs from './Tabs'
import Tab from './Tabs/Tab'
export default class ExamplePage extends Component {
state = {
selectedTab: 1
}
@MarkMurphy
MarkMurphy / ListViewDemo.js
Created January 23, 2017 15:20
React Native Web - ListViewDemo
import React, { Component } from 'react';
import { ListView, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 20,
},
row: {
padding: '10px'
@MarkMurphy
MarkMurphy / README.md
Last active February 5, 2024 19:59
Cursor based pagination for Rails models.

Example Usage

Users

id name
1 Jane
2 Max
3 John
4 Scott
@MarkMurphy
MarkMurphy / README.md
Last active August 7, 2016 10:02
Multipart Upload API

Endpoints for uploading large files in multiple chunks. Also has the ability to resume if the upload is interrupted.

Typical usage:

  1. Send a POST request to /files with the first chunk of the file and receive an upload id in return.
  2. Repeatedly PATCH subsequent chunks using the upload id to identify the upload in progress and an offset representing the number of bytes transferred so far.
  3. After each chunk has been uploaded, the server returns a new offset representing the total amount transferred.
  4. After the last chunk commit the upload by passing its id to another endpoint such as POST /videos, POST /audio, etc.

Example:

@MarkMurphy
MarkMurphy / AlbumPage.js
Last active May 24, 2016 13:47
redux-crud pagination
// containers/AlbumPage.js
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { browserHistory } from 'react-router'
import { fetchAlbum, deleteAlbum } from '../actions/albums'
import { listPhotos } from '../actions/photos'
import bindAll from 'lodash/bindAll'
import AlbumHeader from '../components/AlbumHeader'
import PhotoGallery from '../components/PhotoGallery'
@MarkMurphy
MarkMurphy / README.md
Last active March 25, 2022 21:47
ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps with Rails / MySQL

ActiveRecord: Store Milliseconds (or Microseconds) in DateTimes or Timestamps with Rails / MySQL

Milliseconds in your DateTimes or Timestamps.

We got 'em, you want 'em.

NOTE: only MySQL 5.6.4 and above supports DATETIME's with more precision than a second. For reference see MySQL 5.6.4 Changelog

Why

Shit needs to be PRECISE

@MarkMurphy
MarkMurphy / README.md
Last active January 11, 2024 01:04
Rails resumable uploads

Uploads large files in multiple chunks. Also has the ability to resume if the upload is interrupted.

Typical usage:

  1. Send a POST request to /upload with the first chunk of the file and receive an upload id in return.
  2. Repeatedly PATCH subsequent chunks using the upload id to identify the upload in progress and an offset representing the number of bytes transferred so far.
  3. After each chunk has been uploaded, the server returns a new offset representing the total amount transferred.
  4. After the last chunk commit the upload by passing its id to another endpoint such as POST /upload/commit/:id: