Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Set status

Wildan Zulfikar wzulfikar

💭
Set status
View GitHub Profile
@kentcdodds
kentcdodds / package.json
Last active Mar 4, 2021
Validates that the versions of tools specified in `engines` in the package.json are installed on the machine.
View package.json
{
"name": "workshop-computer-validator",
"version": "1.0.0",
"description": "I use this to validate people's computers have the proper versions of node and npm installed for a workshop",
"bin": "./validate-system.js",
"dependencies": {
"semver": "7.1.3"
}
}
@derindutz
derindutz / use-persistent-swr.ts
Last active Jan 29, 2021
useSWR with localforage as a persistent cache
View use-persistent-swr.ts
import useSWR from '@zeit/swr';
import localForage from 'localforage';
import { ConfigInterface } from '@zeit/swr/dist/src/types';
import { useState, useEffect } from 'react';
export function usePersistentSWR(key: string, fn?: Function, config?: ConfigInterface) {
let handleSuccess;
if (config !== undefined && config.onSuccess !== undefined) {
const { onSuccess } = config;
handleSuccess = (data: any, key: string, config: ConfigInterface) => {
@mfellner
mfellner / graphql.ts
Created Jul 8, 2019
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
View graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@chibicode
chibicode / README-Twemoji-React.md
Last active Mar 2, 2021
A dead simple React.js Twemoji component.
View README-Twemoji-React.md

Twemoji + React

A dead simple React Twemoji component.

Requirements: twemoji

npm install --save twemoji
@baymac
baymac / Form.gs
Created Jan 1, 2019
App Script to send the response from Google Form to Firebase
View Form.gs
function onFormSubmit(e) {
var form = FormApp.openById('1Z65umQSZ2drz3MvTWCWlwP4-ySeoB5D7RvX1LtusnEU');
var formResponses = form.getResponses();
var latestResponse = formResponses.length - 1;
var formResponse = formResponses[latestResponse];
var email = formResponse.getRespondentEmail();
var items = formResponse.getItemResponses();
View gimme.sh
#!/bin/bash
for file in $(./ipfs refs local);
do
if ! [[ $(./ipfs cat "$file" 2>&1 >/dev/null | grep 'Error') ]] ; then
if ! [[ $(./ipfs cat "$file" | file - | grep ': data') ]] ; then
printf "=== LOCAL FILE FOUND ===\n\n"
echo $file
./ipfs cat "$file" | file -
printf "\n\n"
View pprof.md

pprof

With a single import _ "net/http/pprof" you can add profiling endpoints to a HTTP server.

package main

import (
	"fmt"
@mholt
mholt / macapp.go
Created May 18, 2018
Distribute your Go program (or any single binary) as a native macOS application
View macapp.go
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@aurorabbit
aurorabbit / progress.10s.sh
Last active Aug 5, 2020
Bitbar timely progress bar
View progress.10s.sh
#!/bin/sh
# add this to your bitbar directory
# don't forget to chmod +x
# width and characters for the progress bars
# feel free to configure these
width=30
fill_char=""
empty_char=""
@magjac
magjac / README.md
Last active Jan 27, 2021
D3 Graphviz GUI editor proof-of-concept
View README.md

This is a proof-of-concept of a graphical editor that allows you to to edit a Graphviz graph graphically, by drawing edges between nodes and inserting new nodes by using the mouse only. It also allows you to edit the textual DOT language description and directly see the graph transform itself into a new layout in an animated transition.

The GUI editor is perfectly usable as it is, but it has some simplifications that needs to be addressed in a production quality application in order not to hamper productivity:

  • Draws only the standard type edge with alternating colors, although you can edit all aspects of it with the text editor afterwards and see the changes directly.
  • Draws only two kinds of node shapes, alternating between ellipse and polygon and different colors and using predefined names. Also this can of course be changed with the text editor.

Help is available by clicking the question mark in the top right corner.

This sma