Skip to content

Instantly share code, notes, and snippets.

View lsongdev's full-sized avatar
👨‍💻

Lsong lsongdev

👨‍💻
View GitHub Profile
# Github CDN Server
199.27.76.133 assets-cdn.github.com
23.235.46.133 camo.githubusercontent.com
23.235.46.133 avatars0.githubusercontent.com
23.235.46.133 avatars1.githubusercontent.com
23.235.46.133 avatars2.githubusercontent.com
23.235.46.133 avatars3.githubusercontent.com
23.235.46.133 avatars4.githubusercontent.com
@lsongdev
lsongdev / css-parser.js
Created March 16, 2016 10:38
simple css parser
const fs = require('fs');
function notEmpty(input){
return !!input.trim();
};
function kv(prop){
var obj = {};
prop.split(/;/g).filter(notEmpty).forEach(function(item){
var p = item.split(':');
@lsongdev
lsongdev / github-widgets.js
Last active March 2, 2016 08:32
show github star, forks and more .
/**
* Github Widgets
* @author lsong
* @example
*
* <a href="https://github.com/song940/kelp/stargazers">
* <github repo="song940/kelp" key="stargazers_count" ></github> Stargazers
* </a>
*/
;(function(elements){
@lsongdev
lsongdev / koel-installation-docs_debian8.md
Created February 20, 2016 17:16 — forked from brahmlower/koel-installation-docs_debian8.md
This is installation documentation for installing Koel on Debian 8.

Installation on Debian 8

This is installation documentation for installing Koel on Debian 8.

Install Dependancies

Most packages can be installed via apt-get.

user@debian:~/$ sudo apt-get install -y apache2 mysql-server php5 php5-mysql g++ git curl

Composer

#!/bin/bash
echo "This script generates the certificate and private key for the https webadmin"
echo "Note that the generated certificate is self-signed, and therefore not trusted by browsers"
echo "Note that this script requires openssl to be installed and in PATH"
echo ""
echo "When OpenSSL asks you for Common Name, you need to enter the fully qualified domain name of the server, that is, e. g. gallery.xoft.cz"
echo ""
openssl req -x509 -newkey rsa:2048 -keyout httpskey.pem -out httpscert.crt -days 3650 -nodes
var 真 = true;
var 假 = !真;
function 如果(condation, then){
if(condation) then();
return {
否则: function(then){
if(!condation) then();
}
var dgram = require('dgram');
var port = 1300;
var now = function() {
var date = new Date();
return new Buffer(date.toUTCString() + "\r\n");
}
var tcpserver = net.createServer(function(c) {
c.write(now());
c.end();
});
@lsongdev
lsongdev / kelp.js
Last active February 28, 2022 03:59
'use strict';
/**
* [exports Kelp]
* @return {[type]} [description]
*/
function Kelp() {
/**
* [app http server handler]
* @param {[type]} req [request]
* @param {[type]} res [response]
'use strict';
const connect = require('connect');
const route = require('connect-routeify');
const bodyParser = require('body-parser');
const app = connect();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const pathToRegexp = require('path-to-regexp');
function route(def, callback){
var keys = [];
var re = pathToRegexp(def, keys);
return function(req, res, next){
if(re.test(req.url)){
req.params = {};
var matchs = re.exec(req.url);
keys.forEach(function(key, i){