Skip to content

Instantly share code, notes, and snippets.

Ken Ng kenng

Block or report user

Report or block kenng

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
@kenng
kenng / lambda-email.py
Created May 13, 2019 — forked from rambabusaravanan/lambda-email.py
AWS Lambda Function to send SMTP Email
View lambda-email.py
import smtplib
import os
def send_email(host, port, username, password, subject, body, mail_to, mail_from = None, reply_to = None):
if mail_from is None: mail_from = username
if reply_to is None: reply_to = mail_to
message = """From: %s\nTo: %s\nReply-To: %s\nSubject: %s\n\n%s""" % (mail_from, mail_to, reply_to, subject, body)
print (message)
try:
@kenng
kenng / listAllEventListeners.js
Created Apr 7, 2019 — forked from dmnsgn/listAllEventListeners.js
List all event listeners in a document
View listAllEventListeners.js
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@kenng
kenng / php
Created Feb 13, 2019
phpmailer
View php
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
@kenng
kenng / php
Last active Feb 27, 2019
php mail function
View php
<?php
class IwMail {
protected $subject;
protected $headers;
protected $content;
protected $to;
protected $from;
public $mail;
@kenng
kenng / php
Last active Jan 30, 2019
php debug
View php
public static function WriteErrorFile(String $msg) {
$fpath = base_path() . '/errors.log';
$fpath = "/Applications/AMPPS/www/lwnew.thelivingwellco.com.sg/wp-content/plugins/itwonders-woocommerce-deposit/errors.log";
error_log(print_r($msg, TRUE), 3, $fpath);
}
public static function backtrace($skip=0, $limit=12) {
$dump = [];
$mydump = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $limit);
@kenng
kenng / javascript
Created Jan 22, 2019
particle json
View javascript
{
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
@kenng
kenng / important.css
Created Jan 22, 2019 — forked from tzi/important.css
How to set an !important css property in javascript
View important.css
.test {
height: 139px;
width: 96px
}
View javascript
function loadScript(url) {
var script = document.createElement("script"); // create a script DOM node
script.src = url; // set its src to the provided URL
document.head.appendChild(script);
}
loadScript('https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js')
/*
pass in either myDOM, myid, or myclass, just one of them
@kenng
kenng / wget-snapshotpage.md
Created May 15, 2018 — forked from dannguyen/wget-snapshotpage.md
Use wget to snapshot a page and its necessary visual dependencies
View wget-snapshotpage.md

Use wget to mirror a single page and its visible dependencies (images, styles)

Money graphic via State of Florida CFO Vendor Payment Search

Graphic via State of Florida CFO Vendor Payment Search (flair.myfloridacfo.com)

This is a quick command I use to snapshot webpages that have a fun image I want to keep for my own collection of WTFViz. Why not just right-click and save the image? Oftentimes, the webpage in which the image is embedded contains necessary context, such as captions and links to important documentation just incase you forget what exactly that fun graphic was trying to explain.

You can’t perform that action at this time.