Skip to content

Instantly share code, notes, and snippets.

View bobwei's full-sized avatar

Bob Wei bobwei

View GitHub Profile
@eyecatchup
eyecatchup / calc-sapisidhash.js
Last active November 14, 2024 10:23
Calculate SAPISIDHASH
// Generates the SAPISIDHASH token Google uses in the Authorization header of some API requests
async function getSApiSidHash(SAPISID, origin) {
function sha1(str) {
return window.crypto.subtle.digest("SHA-1", new TextEncoder("utf-8").encode(str)).then(buf => {
return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join('');
});
}
const TIMESTAMP_MS = Date.now();
const digest = await sha1(`${TIMESTAMP_MS} ${SAPISID} ${origin}`);
@fakenickels
fakenickels / metro.config.js
Last active December 22, 2019 04:54 — forked from sibelius/metro.config.js
metro config to work with yarn workspaces
const path = require('path');
const getWorkspaces = require('get-yarn-workspaces');
const blacklist = require('metro-config/src/defaults/blacklist');
const workspaces = getWorkspaces(__dirname);
// Blacklists any react-native that doesn't come from packages/app
const blacklistRE = blacklist([ /(?<!packages\/app\/)node_modules\/react-native\/.*/g])
import React, { useEffect, useState, useRef } from "react";
import {
SpeechRecogintionResult,
createSpeechRecognition,
createMediaRecorder,
SpeechRecord
} from "./utils";
let currentSpeechRecognition: any | null = null;
let currentMediaRecorder: any | null = null;
@okeehou
okeehou / outline-server-setup.md
Last active November 13, 2024 04:51
How to setup an Outline VPN Server on Ubuntu 16.04

How to setup an Outline VPN Server on Ubuntu 16.04 Server

This guide will show you how to install Outline Server on an Ubuntu 16.04 Server, use Outline Manager for Windows and connect to your Outline Server on Windows and Anroid.

Install Outline Manager

Outline Manager supports Windows, macOS and Linux.

Outline Manager for Windows

@erikyuntantyo
erikyuntantyo / react-native-offline-bundling-android
Last active October 29, 2023 06:36
Build react-native offline bundling into android
# create assets folder in the current project
$ mkdir android/app/src/main/assets
# create bundle script
$ react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
# execute command to run android to create debug apk
$ react-native run-android
# Or change to android folder
@kutyel
kutyel / curry.js
Last active August 5, 2019 20:51
My own implementation of curry 🍛
// Ultimate version
const curry = (f, ...args) =>
f.length <= args.length
? f(...args)
: x => curry(f, ...args, x)
@learncodeacademy
learncodeacademy / .drone.yml
Created June 28, 2017 16:28
Rancher Drone CD Pipeline Setup
pipeline:
slack:
image: plugins/slack
webhook: <your slack webhook url>
channel: deployments
username: drone
template: "<{{build.link}}|Deployment #{{build.number}} started> on <http://github.com/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> by {{build.author}}"
when:
branch: [ master, staging ]
build:
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active November 15, 2024 13:32
React Native Bridging Cheatsheet
@uorat
uorat / nginx-websocket-proxy.conf
Last active September 26, 2024 15:57
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
@wuct
wuct / AuthorizationHOC.js
Created December 22, 2015 06:22
An authorization high-order-component using recompose, redux and react-router.
import { emptyObject } from 'fbjs/lib/emptyObject';
import { connect } from 'react-redux';
import { pushState } from 'redux-router';
import pure from 'recompose/pure';
import defaultProps from 'recompose/defaultProps';
import doOnReceiveProps from 'recompose/doOnReceiveProps';
import renderNothing from 'recompose/renderNothing';
import renderComponent from 'recompose/renderComponent';
import branch from 'recompose/branch';
import compose from 'recompose/compose';