Skip to content

Instantly share code, notes, and snippets.

View ethanliew's full-sized avatar

Ethanz Liew ethanliew

View GitHub Profile
var LINE = require('./line.js');
var line = new LINE();
var email = 'your email';
var password = 'your password';
line.login(email, password, function(error, result) {
if (error) {
return;
}
@echo off
@rem ==================
@rem Source:
@rem https://gist.github.com/jcppkkk/8330314
@rem Description:
@rem Install context menu to allow user opens file with Sublime Text as User or Admin, or Open Folder with Sublime Text.
@rem Usage:
@rem Download this .bat file to in Sublime Text's installation folder.
@rem Execute this batch file. It will download elevate codes and setup context menu.
@rem ==================
/**
* Provides requestAnimationFrame in a cross browser way.
* @author paulirish / http://paulirish.com/
*/
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
var isPortTaken = function(PORT, callback) {
var net = require('net')
var tester = net.createServer()
tester.once('error', function (err) {
if (err.code == 'EADDRINUSE') {
callback(null, true)
} else {
callback(err)
}
})
@ethanliew
ethanliew / mysql_pivot.sql
Created July 11, 2017 03:51 — forked from chappy84/mysql_pivot.sql
MySQL Pivot Stored Procedure
DROP PROCEDURE IF EXISTS pivot_user_preferences;
DELIMITER $$
CREATE PROCEDURE pivot_user_preferences(IN user_id INT)
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE definition_label CHAR(255);
DECLARE label_cursor CURSOR FOR SELECT DISTINCT label FROM example_db.user_preferences;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
@ethanliew
ethanliew / osx-10-10-virtualbox.md
Created August 11, 2017 03:34 — forked from frdmn/osx-10-10-virtualbox.md
Install OS X 10.10 Yosemite in VirtualBox
@ethanliew
ethanliew / gist:ad0ee3ea7274298e70055f0bab36079d
Created October 14, 2017 06:52 — forked from rolinger/gist:d6500d65128db95f004041c2b636753a
PHP => FCM Push notification tutorial for Android and iOS
Below is a full tutorial on how to setup and use Googles Firebase push notification API for both Android and iOS. It is based on this
earlier implementation of Googles GCM method: https://gist.github.com/prime31/5675017 - FCM is the new method and GCM will eventually be
retired.
## THE BELOW METHOD IS THE NEWER FCM METHOD:
Register your app in the FCM Console: https://console.firebase.google.com (add project)
1. Click on the newly added project, in the upper left menu is the "Overview" and Gear Settings.
2. Click on the GEAR settings icon, and then on "Project Settings"
3. In the main screen, click on "Cloud Messaging"
@ethanliew
ethanliew / ca.md
Created October 19, 2017 08:46 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@ethanliew
ethanliew / .htaccess - Prevent Script Injection
Created February 5, 2018 03:45 — forked from unix7/.htaccess - Prevent Script Injection
.htaccess - Prevent Script Injection
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
//Source: http://wp.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');