Skip to content

Instantly share code, notes, and snippets.

Andrew Hlavats andrewhl

  • Toronto
Block or report user

Report or block andrewhl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sample_data.js
export default {
data: [
{
id: 1,
level: 1,
parent_id: null,
children: [ 4,5 ]
},
{
id: 2,
View Registry.js
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 ReorderMenu.js
renderMenuItems() {
let i = 0;
return this.props.sections.map((section, index) => {
i ++;
return [
<MenuItemTarget
onDrop={this.handleDrop}
position={index - 1}
key={i * 100}
View callbackhell.js
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
// 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
/* @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
{
"name": "Top Level One",
"id": "topLevelOne,
"children": [
{
"name": "Stuff",
"id": "topLevelOne.stuff",
"children": [
{
"name": "Things",
View convertToRoman.js
//jshint esversion:6
function convertToRoman(num) {
const UNITS = {
1: 'I',
4: 'IV',
5: 'V',
9: 'IX',
10: 'X',
40: 'XL',
@andrewhl
andrewhl / 0_reuse_code.js
Created Mar 27, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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
function orderNum(arr, num) {
let i = arr.length - 2;
let temp;
if (arr[i] < num) {
return arr;
}
while (arr[i] > num) {
temp = arr[i];
You can’t perform that action at this time.