Skip to content

Instantly share code, notes, and snippets.

View kuanyui's full-sized avatar
❄️
なんでそんなに慣れてんだよ!

クエン酸 kuanyui

❄️
なんでそんなに慣れてんだよ!
View GitHub Profile
;; (:= a 1) a = 1
;; (:= a (list 1 2 3)) a = (1 2 3)
;; (:= (a b c) (1 2 3)) a = 1, b = 2, c = 3
(defmacro := (places values)
`(cond ((and (listp (quote ,places))
(listp ,values))
(if (eq (length (quote ,places)) (length ,values))
(map 'list (lambda (sym val) (set sym val)) (quote ,places) ,values)
(error "The length of two args are not equal")))
(defun run-length (results)
(if (null results)
results
(let ((tmp (run 1 (car results) (cdr results))))
(cons (car tmp) (run-length (cdr tmp))))))
(defun run (times elem remains)
(cond ((equal elem (car remains)) (run (1+ times) elem (cdr remains)))
((= times 1) (cons elem remains))
((> times 1) (cons (list times elem) remains))))

大大安安

自我介紹

ono hiroko

Github

kuanyui

Lisp

各種神話的語言

Emacs Lisp

廣泛使用的 Lisp 方言

風和日麗的一天

@kuanyui
kuanyui / 雅量.org
Last active September 10, 2016 17:14

朋友裝了新系統,變色龍帶綠色的皮膚與圓睜睜的大眼睛,當她拿給我們看時,一位對Linux十分感與趣的同學說:

「啊,桌布的Geeko好可愛!」

「我沒用過openSUSE耶,好用嗎?」我說。

「根本糞distro。不用Arch的人都智能不足啦。」一位見到人就要傳教、外號叫「引戰客」的同學緊接著說。

我們不禁啞然失笑,同樣的一個distro,每個人卻有不同的感覺。那位朋友連忙把筆電蓋上,她覺得openSUSE就是openSUSE,不是變色龍,也不是智力測驗,更不是宗教。

此僅為備份,因為原文在Facebook中。 作者:顏華容 https://www.facebook.com/artemis.yen/posts/10207549044542275

一點關於練琴效率的小心得 如果大家有興趣的話,在連假的這幾天可以實驗

實驗材料:沒有彈過的曲子(有沒有聽過無妨,因為聽過你也不見得會彈,哈哈。)

觀察曲式:意思就是說,「它是什麼時代來的誰?」

@kuanyui
kuanyui / I want to do a form looks like this:
Last active August 29, 2015 14:26
I have a lot of `key: value` pairs to save strings in site, how to use `forms.Form` to make a form like this?
Site Configuration
site_title: ________________
site_subtitle: _________________
admin_email: _________________
admin_phone: _________________
[Save]
@kuanyui
kuanyui / find_duplicated_files.py
Last active August 29, 2015 14:24
Find duplicated files via MD5 checksum and output the list as file.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import hashlib, os, sys, math, threading, time, argparse, datetime, sqlite3
# filePath is relative path
# list.append() set.add()
class Hasher(threading.Thread):
def __init__(self, lock, file_walker):
threading.Thread.__init__(self)
@kuanyui
kuanyui / login.html
Last active August 29, 2015 14:21
(Unusable) Django AJAX login form.
{# accounts/includes/login.html #}
{% load crispy_forms_tags %}
<h1>Login</h1>
<div class="col-sm-12">
<form class="login-form" method="post">
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-primary">Login!!!!!</button>
</form>
</div>
@kuanyui
kuanyui / views.py
Created May 22, 2015 20:45
既然create view都已經寫這麼多,那有沒有辦法繼承並簡化update view的寫法?
class ProductCreate(StaffuserRequiredMixin, CreateView):
'''
Use URL parameter (GET) to decide if currently is under a category
'''
form_class = ProductForm
template_name = 'console/create_product.html'
submit_title = "建立商品"
def get_context_data(self, *args, **kwargs):
context = CreateView.get_context_data(self, *args, **kwargs)
@kuanyui
kuanyui / gnu_docs.css
Created November 27, 2014 12:41
Stylish for GNU documents
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("www.gnu.org") {
code, kbd {
border-radius: 2px;
padding:1px 10px;
}
code{
color: #006 !important;
background-color: #ddf !important;
}