Skip to content

Instantly share code, notes, and snippets.

View ldcc's full-sized avatar

ldcc ldcc

View GitHub Profile
@ldcc
ldcc / jekyll.service
Last active May 24, 2019 03:21
ruby jekyll systemd service
[Unit]
Description=Daemon to start Jekyll service
[Service]
Type=simple
ExecStart=/usr/local/bin/jekyll serve --source /home/user/repos/blog --destination /srv/jekyll/blog
ExecStop=/usr/local/bin/jekyll clean --source /home/user/repos/blog --destination /srv/jekyll/blog
PIDFile=/var/run/jekyll.pid
[Install]
@ldcc
ldcc / sslocal.service
Last active May 24, 2019 03:20 — forked from ygmpkk/sslocal.service
shadowsocks client systemd service
[Unit]
Description=Daemon to start Shadowsocks Client
Wants=network-online.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/sslocal -c /etc/shadowsocks/client.json
PIDFil=/var/run/sslocal.pid
@ldcc
ldcc / resname.md
Last active May 24, 2019 03:34
Jekyll Posts Filename on Liquid.

Get filenames from my present blog posts on jekyll.

Get from single post

1.Split and pick the filename from the post of full path:

{% assign file = page.path | split: "/" | last %}

The page.path which respected the filepath that jekyll does generated.

@ldcc
ldcc / transpose.py
Last active May 24, 2019 03:14
transpose the matrices on python
O = [1, 2, 3]
A = [11, 22, 33]
B = [111, 222, 333]
C = [1111, 2222, 3333]
M = [O, A, B, C]
def transpose0(m):
return [tuple(r[c] for r in m) for c in range(len(m[0]))]
@ldcc
ldcc / full-combination.rkt
Last active May 24, 2019 02:48
Computes all combinations of r elements from n.
(define combo
(let ([d (- n r)])
(λ (n r)
(/ (factorial n 1)
(factorial r 1)
(factorial d 1)))))
(define factorial
(λ (x s)
(cond [(< x 1) s]
@ldcc
ldcc / cons-test.sol
Last active May 24, 2019 02:47
Solidity list structure gas consumption tests
pragma solidity ^0.4.24;
pragma experimental "v0.5.0";
contract ListSystematically {
struct Holder {
uint256 amount;
uint256 frees;
Share[] shares;
}
@ldcc
ldcc / badges.md
Last active May 24, 2019 03:12
mark badges for open source projects

Badges

Travis
Status

Coveralls
Coveralls

NPM

@ldcc
ldcc / cons's.rkt
Last active May 23, 2019 11:05
cons combinators
(define (cons1 x y)
(λ (m) (m x y)))
(define (car1 z)
(z (λ (p q) p)))
(define (cdr1 z)
(z (λ (p q) q)))
(define (cons2 x y)
@ldcc
ldcc / reverse.rkt
Last active May 23, 2019 11:04
list reversal
(define reverse
(letrec ([loop (λ (l1 l2)
(cond [(null? l1) l2]
[else (loop (cdr l1) (cons (car l1) l2))]))])
(λ (l) (loop l '()))))
(reverse '(a b c d e f g))
;; ⇒ '(g f e d c b a)
@ldcc
ldcc / ruby_quicksort.rb
Last active May 23, 2019 11:00
Ruby to doing a quick sort.
class QuickSort
def self.sort!(keys)
quick(keys,0,keys.size-1)
end
private
def self.quick(keys, left, right)
if left < right