Skip to content

Instantly share code, notes, and snippets.

View rossnelson's full-sized avatar
💀

Ross Nelson rossnelson

💀
View GitHub Profile
package something
import (
"encoding/json"
"strconv"
)
type SomeData struct {
SomeSlice []int `json:"some_slice"`
}
package intervals
var names = map[string]string{
"daily": "daily",
"weekly": "weekly",
"monthly": "monthly",
"yearly": "yearly",
}
var singular = map[string]string{
@rossnelson
rossnelson / screen-enter.js
Created January 25, 2024 03:58
forever-scroll
import { createRef, useEffect, useState } from 'react';
export function useScreenEnter(callback) {
const scrollRef = createRef();
const loaderRef = createRef();
const [more, hasMore] = useState(true);
function activate() {
if (
@rossnelson
rossnelson / use-debounce.ts
Created January 21, 2024 18:29
Debounce in react
import { useCallback } from 'react';
import debounce from 'lodash.debounce';
export function useDebounce(fn: () => void, delay: number) {
const debouncer = debounce(fn, delay);
const start = useCallback(() => {
debouncer();
}, [debouncer]);
@rossnelson
rossnelson / base-model.ts
Last active January 18, 2024 19:48
Proxy model allowing helpers tied to data objects
import _ from 'lodash';
import { DateTime } from 'luxon';
import moment from 'moment-timezone';
class Base<T> {
params: T;
constructor(params: T) {
this.params = params;
}
import Session from 'lib/session';
const store = {
state: Session.account ? Session.account : null,
reducers: {
setAccount(state, account) {
return account;
}
}
@rossnelson
rossnelson / store.jsx
Created July 22, 2023 00:48
React Context Api Abstraction
import React, { createContext, useContext, useReducer } from 'react';
import Log from 'lib/log';
import _ from 'lodash';
import stores from './stores';
const store = createContext(stores.state);
const { Provider } = store;
const StateProvider = ({ children }) => {

Keybase proof

I hereby claim:

  • I am rossnelson on github.
  • I am rossnelson (https://keybase.io/rossnelson) on keybase.
  • I have a public key ASDwEIAenmga0BCj6sYqj1O0zS55CCd9fbU0LQ0Hu_piZQo

To claim this, I am signing this object:

package process
import (
"encoding/json"
"fmt"
"github.com/simiancreative/simiango/logger"
)
var processors map[KindID]Processor
const repl = require('repl');
const { Driver } = require("zwave-js");
const networkKey = Buffer.from(process.env.HAB_DEVICE_ID.replace(/-/g, '')
.split('')
.slice(1, 17));
// Tell the driver which serial port to use
const driver = new Driver("/dev/zwaveAeotec", {