Skip to content

Instantly share code, notes, and snippets.

View mooyoul's full-sized avatar
👨‍💻
working from somewhere

MooYeol Prescott Lee mooyoul

👨‍💻
working from somewhere
View GitHub Profile
<img src="https://cdn.my-awesome-website.com/images/some-image.gif" alt="Some animated image">
@mooyoul
mooyoul / emulate-click.js
Created January 19, 2018 07:27
node-ffi
/**
* Created by Prescott on 2015-05-08.
*/
const ffi = require("ffi");
// const ref = require('ref');
/*
const intPtr = ref.refType(ref.types.int32);
@mooyoul
mooyoul / render.js
Created December 27, 2017 08:52
Render text using Canvas in Node.js environment
const Canvas = require('canvas');
const fs = require('fs');
const canvas = new Canvas(640, 480); // creates 6400px * 480px canvas
const ctx = canvas.getContext('2d'); // get 2d context
// Fill background
ctx.fillStyle = "rgb(255, 255, 255)"
ctx.fillRect(0, 0, canvas.width, canvas.height);
@mooyoul
mooyoul / index.js
Created October 24, 2017 22:56
Bosun Slack Proxy
const { text, send } = require('micro');
const request = require('request');
const debug = require('debug');
const LOG_TAG = 'bosun-slack-proxy';
debug.enable(LOG_TAG);
const log = debug(LOG_TAG);
module.exports = async (req, res) => {
const requestBody = await text(req);
@mooyoul
mooyoul / render.js
Created August 29, 2017 16:48
Draw text in Node.js
'use strict';
const fs = require('fs');
const Canvas = require('canvas');
const width = 600;
const height = 300;
const canvas = new Canvas(width, height); // creates 400px * 200px size canvas
// draw
@mooyoul
mooyoul / check.sh
Created July 10, 2017 10:22
Check last git commit id has changed
#!/bin/bash
echo 'Checking last commit id'
# Change repo to monitor
GIT_REPO=https://github.com/torvalds/linux.git
LATEST_COMMIT_LOG=$(git ls-remote $GIT_REPO refs/heads/master)
LAST_FETCHED_COMMIT_LOG=$(cat /tmp/last-commit.log 2>/dev/null)
@mooyoul
mooyoul / get-cidr.sh
Last active July 6, 2017 11:42
Gets CIDR by query whois with specific netname (e.g. Name of ISP)
#!/bin/bash
# First of all, you'll need ipcalc utility.
# ipcalc can be downloaded at jodies.de/ipcalc
WHOIS_QUERY = "some-netname"
whois -h whois.apnic.net $WHOIS_QUERY | grep inetnum | grep -Eo '[0-9].+' | sed 's/ //g' | xargs -I IP_RANGE sh -c 'ipcalc -rn IP_RANGE | tail -n +2'
# ######################
# Explaination
@mooyoul
mooyoul / webpack.config.js
Created May 31, 2017 17:14
Angular 1 Webpack example
'use strict';
const
path = require('path'),
webpack = require('webpack'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
dotenv = require('dotenv'),
isProduction = process.env.NODE_ENV === 'production',
@mooyoul
mooyoul / cloudfront-metrics.js
Created May 15, 2017 17:11
CloudFront Metrics via CloudWatch API
'use strict';
const AWS = require('aws-sdk');
const cloudwatch = new AWS.CloudWatch();
const endDate = new Date();
const startDate = new Date(endDate.getTime() - (3600 * 24 * 1000)); // 1 day ago
@mooyoul
mooyoul / npm-debug.log
Created February 25, 2017 20:08
npm log about cfb issue
This file has been truncated, but you can view the full file.
14007 verbose addNameRange registry:https://registry.npmjs.org/resolve-dir not in flight; fetching
14008 silly resolveWithNewModule [email protected] checking installable status
14009 silly cache add args [ 'is-glob@^2.0.1', null ]
14010 verbose cache add spec is-glob@^2.0.1
14011 silly cache add parsed spec Result {
14011 silly cache add raw: 'is-glob@^2.0.1',
14011 silly cache add scope: null,
14011 silly cache add escapedName: 'is-glob',
14011 silly cache add name: 'is-glob',
14011 silly cache add rawSpec: '^2.0.1',