Skip to content

Instantly share code, notes, and snippets.

View hellwolf's full-sized avatar

Miao ZhiCheng hellwolf

View GitHub Profile
@hellwolf
hellwolf / sync.gs
Created November 10, 2016 09:34
sync.gs
function GetSyncListItems(serviceInstanceId, listId, accountSid, authToken) {
var url = "https://preview.twilio.com/Sync/Services/" + serviceInstanceId + "/Lists/" + listId + "/Items";
var result = ImportJSON(url, "", "", accountSid, authToken);
return result;
}
@hellwolf
hellwolf / ImportJSON.gs
Created November 10, 2016 08:32
ImportJSON.gs with username/password support
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@hellwolf
hellwolf / supervisord
Last active August 29, 2018 12:29
/etc/init.d/supervisord for `pip install supervisor` supervisor@^3.3.4
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Cameron Kerr <cameron.kerr.nz@gmail.com> adjusted 'status'
# to return an LSB-compliant return code so things like
@hellwolf
hellwolf / encstream.html
Last active October 21, 2018 16:42
Example crypto.subtle encrypt/decrypt with AES-CTR
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example crypto.subtle encrypt/decrypt with AES-CTR</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
@hellwolf
hellwolf / truffle-json-inspect-sizes.sh
Last active February 19, 2019 14:19
jq sort truffle contract json artifact
jq -r '[
. as $root | keys[] as $k | $root[$k] | @json | length as $len | { key: $k, length: $len }
] | sort_by(.length) | reverse | map("\(.key) \(.length)")[]' $CONTRACT_JSON_FILE
@hellwolf
hellwolf / gen-secp384r1-keypairs.sh
Created April 7, 2019 09:20
Generate secp384r1 key pairs
openssl ecparam -name secp384r1 -genkey -noout -out new-secp384r1-private-key.pem
openssl ec -in new-secp384r1-private-key.pem -pubout -outform DER -out new-secp384r1-public-key.der
@hellwolf
hellwolf / test-ecdh1-derive.sh
Created April 7, 2019 09:21
test ecdh1 derive mechanism
#!/bin/bash
openssl pkeyutl -derive -inkey new-secp384r1-private-key.pem -peerkey XXXXXXXX-pin1-public-key.pem | xxd -p | tr '\n' '|' | sed 's/|//g'
echo
pkcs11-tool --derive --token-label PIN1 --login --id 01 -m ECDH1-DERIVE --input-file new-secp384r1-public-key.der --output-file >(xxd -p | tr '\n' '|' | sed 's/|//g')
pragma solidity >=0.4.21 <0.6.0;
// converted from cDAI.json
contract cDAI {
function name() external returns (
string memory
);
function approve(
address spender,
@hellwolf
hellwolf / rtoken-snippet.sol
Created August 6, 2019 11:25
rtoken sinippet
/**
* @notice Sender supplies assets into the market and receives rTokens in exchange
* @param mintAmount The amount of the underlying asset to supply
* @return uint 0=success, otherwise a failure
*/
function mint(uint256 mintAmount) external returns (bool);
/**
* @notice Sender redeems rTokens in exchange for the underlying asset
* @param redeemTokens The number of rTokens to redeem into underlying
@hellwolf
hellwolf / IRToken.sol
Created October 18, 2019 12:34
IRToken.sol for remix editor
// File: contracts/RTokenStructs.sol
pragma solidity ^0.5.8;
contract RTokenStructs {
/**
* @notice Global stats
*/
struct GlobalStats {