Skip to content

Instantly share code, notes, and snippets.

@lolocoo
lolocoo / ycombinator.js
Created November 29, 2017 09:40
ycombinator
Deriving the Y Combinator in 7 Easy Steps
December 01, 2010
The Y Combinator is a method of implementing recursion in a programming language that does not support it natively (actually, it's used more for exercising programming brains). The requirement, though, is that language to support anonymous functions.
I chose JavaScript for deriving the Y Combinator, starting from the definition of a recursive factorial function, using a step-by-step transformation over the initial function.
Update
There's now a Chinese translation of this article as well as a Clojure port.
@lolocoo
lolocoo / jscombinator.js
Created November 28, 2017 06:36
jscombinator
var y = le => (f => f(f)) (f => le(x => (f(f))(x)))
var y = function(le) {
return function(f) {
return f(f);
}(function(f) {
return le(
function(x) { return (f(f))(x); }
var list = [
'Cras justo odio',
'Dapibus ac facilisis in',
'Morbi leo risus',
'Porta ac consectetur ac',
'Vestibulum at eros'
]
var list_set = function () {
list.push('Item '+ new Date().getTime());
$('#list').trigger('update:list');
docker 部署 gitlab
`wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml && docker-compose up -d `
var $seach, $list;
$seach = $('#seach');
$list = $('#list');
$seach.on('keydown', function(){
var $this = $(this);
setTimeout(function(){
var val = $this.val();
var re = new RegExp(val);
var newlist = $list.find('li').filter(function(item){
var roc = {
namespace: function(ns) {
var parts = ns.split('.'),
object = this,
i, len;
for (i=0, len=parts.length; i < len; i++) {
if (!object[parts[i]) {
object[parts[i]] = {};
}
object = object[parts[i]];
@lolocoo
lolocoo / gulpfile.js
Created March 1, 2017 01:00
tencent gulp file
var gulp = require('gulp');
// sass 插件
var sass = require('gulp-sass');
// 自动同步浏览器插件
var browserSync = require('browser-sync');
// 合并文件的插件
var useref = require('gulp-useref');
// 压缩js插件
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
@lolocoo
lolocoo / sui-offcanvas
Created February 25, 2017 00:32
sui-offcanvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>我的生活</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
https://github.com/emmetio/emmet-atom/issues/354
@lolocoo
lolocoo / persistant-header.html
Created December 13, 2016 00:24
persistant-header
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Table with Persistent Headers</title>
<link rel="stylesheet" href="css/style.css">