Skip to content

Instantly share code, notes, and snippets.

View sirdlx's full-sized avatar

Sir Charles White sirdlx

View GitHub Profile
@sirdlx
sirdlx / formatBytesText.js
Created June 9, 2016 20:37
format bytes to text: 243.6 BG
let bytesText = function formatBytesText(bytes) {
if(bytes < 1024) return bytes + " Bytes";
else if(bytes < 1048576) return(bytes / 1024).toFixed(2) + " KB";
else if(bytes < 1073741824) return(bytes / 1048576).toFixed(2) + " MB";
else return(bytes / 1073741824).toFixed(2) + " GB";
};
@sirdlx
sirdlx / cloudSettings
Last active October 12, 2016 18:39
Visual Code Sync Settings
{"lastUpload":"2016-10-12T18:39:35.964Z"}
@sirdlx
sirdlx / square.js
Created February 1, 2017 03:13
Node server for help with squareup.
"use strict";
var decimalOnly = /^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;
var cleanText = (function (textin) {
return textin.replace(/[^\w-]/g, '').toLowerCase();
});
var express = require('express');
var router = express.Router();
var request = require("request");
var squareBaseURLv1 = "https://connect.squareup.com/v1/";
var squareBaseURLv2 = "https://connect.squareup.com/v2/";
@sirdlx
sirdlx / index.android.js
Created March 19, 2017 22:53
Alternative to react-navigation's replace action
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React from 'react';
import {
AppRegistry,
StyleSheet,
class StorageDriver {
constructor (conf = {}) {
this.conf = conf
if (
typeof this.conf.storage.getItem !== 'function' ||
typeof this.conf.storage.removeItem !== 'function' ||
typeof this.conf.storage.setItem !== 'function'
) {
throw new Error('Given Storage doesn\'t have methods `getItem`, `setItem` and `removeItem`.')