Skip to content

Instantly share code, notes, and snippets.

View DAB0mB's full-sized avatar
♥️
Single af

Eytan Manor DAB0mB

♥️
Single af
View GitHub Profile
@DAB0mB
DAB0mB / flatten_deep.js
Created December 31, 2017 06:30
A JavaScript function to flat an array recursively
function flattenDeep(array) {
if (!(array instanceof Array)) {
return array;
}
return array.reduce((flatArray, cell) => {
return flatArray.concat(flattenDeep(cell));
}, []);
}
@DAB0mB
DAB0mB / ConsultFormController.js
Created August 28, 2018 04:33
A sample controller for an Appfairy view
import React from 'react'
import ConsultFormView from '../views/ConsultFormView'
class ConsultFormController extends React.Component {
state = {}
render() {
return (
<ConsultFormView>
<name onChange={this.setName} />
@DAB0mB
DAB0mB / git-remove.js
Last active September 3, 2018 10:06
usage: $ ./git-remove.js <anchor> <amount>
#!/usr/bin/env node
const execa = require('execa')
const fs = require('fs')
const tmp = require('tmp')
// Main
{
const [anchor, amount = 1] = process.argv.slice(-2).map(Number)
gitRebaseInteractive(anchor, function (operations, amount) {
const { spawn } = require('child_process')
spawn('git', ['log'])
const { spawn } = require('child_process')
spawn('git', ['log']).stdout.pipe(process.stdout)
const { spawn } = require('child_process')
spawn('git', ['log'], {
stdio: 'inherit' // Will use process .stdout, .stdin, .stderr
})
const { execFile } = require('child_process')
execFile('git', ['log'], (err, out) => {
if (err) {
console.error(err)
}
else {
console.log(out)
}
})
import { DocumentNode, GraphQLError } from 'graphql'
import { OperationVariables, FetchPolicy } from 'apollo-client'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useApolloClient } from 'react-apollo-hooks'
import * as isEqual from 'react-fast-compare'
export type SubscriptionOptions<TVariables> = {
variables?: TVariables;
fetchPolicy?: FetchPolicy;
}
function observerCallback (mutations, observer) {
// Will cause more mutations
updateStyle(mutations)
// Will dispose pending mutations
observer.takeRecords()
}
@DAB0mB
DAB0mB / git_squence_editor.sh
Last active March 18, 2020 09:30
git_squence_editor.sh
git_sequence_editor () {
if test -z "$GIT_SEQUENCE_EDITOR"
then
GIT_SEQUENCE_EDITOR="$(git config sequence.editor)"
if [ -z "$GIT_SEQUENCE_EDITOR" ]
then
GIT_SEQUENCE_EDITOR="$(git var GIT_EDITOR)" || return $?
fi
fi