Skip to content

Instantly share code, notes, and snippets.

@sunnycyk
sunnycyk / self-signed-certificate-with-custom-ca.md
Created November 9, 2020 00:49 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@sunnycyk
sunnycyk / updateallitems.py
Created December 17, 2016 05:35
dynamodb notes
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('table')
response = table.scan(
ProjectionExpression='#k,#s',
ExpressionAttributeNames={
'#k' : 'id', #partition key
#!/bin/bash
# install node.js - v4 and v6 have problem running strong-pm?
curl -sL https://rpm.nodesource.com/setup_5.x | 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
// 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
# To Update
curl -sI https://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz | awk '/Location:/ {print $2}'
# compute the hash
nix-prefetch-url --type 256 unpack <URL>
@sunnycyk
sunnycyk / example.html
Last active July 4, 2018 20:57
Ionic Framework Infinite Scroll Example
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Ionic List Directive</title>
<link href="http://code.ionicframework.com/0.9.24/css/ionic.min.css" rel="stylesheet">
<script src="http://code.ionicframework.com/0.9.24/js/ionic.bundle.min.js"></script>
</head>
@sunnycyk
sunnycyk / ex8-10.swift
Last active April 13, 2018 14:35
IOS Core Animation Example Chapter 8
//
// ViewController.swift
// animation810
//
// Created by Sunny Cheung on 27/10/14.
// Copyright (c) 2014 khl. All rights reserved.
//
import UIKit
@sunnycyk
sunnycyk / lb.sh
Last active August 22, 2017 09:23
myscript
#!/bin/sh
echo "Start loopback scaffolding for $1"
echo "Enter name for application:"
read app
echo "Creating $app"
@sunnycyk
sunnycyk / Observer.php
Last active June 6, 2017 00:37
Magento
<?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[$.*]?/';
@sunnycyk
sunnycyk / facedetection.py
Created May 14, 2014 07:25
Pi Face Detection
import cv2
import cv2.cv as cv
import config
import picamera
def detect_faces(image):
haar_faces = cv2.CascadeClassifier(config.HAAR_FACES)
detected = haar_faces.detectMultiScale(image, scaleFactor=config.HAAR_SCALE_FACTOR,
minNeighbors=config.HAAR_MIN_NEIGHBORS,
minSize=config.HAAR_MIN_SIZE,