Skip to content

Instantly share code, notes, and snippets.

@maruware
maruware / convert.ts
Last active January 19, 2022 01:28 — forked from wuchengwei/dataURL to blob and blob to dataURL
dataURL to blob and blob to dataURL
//**dataURL to blob**
function dataURLtoBlob(dataurl: string) {
const arr = dataurl.split(',')
const fmt = arr[0]
const b64 = arr[1]
if (!fmt || !b64) throw new Error('invalid dataurl')
const m = fmt.match(/:(.*?);/)
if (!m) throw new Error('invalid dataurl')
@maruware
maruware / LabeledValue.tsx
Created August 20, 2020 06:47
LabeledValue.tsx
import React from 'react'
import Typography from '@material-ui/core/Typography'
import { makeStyles, createStyles } from '@material-ui/core/styles'
import { grey } from '@material-ui/core/colors'
const useStyles = makeStyles((theme) =>
createStyles({
label: {
fontSize: 14,
@maruware
maruware / aws-env.json
Created July 29, 2020 12:18
vscode aws env
{
"AWS Env": {
"prefix": "aws-env",
"body": [
"export AWS_ACCESS_KEY_ID=$1",
"export AWS_SECRET_ACCESS_KEY=$2",
"export AWS_DEFAULT_REGION=$3"
],
"description": "AWS Env"
}
@maruware
maruware / memo.md
Created March 23, 2020 09:36
gstreamer RTP

H264

Receiver

gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,framerate=25/1 ! videoconvert ! x264enc ! h264parse ! rtph264pay pt=96 ! udpsink host=127.0.0.1 port=5000

Sender

@maruware
maruware / hoge.service
Created March 11, 2020 11:49
systemd service example
[Unit]
Description=some-service
After=network.target
[Service]
WorkingDirectory=/your/directory
Environment=NODE_ENV=production
Environment=REDIS_HOST=localhost
ExecStart=/usr/bin/node index.js
Restart=always
@maruware
maruware / install.sh
Created February 12, 2020 02:37
gstreamer installation on ubuntu
sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
# dev
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
@maruware
maruware / gen_tls.sh
Last active March 23, 2020 06:44
Generate TSL certificate
#!/bin/bash
CN=${CN:-example.com}
NAME=${NAME:-example}
DST=${DST:-.}
echo "CN=$CN, NAME=$NAME, DST=$DST"
openssl req -nodes -newkey rsa:2048 -subj "/CN=$CN/O=$NAME" \
-keyout $DST/$NAME.key -out $DST/$NAME.csr && \
@maruware
maruware / PaginateGrid.tsx
Created January 15, 2020 07:48
Paginate query with dx-react-grid
import React, { useState, useEffect } from 'react'
import {
PagingState,
SortingState,
CustomPaging,
Sorting
} from '@devexpress/dx-react-grid'
import {
Grid,
GridProps,
@maruware
maruware / error.go
Created January 9, 2020 10:36
Go http error handle
package controllers
import (
"fmt"
"net/http"
r "github.com/unrolled/render"
)
type ErrorResponse struct {
@maruware
maruware / ColorRectRadio.tsx
Created December 27, 2019 09:45
Material UI ColorRectRadio (for color palette)
import React from 'react'
import clsx from 'clsx'
import Radio, { RadioProps } from '@material-ui/core/Radio'
import { makeStyles, createStyles } from '@material-ui/core/styles'
const useStylesRect = makeStyles(theme =>
createStyles({
root: {
padding: 2,
display: 'flex',