some scripts for various work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var browserify = require('browserify-middleware'); | |
var express = require('express'); | |
var app = express(); | |
browserify.settings.development('basedir', __dirname); | |
app.use('/js',browserify('./client')); | |
app.get('/js/main.js', browserify('./client/main.js',{ | |
external: ['OpenLayers'], | |
detectGlobals: false | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="/js/main.js"></script> | |
<style> | |
#map { | |
width:600px; | |
height:400px; | |
} | |
</style> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.OpenLayers = require('./OpenLayers.js'); | |
window.init = function() { | |
var osm = new OpenLayers.Layer.OSM(); | |
osm.wrapDateLine = false; | |
var map = new OpenLayers.Map("map",{projection:'EPSG:900913',numZoomLevels:18}); | |
map.addLayers([osm]); | |
map.setCenter(new OpenLayers.LonLat(8126483.8753499,2162623.286343),15); | |
console.log('init function called'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// svg file detail | |
var width = 400; | |
var height = 400; | |
// svg file spatial extent, you should know these values for your file | |
var extent = {left: -180, bottom: 90, right: 180, top: 90}; | |
var x_res = (extent.left - extent.right) / width; | |
var y_res = (extent.left - extent.right) / height; | |
// x_res and y_res should be same |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var extent = { | |
left: -20037508.342789244, | |
right: 20037508.342789244, | |
bottom: -20037508.342789244, | |
top: 20037508.342789244 | |
}; | |
var size = 256; // map tile size | |
var resolutions = []; | |
for (var i=0; i< 24; i++) { | |
resolutions.push( (extent.right - extent.left) / (256 * Math.pow(2,i)) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRINT "Enter the password" | |
INPUT WORD$ | |
IF WORD$ = "SECRET" THEN | |
PRINT "permission granted" | |
ELSE | |
PRINT "permission denied": GOTO goend | |
END IF | |
PRINT "what should I call you" | |
INPUT name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [] | |
const dummy = async function (i) { | |
return new Promise((res, rej) => { | |
const delay = Math.random() * 1000 | |
setTimeout(() => { | |
console.log('%s, delayed: %s, timestamp: %s', i, delay, Date.now()); | |
res(i); | |
}, delay); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
console.log('Starting'); | |
let result; | |
try { | |
result = await test(); | |
} catch (error) { | |
// catch both thrown error as well as Promise rejection | |
console.error(error); | |
} | |
console.log('Result: ', result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const file = process.argv[2]; | |
const {promisify} = require('util'); | |
const zlib = require('zlib'); | |
const gzip = promisify(zlib.gzip); | |
(async () => { | |
const fs = require('fs'); | |
const data = fs.readFileSync(file, 'utf-8'); | |
const buf = await gzip(data) |
OlderNewer