Skip to content

Instantly share code, notes, and snippets.

<html>
<div style="width: 100px">
<img src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 24 24"><text x="0" y="12" font-size="12">你好</text></svg>' style="width: 50%" />
</div>
</html>
@bolasblack
bolasblack / keymap_hhkb.c
Last active November 4, 2017 00:23
tmk_keyboard keymap
/*
* HHKB Layout
*/
// Remember to uncomment `KEYMAP_SECTION_ENABLE = yes` in Makefile
#include "keymap_common.h"
#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
@bolasblack
bolasblack / rate_limit.clj
Created June 6, 2017 04:52
[limit concurrency operation with core.async]
(def RATE_LIMIT 5)
(defn operate [n]
(println "test-operate" n (.now js/Date))
(async/timeout 1000))
(defn -test []
(let [limit-chan (async/chan (- RATE_LIMIT 1))]
(go (doseq [n (range 20)]
(let [operate-chan (operate n)]
@bolasblack
bolasblack / report-boss.js
Last active June 5, 2017 07:49
[report boss]
const groups = $('#data-table > tbody').map((index, elem) => ({
title: $(elem).find('.group-title').text(),
entries: $(elem).find('.reports-table-children > tbody > tr').map((index, elem) => ({
title: $.trim($(elem).find('.col-title').text()),
time: parseFloat($.trim($(elem).find('.col-total').text()), 10)
})).toArray()
})).toArray()
groups.forEach(group => {
const groupedEntries = group.entries.reduce((memo, entry) => {
memo[entry.time > 1 ? 'isolate' : 'merge'].push(entry)
#!/usr/bin/env bash
# GistID: 9499613
# Example Makefile:
# npm :
# @echo "Check npm package update..."
# @CHECK_FILE=package.json STATE_FOLDER=node_modules bash scripts/update_manager.sh check; \
# if [ $$? -eq 1 ]; then \
# npm install \
# && npm update \
@bolasblack
bolasblack / example.js
Last active May 18, 2017 08:02
[Wirte once algorithm for sync & async function]
import co from 'co' // or whatever like co
import fetch from './fetch_data_synchronously'
import fetchAsync from './fetch_data_asynchronously'
export function process() {
const generator = processAlgorithmGenerator(fetch)
let next = { done: false }
while(!next.done) {
next = generator.next(next.value)
}
@bolasblack
bolasblack / cR.js
Last active May 18, 2017 07:56
[dot chain syntax for ramda.js]
import R from 'ramda'
class CR {
constructor(fn) {
this.runCR = (fn || R.identity)
}
}
R.keys(R).forEach(method => {
CR.prototype[method] = function() {
var rfn = arguments.length ? R[method].apply(null, arguments) : R[method]
@bolasblack
bolasblack / GuideColor.swift
Last active May 26, 2016 02:26
Colors from iOS Human Interface Guidelines
import UIKit
// Color from: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/ColorImagesText.html
class GuideColor {
static let cyan = UIColor(red: 90/255, green: 200/255, blue: 250/255, alpha: 1)
static let yellow = UIColor(red: 255/255, green: 204/255, blue: 0/255, alpha: 1)
static let orange = UIColor(red: 255/255, green: 149/255, blue: 0/255, alpha: 1)
static let pink = UIColor(red: 255/255, green: 45/255, blue: 85/255, alpha: 1)
static let blue = UIColor(red: 0, green: 122/255, blue: 255/255, alpha: 1)
static let green = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1)
# -*- coding: utf-8 -*-
description 'exec git push after save page'
Page.hook :after_commit do
Olelo.logger.info "push git history after save page"
git_path = Config[:repository][:git][:path]
response = `git --git-dir=#{git_path} --bare push origin master 2>&1`
if $?.success?
Olelo.logger.info "git history push success"
else