Skip to content

Instantly share code, notes, and snippets.

View drejohnson's full-sized avatar

DeAndre Johnson drejohnson

View GitHub Profile
@drejohnson
drejohnson / ResizeObserver.d.ts
Created July 5, 2018 18:51 — forked from strothj/LICENSE
ResizeObserver TypeScript definition
interface Window {
ResizeObserver: ResizeObserver;
}
/**
* The ResizeObserver interface is used to observe changes to Element's content
* rect.
*
* It is modeled after MutationObserver and IntersectionObserver.
*/
@drejohnson
drejohnson / Index.re
Last active June 30, 2020 21:03
basic reasonml binding for lit-html. WIP
/* Works but props not added to values array */
let sayHello = name =>
LitHtml.html(
{j|
<h1>Hello $(name) </h1>
<p>Goodbye</p>
<div>
<span>This is nested</span>
</div>
|j},
@drejohnson
drejohnson / algovpn-aws-lightsail.md
Last active July 22, 2024 15:52
Installing Algo Vpn to Amazon Lightsail

Installing Algo Vpn to Amazon Lightsail

  • Create a key pair (see: here if you need help with this step)
  • Log into Lightsail and upload your newly created SSH key to the region in which you plan to deploy your VPN server
  • Create a new $3.50/mo Ubuntu 16.04 LTS Lightsail instance in your desired location
  • Create and attach a static IP address to your new instance
  • Log into the newly created instance and run: do-release-upgrade - this will update the 16.04 instance to 18.04
  • Follow the directions in README.md to deploy the Algo server, selecting "Install Algo to existing Ubuntu 18.04 server" when prompted and using the user "ubuntu" when asked
  • Once Algo finishes installing, log into Lightsail and open UDP ports 500, 4500 and 51820.
/* Using jaredly/let-anything */
module Await = {
let let_ = (promise, continuation) =>
promise
|> Js.Promise.then_(value => continuation(value) |> Js.Promise.resolve);
};
let fetchAsync = {
let%Await response = Fetch.fetch("https://swapi.co/api/films/1/");
@drejohnson
drejohnson / launch.json
Created November 8, 2018 05:33 — forked from mohamedmansour/launch.json
webpack-dev-server integration with vscode and typescript for react
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Debug",
The MIT License (MIT)
Copyright (c) 2013 Jamar Parris
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S
@drejohnson
drejohnson / change_primary_key.md
Created November 11, 2018 18:13 — forked from scaryguy/change_primary_key.md
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@drejohnson
drejohnson / async-graphql-request.ts
Last active December 4, 2018 15:45
Using async generators and fetch api to query graphql
export const initGraphql = (input: RequestInfo, accessKey?: string) =>
async function* asyncFetch(query: any, variables?: any) {
while (true) {
const response = await fetch(input, {
method: 'POST',
headers: accessKey
? {
'Content-Type': 'application/json',
'x-hasura-access-key': accessKey,
}
@drejohnson
drejohnson / revert-a-commit.md
Created June 17, 2019 10:51 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@drejohnson
drejohnson / install.sh
Last active March 18, 2020 12:45
install openwrt router in china
#!/bin/sh
set -e
# you may want upgrade netifd first
# timezone
TIMEZONE=HKT-8
# override shadowsocks server config