Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:

Danny dannyhw

:shipit:
View GitHub Profile
@dannyhw
dannyhw / publishToMedium.js
Created Mar 30, 2022
if you put your integration token in a .env.json you can automatically post a markdown file to medium
View publishToMedium.js
#!/usr/bin/env node
const yargs = require("yargs/yargs");
const { hideBin } = require("yargs/helpers");
const { token } = require("./.env.json");
const { URL, URLSearchParams } = require("url");
const fetch = require("node-fetch");
class HTTPResponseError extends Error {
constructor(response, customMessage, ...args) {
super(
View policy
no data is stored anywhere other than on your device and it is not shared with any 3rd party or uploaded in any way
@dannyhw
dannyhw / addon_react_native_web.md
Last active Jul 5, 2022
draft document about a new react native web addon
View addon_react_native_web.md

Intro

Storybook is a UI development workshop for components and pages. It's used by many teams for all kinds of reasons. You can develop components in isolation, run visual tests and even validate the accessibility of your UI.

Storybook started off web focused and has expanded to many different platforms since then. One of those platforms is React Native.

Storybook for React Native is a catalog of all your components and states, that runs inside your iOS or Android app, on your mobile device. This is great for seeing your React Native components in their production setting, but also has some disadvantages when compared to Storybook's web UI.

That's why I'm excited to announce Storybook for React Native Web, a new complementary approach to developing and sharing React Native components in Storybook.

@dannyhw
dannyhw / setup_expo_rn_sb.sh
Last active Jun 19, 2022
React native storybook alpha v6 Expo setup
View setup_expo_rn_sb.sh
#!/bin/bash
set -e
APP_NAME=${1:-RNStorybookAlpha}
echo "APP_NAME: $APP_NAME"
npm install --global expo-cli
expo init -t expo-template-blank-typescript $APP_NAME
cd $APP_NAME
expo install @storybook/react-native@next \
@storybook/addon-ondevice-actions@next \
@dannyhw
dannyhw / setup_rn_sb.sh
Last active Sep 20, 2022
Setup a new project to test the 6.0 alpha of react native storybook
View setup_rn_sb.sh
#!/bin/bash
npx react-native init RnSBSixAlpha --template react-native-template-typescript;
cd RnSBSixAlpha;
yarn add @storybook/react-native@next \
@react-native-async-storage/async-storage \
@storybook/addon-ondevice-actions@next \
@storybook/addon-ondevice-controls@next \
@storybook/addon-ondevice-backgrounds@next \
@storybook/addon-ondevice-notes@next \
@dannyhw
dannyhw / SVGClock.js
Last active Mar 23, 2018
react native hour clock with expo using the svg component library, saving for later
View SVGClock.js
import { Svg } from "expo"
import React, { Component, Fragment } from "react"
import { View } from "react-native"
import { PropTypes } from "prop-types"
const getClockCoordinates = ({ radius, ratio }) => {
const coords = []
for (let i = 1; i <= 12; i++) {
const cx = radius
const cy = radius
@dannyhw
dannyhw / see_recent_users.rb
Last active Feb 13, 2017
Gets recent RSA key signatures from in /var/log/auth.log and matches them to RSA key comments. If comments contain the users identity you can see who has recently logged in via ssh using RSA for authentication.
View see_recent_users.rb
#!/usr/bin/env ruby
require 'set'
user_key_pairs = {}
File.open(ENV['HOME'] + '/.ssh/authorized_keys').each do |public_key|
file_name = public_key.split(' ')[2] + '.pub_key'
key_file = File.new(file_name, 'w')
key_file.puts public_key
key_file.close
key_sig_user = `ssh-keygen -l -f #{file_name}`
View download_directory_from_git.py
import base64
import os
from github import Github, GithubException
def get_sha_for_tag(repository, tag):
"""
Returns a commit PyGithub object for the specified repository and tag.
"""