View sample_data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data: [ | |
{ | |
id: 1, | |
level: 1, | |
parent_id: null, | |
children: [ 4,5 ] | |
}, | |
{ | |
id: 2, |
View Registry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
// Best practice is to use prop-type declarations on all components that receive props. | |
import PropTypes from 'prop-types'; | |
import ReactDOM from 'react-dom' | |
import { connect } from 'react-redux' | |
import { Table, Button, Container, Input, Form } from 'semantic-ui-react'; | |
import RequestRegistryRow from '../components/RequestRegistryRow'; | |
import Layout from '../components/Layout'; |
View callbackhell.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post('/articles/:uuid/file', upload.array('file', 2), (req, res, next) => { | |
const session = driver.session(); | |
let images = []; | |
let captions = req.body.caption; | |
const sessionUuid = uuidV4(); | |
req.files.forEach((file, index) => { | |
images.push(Object.assign({}, { |
View server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Iterate through request files array and write each file to Neo4j | |
images.forEach(image => { | |
session.writeTransaction(tx => { | |
tx.run(`MATCH (n:Article {uuid: $uuid})-[:HAS]->(f:File) | |
MERGE (n)-[:HAS]->(i:File { | |
name: $name, | |
caption: $caption | |
}) WITH i,n SET i.uuid = $fileUuid, | |
i.url = $url, | |
i.updated_at = $updatedAt, |
View AddItem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
import React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
import { Container, Header, Left, Button, Body, Title, Right, Icon, Text } from 'native-base'; | |
import { TouchableWithoutFeedback, Keyboard, Alert } from 'react-native'; | |
import { getFormValues, isPristine, isValid } from 'redux-form'; | |
import AddItemFormContainer from '../../components/AddItemFormContainer'; | |
import * as itemsModule from '../../../../redux/modules/items'; | |
import BackButton from './components/BackButton'; | |
import SubmitButton from './components/SubmitButton'; |
View data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Top Level One", | |
"id": "topLevelOne, | |
"children": [ | |
{ | |
"name": "Stuff", | |
"id": "topLevelOne.stuff", | |
"children": [ | |
{ | |
"name": "Things", |
View convertToRoman.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//jshint esversion:6 | |
function convertToRoman(num) { | |
const UNITS = { | |
1: 'I', | |
4: 'IV', | |
5: 'V', | |
9: 'IX', | |
10: 'X', | |
40: 'XL', |
View 0_reuse_code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
View dbLinear2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function orderNum(arr, num) { | |
let i = arr.length - 2; | |
let temp; | |
if (arr[i] < num) { | |
return arr; | |
} | |
while (arr[i] > num) { | |
temp = arr[i]; |
NewerOlder