Skip to content

Instantly share code, notes, and snippets.

@Johniel
Johniel / typo-fix.el
Created July 22, 2014 03:02
タイポしすぎぃ!
;; 怒りのタイポ修正
;; http://d.hatena.ne.jp/kitokitoki/20091124/p2
(defun delete-word (arg)
"Delete characters forward until encountering the end of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (forward-word arg) (point))))
;; http://d.hatena.ne.jp/kitokitoki/20091124/p2
@Johniel
Johniel / list.cpp
Last active August 29, 2015 13:56
container_of怖い
#include <iostream>
#include <vector>
using namespace std;
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define list_entry(ptr, type, member) container_of(ptr, type, member)
#define container_of(ptr, type, member) ({ \
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var container, stats;
var camera, scene, renderer;
var mesh;
init();
animate();
@Johniel
Johniel / appearance.el
Created July 27, 2013 23:04
以前のfaceの設定
(when window-system
(eval-safe
;; (add-to-list 'default-frame-alist '(alpha . (95 80)))
(add-to-list 'default-frame-alist '(foreground-color . "ivory"))
(add-to-list 'default-frame-alist '(background-color . "#2D0922"))
(add-to-list 'default-frame-alist '(cursor-color . "purple2"))
(set-face-background 'region "RoyalBlue4")
(set-face-background 'cua-rectangle "DodgerBlue4")
(set-face-foreground 'mode-line "white")
(set-face-background 'mode-line "#2d2d30")
@Johniel
Johniel / ガ出力
Last active December 19, 2015 10:59
インデントを足した
((class ClassName
(f :: int -> char -> float -> string)
(g :: void -> double))
(struct StructName : []
(n:int)
(s:string))
(struct Klass : [ClassName, ]
(m:int)
(t:string))
(add :: int(a) -> int(b) -> int
@Johniel
Johniel / core.clj
Created June 10, 2013 23:08
taplの3章?
(ns tapl.core
(:require [instaparse.core :as insta]))
(def my-parser
(insta/parser
"<T> := 'true' | 'false' | '0' |
'succ'<space>T | 'pred'<space>T | 'iszero'<space>T |
'if'<space>T<space>'then'<space>T<space>'else'<space>T;
space := #'\\s';"))
@Johniel
Johniel / r.txt
Created March 2, 2013 08:51
reducersをブン回す
user=> (clojure-version)
"1.4.0"
user=> (require '[clojure.math.numeric-tower :as math])
nil
user=> (for [n (range 0 26)]
#_=> (let [v (vec (range 0 (math/expt 2 n)))]
#_=> (do (System/gc)
#_=> (time (reduce + (filter even? (map #(mod % 2) v)))))))
("Elapsed time: 0.272565 msecs"
@Johniel
Johniel / tabbar+.el
Created December 18, 2012 01:22
tabbar.el extension
;;; tabbar+.el --- Tabbar extensions
;; Copyright (C) 2012
;; Author:
;; Keywords:
;; Version 0.2.2
;;; Commentary:
@Johniel
Johniel / ytl-linker.el
Created December 6, 2012 07:47
@yutoppはリンカ作成に失敗しました。
(defun sort-lines-random (beg end)
"Sort lines in region randomly."
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(let ;; To make `end-of-line' and etc. to ignore fields.
((inhibit-field-text-motion t))
(require 'linum)
(require 'whitespace)
(defface linum-hidden-face '((t :inherit (shadow default))) nil)
(set-face-attribute
'linum-hidden-face nil
:foreground (assoc-default 'background-color default-frame-alist))
(defun ytl-hide-spaces (str)