Skip to content

Instantly share code, notes, and snippets.

Avatar
⁉️

Christoph Michel MrToph

⁉️
View GitHub Profile
View eosjs-name.ts
// Originally from https://raw.githubusercontent.com/EOSIO/eosjs/v16.0.9/src/format.js
// eosjs2 does not have this function
import Long from 'long';
function bytesToHex(bytes) {
let leHex = '';
for (const b of bytes) {
const n = Number(b).toString(16);
leHex += (n.length === 1 ? '0' : '') + n;
}
@MrToph
MrToph / Axis.js
Created Jun 21, 2017
Charts in React Native with React-Native-SVG and D3.js
View Axis.js
import React, { Component, PropTypes } from 'react'
import { G, Line, Path, Rect, Text } from 'react-native-svg'
import * as d3scale from 'd3-scale'
import { dateToShortString } from '../utils'
export default class Axis extends Component {
static propTypes = {
width: PropTypes.number.isRequired,
ticks: PropTypes.number.isRequired,
x: PropTypes.number,
@MrToph
MrToph / google-drive.js
Last active May 14, 2020
Google Drive API v3 fetch
View google-drive.js
import GoogleSignIn from 'react-native-google-sign-in'
const url = 'https://www.googleapis.com/drive/v3'
const uploadUrl = 'https://www.googleapis.com/upload/drive/v3'
const boundaryString = 'foo_bar_baz' // can be anything unique, needed for multipart upload https://developers.google.com/drive/v3/web/multipart-upload
let apiToken = null
View DatePickerRN.js
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View how-to-use-d3js-in-react-1.js
d3.csv('data.csv', (err, data) => {
if (err) {
console.log(err)
return
}
ReactDOM.render(
<App width={960} height={640} data={data} />,
document.getElementById('root'),
)
})
View React-Native-SVG Axis
import React, { Component, PropTypes } from 'react'
import { G, Line, Text } from 'react-native-svg'
import * as d3scale from 'd3-scale'
export default class Axis extends Component {
static propTypes = {
width: PropTypes.number.isRequired,
ticks: PropTypes.number.isRequired,
x: PropTypes.number,
y: PropTypes.number,
View MorePopupMenu.js
import React, { Component, PropTypes } from 'react'
import { View, UIManager, findNodeHandle, TouchableOpacity } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialIcons'
const ICON_SIZE = 24
export default class PopupMenu extends Component {
static propTypes = {
// array of strings, will be list items of Menu
actions: PropTypes.arrayOf(PropTypes.string).isRequired,
View PeanoCurve.js
import Curve from './Curve';
export default class PeanoCurve extends Curve {
createData (recLevel) {
this.points = [];
this.recLevel = recLevel;
if (recLevel <= 0) return;
// maxSize is used for rescaling point coordinates to [0,1]
this.maxSize = Math.pow(3, recLevel) - 1; // 3^recLevel - 1 will be the max coordinate of the data.
this.createDataRecursive(0, 0, Math.pow(3, recLevel), 0, 0);
return this.points;
View HilbertCurve.js
import Curve from './Curve';
export default class HilbertCurve extends Curve {
constructor () {
super();
}
createData (recLevel) {
this.points = [];
this.recLevel = recLevel;
if(recLevel <= 0) return;
You can’t perform that action at this time.