Skip to content

Instantly share code, notes, and snippets.

View knjname's full-sized avatar
💭
🐙

knjname knjname

💭
🐙
View GitHub Profile
const ldap = require("ldapjs");
const server = ldap.createServer();
server.bind("", (req, res, next) => {
console.log(`Bind attempt with ${req.dn.toString()}`);
res.end();
return next();
});
const formula = [31,28,31,30,31,30,31,31,30,31,30,31].map((e, m) => {
m++;
const otherMonths = [1,2,3,4,5,6,7,8,9,10,11,12].filter(e => e !== m);
return `${e} * (${otherMonths.map(om => `(x-${om})`).join('*')}) / (${otherMonths.map(om => `(${m}-${om})`).join('*')})`
}).join("\n + ")
// 31 * ((x-2)*(x-3)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((1-2)*(1-3)*(1-4)*(1-5)*(1-6)*(1-7)*(1-8)*(1-9)*(1-10)*(1-11)*(1-12))
// + 28 * ((x-1)*(x-3)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((2-1)*(2-3)*(2-4)*(2-5)*(2-6)*(2-7)*(2-8)*(2-9)*(2-10)*(2-11)*(2-12))
// + 31 * ((x-1)*(x-2)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((3-1)*(3-2)*(3-4)*(3-5)*(3-6)*(3-7)*(3-8)*(3-9)*(3-10)*(3-11)*(3-12))
// + 30 * ((x-1)*(x-2)*(x-3)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((4-1)*(4-2)*(4-3)*(4-5)*(4-6)*(4-7)*(4-8)*(4-9)*(4-10)*(4-11)*(4-12))
'''
''' A simple unit testing library.
'''
''' @usage
''' Write a test class with the following rules.
'''
''' * A test class name must be ended with `Test` suffix.
''' * A Test method name must be ended with `_Test` suffix.
'''
''' You can see some examples in MonkeyTest class also included in Ariawase.
# Before executing this command, you need to start an empty gitlab instance.
docker-compose exec gitlab /sbin/entrypoint.sh app:rake gitlab:backup:restore
@knjname
knjname / upgrade-gitlab.sh
Last active July 11, 2018 08:43
Upgrading script of sameersbn/gitlab.
#!/bin/bash
# Usage:
# $ FROM_VERSION=10.8.3-1 TO_VERSION=11.0.0 bash upgrade-gitlab.sh
#
# Assuming that you have `sameersbn/gitlab:version_string` entry in docker-compose.yml.
# See https://github.com/sameersbn/docker-gitlab
: ${FROM_VERSION:?}
: ${TO_VERSION:?}
@knjname
knjname / (供養) re-frame 0.8.0 の変更点.md
Last active April 4, 2018 14:31
(供養) re-frame 0.8.0 の変更点.md
@knjname
knjname / Dockerfile
Last active March 12, 2018 04:10
Building go docker image `FROM scratch`
FROM golang AS builder
WORKDIR /
ADD ./helloworld.go /helloworld.go
RUN ["go", "build", "/helloworld.go"]
FROM scratch
COPY --from=builder /helloworld /helloworld
CMD ["/helloworld"]
@knjname
knjname / index.js
Created November 28, 2017 03:19
TypeScriptのデコレータでクラス宣言順でハマる例
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
function methodDecorator(target, key, descriptor) { return target; }
task customizedBootRun(type: JavaExec) {
dependsOn bootRun.getTaskDependencies()
// Customize
args = ["something", "you", "need"]
jvmArgs = ["-Dspring.profiles.active=development"]
classpath = sourceSets.main.runtimeClasspath
main = "your.main.ClassName"
@knjname
knjname / partitionByComparingPredecessor.ts
Created November 24, 2017 11:54
前要素と比較してぶったぎる関数
export function partitionByComparingPredecessor<T>(
list: T[], partition: (prev: T, cur: T) => boolean
): T[][] {
const result: T[][] = []
let prev: T = null
let accum: T[] = []