Skip to content

Instantly share code, notes, and snippets.

Sunny Cheung sunnycyk

Block or report user

Report or block sunnycyk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HD Wallet send raw transactions.js
// const Web3 = require('web3')
// const Tx = require('ethereumjs-tx');
// const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
// ....
const data = contractInstance.methods.myMethods(param...).encodeABI()
const tx = new Tx(null)
tx.nonce = await web3.eth.getTransactionCount(hd_wallet_address)
tx.from = hd_wallet_address
tx.gasPrice = GAS_PRICE
View Fetch Nix package URL
# To Update
curl -sI | awk '/Location:/ {print $2}'
# compute the hash
nix-prefetch-url --type 256 unpack <URL>
sunnycyk /
Last active Aug 22, 2017
echo "Start loopback scaffolding for $1"
echo "Enter name for application:"
read app
echo "Creating $app"
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('table')
response = table.scan(
'#k' : 'id', #partition key
View AWS Ubuntu Strong-PM
# install node.js - v4 and v6 have problem running strong-pm?
curl -sL | bash -
apt-get install -y nodejs git
# install strong-pm
npm install -g strong-pm
# or sudo sl-pm-install --http-auth user:password
sudo sl-pm-install
View Observer.php
class Custom_Module_Model_Observer {
public function customRedirect() {
$url = Mage::helper('core/url')->getCurrentUrl();
$url = Mage::getSingleton('core/url')->parseUrl($url);
$path = $url->getPath();
$action = Mage::app()->getRequest()->getActionName();
$pattern = '/[.*]?\/custommodule\/index\/[.*]?|[.*]?\/admin[$.*]?/';
View IFTTT-newFollower.ino
// This #include statement was automatically added by the Particle IDE.
#include "TM1637Display/TM1637Display.h"
TM1637Display display(4, 5); // connect CLK to D4, DIO to D5
int followers = 0; // or start with number that in your profile
void setup()
View dismissMessage.m
#pragma mark -MFMEssageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
switch(result) {
case MessageComposeResultCancelled:
// user canceled sms
[self dismissViewControllerAnimated:YES completion:nil];
View autodownload
// ATLMIMETypeImageJPEGPreview, ATLMIMETypeTextPlain defined in Altas to present the MIME tpye for the medias
self.layerClient = [LYRClient clientWithAppID:YOUR_APP_ID];
self.layerClient.autodownloadMIMETypes = [NSSet setWithObjects:ATLMIMETypeImageJPEGPreview, ATLMIMETypeTextPlain, nil];
View arduino_ble_service_setup.ino
// The Nordic UART Service
static const uint8_t uart_base_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
static const uint8_t uart_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
static const uint8_t uart_rx_uuid[] = {0x71, 0x3D, 0, 2, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
static const uint8_t uart_base_uuid_rev[] = {0x1E, 0x94, 0x8D, 0xF1, 0x48, 0x31, 0x94, 0xBA, 0x75, 0x4C, 0x3E, 0x50, 0, 0, 0x3D, 0x71};
uint8_t txPayload[TXRX_BUF_LEN] = {0,};
uint8_t rxPayload[TXRX_BUF_LEN] = {0,};
GattCharacteristic txCharacteristic (uart_tx_uuid, txPayload, 1, TXRX_BUF_LEN,
You can’t perform that action at this time.