This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Reducer Helper | |
*/ | |
export function createReqeuestTypes(_base) { | |
let base = _base; | |
if (Array.isArray(base)) base = base.join('/'); | |
const res = {}; | |
[REQUEST, SUCCESS, FAILURE] | |
.forEach(type => res[type] = `${base}_${type}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I recently needed to upload a file from the phone's filesystem to S3 using temporary credentials | |
* (i.e. access key, secret key and session token) issued by an API for a React Native application, | |
* without the overhead of Base64 encoding the file and passing it over the bridge (as it could be | |
* several MB big), and wanted to avoid writing native code to do this. | |
* | |
* None of the S3 libraries online worked with the temporary credentials, but I figured out a | |
* solution using the official AWS SDK (which is good, as it supports all the relevant authentication | |
* out of the box) and the react-native-fetch-blob module, which allows you to upload directly from the | |
* filesystem with the correct Content-type header (as far as I can tell, React Native's fetch only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
const SERVER = 'https://...'; | |
const requests = { | |
... | |
post: async (rootUrl, route = '', body = {}, config = {}) => { | |
const response = await axios.post(`${rootUrl}${route}`, body, config); | |
return getResponse(response); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* referenced | |
* 1. http://www.techiedelight.com/min-heap-max-heap-implementation-in-java/ | |
* 2. https://gist.github.com/flexelem/70b120ac9bf2965f419f | |
* */ | |
class MinHeap<E extends Comparable<E>> { | |
private ArrayList<E> heap; | |
MinHeap() { | |
heap = new ArrayList<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"fmt" | |
) | |
var wg = sync.WaitGroup{} | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let allGood = true; | |
proposalResponses.forEach((pr) => { | |
let oneGood = false; | |
if (pr.response && pr.response.status === 200) { | |
oneGood = true; | |
logger.info('install proposal was good'); | |
} else { | |
logger.error('install proposal was bad'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/hex" | |
"fmt" | |
"github.com/btcsuite/btcd/btcec" | |
"github.com/btcsuite/btcd/chaincfg" | |
"github.com/btcsuite/btcd/chaincfg/chainhash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package link | |
type Addr string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package na | |
// Card is abstracted network adapter part to simulate bytes transport on | |
// physical cable. Node's interface uses this interface to send frame | |
// between nodes. | |
type Card interface { | |
Send(buf []byte, addr string) (time.Time, error) | |
Recv() <-chan *FrameData | |
} |
OlderNewer