Skip to content

Instantly share code, notes, and snippets.

View xgqfrms's full-sized avatar
💭
🎉 👻 💻 🕵️‍♂️

xgqfrms xgqfrms

💭
🎉 👻 💻 🕵️‍♂️
View GitHub Profile
// only for Angular2 dist
//
// # SimpleServer
//
// A simple chat server using Socket.IO, Express, and Async.
//
var http = require('http');
var path = require('path');
var async = require('async');

html5 tempalte all in one

<!DOCTYPE html>
<html lang="zh-Hans" manifest="manifest.appcache">
<!-- manifest.json -->

<head>
    <!--
/**
* express static server for react build/dist test!
*/
// simple express server for HTML pages!
// ES6 style
const express = require('express');
const fs = require('fs');
const hostname = '127.0.0.1';
@xgqfrms
xgqfrms / protips.js
Created November 16, 2020 05:18 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@xgqfrms
xgqfrms / JsBlobSaveJson
Created April 8, 2021 16:26 — forked from yiwenl/JsBlobSaveJson
Javascript using Blob to save json file
var saveJson = function(obj) {
var str = JSON.stringify(obj);
var data = encode( str );
var blob = new Blob( [ data ], {
type: 'application/octet-stream'
});
var url = URL.createObjectURL( blob );
var link = document.createElement( 'a' );
@xgqfrms
xgqfrms / watermark.md
Last active January 26, 2022 09:35 — forked from anonymous/example.js
watermark (SVG + Base64)

watermark

var svgText = '<...>'; // SVG source XML

// New browsers: Blob URL
var svgBlob = new Blob([svgText], {type : 'image/svg+xml'});
myImage.src = URL.createObjectURL(svgBlob);
@xgqfrms
xgqfrms / rollup.config.js All In One.md
Last active July 6, 2022 08:42 — forked from evdama/rollup.config.js
rollup.config.js All In One
// @ts-nocheck //TODO: enable remove once there are typings in place
// TODO: uncomment all three eslint() occurrences once eslint warnings and errors are fixed
// for info on emitCSS etc. https://github.com/rollup/rollup-plugin-svelte#extracting-css and https://svelte.dev/docs#svelte_preprocess

// import { eslint } from 'rollup-plugin-eslint'
import { terser } from 'rollup-plugin-terser'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import config from 'sapper/config/rollup.js'