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
#include <stdio.h> | |
#include <stdlib.h> | |
//Malloc a matrix | |
int **malloc_matrix(size_t rows, size_t cols) | |
{ | |
int **data_pointer = (int **)malloc(sizeof(int *) * rows); | |
for (int i = 0; i < rows; i++) | |
{ | |
data_pointer[i] = malloc(sizeof(int) * cols); |
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
const http = require('http'); | |
function request(json) { | |
return new Promise((resolve, reject) => { | |
let startTime = Date.now(); | |
let body = JSON.stringify(json); | |
const options = { | |
host: 'localhost', | |
method: 'POST', | |
port: 3000, |
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
const instanceMap: {[key:string]: any} = {}; | |
export function Singleton<T>(instanceName:string, InstanceConstructor: new () => T):T { | |
if (typeof instanceMap[instanceName] === 'undefined') { | |
instanceMap[instanceName] = new InstanceConstructor(); | |
} | |
return <T>instanceMap[instanceName]; | |
} | |
export default Singleton; |
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
function objectToMap(obj: any, key: string[] = [], mapResult?: Map<string, any>) { | |
if (typeof mapResult === 'undefined') { | |
mapResult = new Map<string, any>(); | |
} | |
if (typeof obj === 'object' && obj !== null && !Array.isArray(obj)) { | |
const k = Object.keys(obj); | |
for (let i = 0; i < k.length; i += 1) { | |
if (typeof obj[k[i]] !== 'object') { | |
mapResult.set(key.concat([k[i]]).join('.'), obj[k[i]]); | |
} else if (obj[k[i]] !== null) { |
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
[ | |
{ | |
"publicKey": "a28dce25d19f11b29bec42547d95d76fcba0d88d45c07f6816f970e417a73c30", | |
"privateKey": "04d26486cd227a7999aa606d7fb07fb3010528ba043c0e3a1b98f1a26c3b16cba28dce25d19f11b29bec42547d95d76fcba0d88d45c07f6816f970e417a73c30", | |
"seed": "04d26486cd227a7999aa606d7fb07fb3010528ba043c0e3a1b98f1a26c3b16cb" | |
}, | |
{ | |
"publicKey": "431a43aa41d085326f6ded197f6c0c29f4b245fd7f3a954f2700b60df2f40097", | |
"privateKey": "f28a767f6b38307ac5ef94f873138334829c87a72fdfd205930de04eb39805e8431a43aa41d085326f6ded197f6c0c29f4b245fd7f3a954f2700b60df2f40097", | |
"seed": "f28a767f6b38307ac5ef94f873138334829c87a72fdfd205930de04eb39805e8" |
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
function test(callback: (result: any)=>void) { | |
(async () => { | |
const a = await function1(); | |
const b = await function2(); | |
return { a, b }; | |
})() | |
.then((result) => { | |
callback(result); | |
}); | |
} |
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
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.6.4; | |
contract Verifier { | |
// Returns the address that signed a given string message | |
function verifyString( | |
string memory message, | |
uint8 v, | |
bytes32 r, | |
bytes32 s |
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
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.6.4; | |
contract VerifyPoC { | |
function verifySerialized(bytes memory message, bytes memory signature) public pure returns (address) { | |
bytes32 r; | |
bytes32 s; | |
uint8 v; | |
assembly { | |
// Singature need to be 65 in length |
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
#include <stdint.h> | |
struct xorshift128p_state { | |
uint64_t a, b; | |
}; | |
/* The state must be seeded so that it is not all zero */ | |
uint64_t xorshift128p(struct xorshift128p_state *state) | |
{ | |
uint64_t t = state->a; |
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
/* | |
MIT License | |
Copyright (c) 2020 Chiro Hiro <[email protected]> | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <immintrin.h> | |
// Global seed value |