Skip to content

Instantly share code, notes, and snippets.

View ellioseven's full-sized avatar

ellioseven ellioseven

View GitHub Profile
import { connect, UR } from "getstream";
import React, { ReactNode } from "react";
import {
DefaultAT,
DefaultUT,
FeedManager,
FeedProps,
SharedFeedManagers,
StreamAppProvider
} from "react-activity-feed";
@ellioseven
ellioseven / index.js
Last active February 19, 2021 09:58
cci-67
// Example: Given an array of distinct integer values, count the number of
// pairs of integers that have difference k. For example, given the array
// { 1, 7, 5, 9, 2, 12, 3} and the difference k = 2,there are four pairs with
// difference 2: (1, 3), (3, 5), (5, 7), (7, 9).
//
// A brute force algorithm is to go through the array, starting from the first
// element, and then search through the remaining elements (which will form the
// other side of the pair). For each pair, compute the difference. If the
// difference equals k, increment a counter of the difference.
//
@ellioseven
ellioseven / fb-track.js
Last active November 30, 2020 07:17
N46 FB Track
var N46CO = document.querySelector(".checkout-button")
if (N46CO && fbq) {
N46CO.addEventListener("click", function () {
var node = document.querySelector(".order-total td")
if (!node) return
var text = node.innerText.replace("$", "")
var value = Number.parseFloat(text).toFixed(2)
fbq("track", "Initiated: Checkout", { currency: "AUD", value: value })
})
}
@ellioseven
ellioseven / config.fish
Last active May 21, 2020 06:14
Fish Config
function fish_prompt
echo (id -u)": "
end
function mpw
docker run \
--rm \
-ti elliotmitchum/mpw mpw -t x -u "Elliot Mitchum" $argv
end
@ellioseven
ellioseven / install.sh
Last active May 22, 2020 00:24
Ubuntu 20.04 Provision
#!/usr/bin/env bash
set -e
set -u
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
import React from "react"
import { Query, compose, graphql } from "react-apollo"
import gql from "graphql-tag"
/**
* Config.
*/
const config = {
menu: [
import React from "react"
import { Query, compose, graphql } from "react-apollo"
import gql from "graphql-tag"
/**
* Config.
*/
const config = {
menu: [
@ellioseven
ellioseven / index.js
Created November 5, 2018 04:10
React Layout Resolver
import React from "react"
const Foo = () => {
const header = <p key="foo-header">Foo Header</p>
const main = <p key="foo-main">Foo Main</p>
const footer = <p key="foo-footer">Foo Footer</p>
return {
header: [header],
main: [main],
footer: [footer]
@ellioseven
ellioseven / binding.js
Created May 27, 2018 09:36
Simple DOM binding
const time = () => Math.round(Date.now() / 1000)
class Component {
constructor () {
this.event = new Event('update')
this.state = { m: time().toString() }
this.element = document.createElement('div')
this.element.addEventListener('update', e => {
this.element.innerHTML = this.render()
})
<h2>Maecenas nec ultrices nibh</h2>
<p>Vestibulum sed tortor non sem consectetur scelerisque at quis dolor. Etiam convallis
iaculis molestie. Cras cursus aliquam velit quis congue.</p>
<p>Aliquam semper libero ac lacus bibendum semper. Sed eu magna a ligula consectetur
auctor. Vivamus ullamcorper, elit feugiat venenatis venenatis, arcu ligula mollis diam,
a malesuada elit dui sed dui.</p>
<h2>Aenean purus enim, fringilla et ultricies</h2>
<p>Fusce convallis, velit vitae semper viverra, nibh ex sagittis tortor, eget
vestibulum nibh enim eu elit. Donec et ante elementum, mollis sapien eu, scelerisque
lacus. Vestibulum finibus convallis mauris.</p>