Skip to content

Instantly share code, notes, and snippets.

View allenhwkim's full-sized avatar

Allen Kim allenhwkim

View GitHub Profile
@allenhwkim
allenhwkim / getStyle.js
Created April 3, 2016 15:43
Get real width and height using getComputedStyle
// ref. https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
function getStyle(elem, prop) {
var styles = window.getComputedStyle(elem, null);
var value = styles.getPropertyValue(prop);
if (!value) {
throw "Could not get style for " + prop;
}
return value
}
@allenhwkim
allenhwkim / getMousePositionInElement.js
Created July 5, 2016 04:18
Find Mouse Position Within A Div
function getDocumentPosition(oElement) {
var posX=0, posY=0;
if(oElement.offsetParent) {
for(;oElement; oElement = oElement.offsetParent) {
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
}
return {x: posX, y: posY};
} else {
return {x: oElement.x, y: oElement.y};
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script>
var previewFile;
window.onload = function() {
var canvas = document.querySelector("#canvas-to-resize");
#!/usr/bin/env node --harmony
var co = require('co');
var prompt = require('co-prompt');
var program = require('commander');
program
.arguments('<file>')
.option('-u, --username <username>', 'The user to authenticate as')
.option('-p, --password <password>', 'The user\'s password')
.action(function(file) {
{
"name": "nodecmd",
"version": "0.0.3",
"description": "A command-line tool for creating command line tol",
"main": "index.js",
"bin": {
"snippet": "./index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
@allenhwkim
allenhwkim / gist:be508558869f322e7697
Created October 22, 2014 14:48
Angular Google Maps Fit Bounds
<!doctype html>
<html ng-app="myapp">
<head>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="http://code.angularjs.org/1.2.25/angular.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<script>
var app = angular.module('myapp', ['ngMap']);
app.controller('MyCtrl', function($scope) {
$scope.positions = [ [-24,132] ,[-25,131] ,[-26,130] ];
@allenhwkim
allenhwkim / vue-min-examle.html
Created September 11, 2017 00:44
Vue Min Example
<!DOCTYPE html>
<html>
<body>
<script src="//unpkg.com/vue/dist/vue.min.js"></script>
<div id="hello-world" v-on:click="msg++">
Hello {{ msg }}
</div>
<script>
new Vue({
el: "#hello-world",
@allenhwkim
allenhwkim / react-min-example.html
Last active September 11, 2017 00:46
Min. React Example
<!DOCTYPE html>
<html>
<body>
<script src="https://fb.me/react-15.0.0.js"></script>
<script src="https://fb.me/react-dom-15.0.0.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.min.js"></script>
<script type="text/babel">
const style = {
backgroundColor: 'grey',
fontSize: '24px'
@allenhwkim
allenhwkim / plunker-submit.js
Last active September 20, 2017 18:21
Create a plunker page from javascript form submisstion
class PlunkerSubmit {
constructor() {
this.formFields = [];
this.indexHeads = [];
this.indexBody = '';
}
setDescription(description) {
this.formFields.push({name: 'description', value: description});