Skip to content

Instantly share code, notes, and snippets.

View ajchemist's full-sized avatar
🕶️

ajchemist

🕶️
  • Korean Peninsula
View GitHub Profile
@ajchemist
ajchemist / a.cpp
Created March 30, 2015 13:16
MFC utilities
char* ConvertUnicodeToMultybyte(CString strUnicode)
{
int nLen = WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, NULL, 0, NULL, NULL);
char* pMultibyte = new char[nLen];
memset(pMultibyte, 0x00, (nLen)*sizeof(char));
WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, pMultibyte, nLen, NULL, NULL);
return pMultibyte;
(defun check-expansion ()
(save-excursion
(cond ((looking-at "\\_>") t)
((unless (bobp) (backward-char 1) (looking-at "\\.")) t)
((unless (bobp) (backward-char 1) (looking-at "->")) t)
(t nil))))
(defun smart-tab (&optional prefix)
"This smart tab is minibuffer compliant: it acts as usual in
the minibuffer. Else, if mark is active, indents region. Else if
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
window.WebSocket = window.WebSocket || window.MozWebSocket;
var websocket = new WebSocket('ws://127.0.0.1:9999','dumb-increment-protocol');
websocket.onopen = function () {
(defn listen-cigarette-burn []
(if-let [cigaburn-dom (dom/getElement "cigarette-burn")]
(events/listen
cigaburn-dom
EventType.MOUSEMOVE
(fn [_]
(if-let [noticenter-dom (dom/getElement "notification-center")]
(when-not (classes/has noticenter-dom "reveal")
(classes/addRemove noticenter-dom "unreveal" "reveal")
;; (events/listenOnce
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html;">
<link href="app.gss" rel="stylesheet/gss" type="text/gss">
</head>
<body>
<img id="cassowaryImg" src="http://gridstylesheets.org/assets/images/Intro/CassowaryBird.png" />
<h1>Hello!</h1>
function sendPacket(stream, buffer)
{
var prefix = new Buffer(4);
var length = buffer.length;
var offset = 0;
// serialize 32bit little endian unsigned int
prefix[offset++] = length & 0xff;
prefix[offset++] = (length >> 8) & 0xff );
prefix[offset++] = (length >> 16) & 0xff );
prefix[offset++] = (length >> 24) & 0xff );
(defn ->kebab [s]
(str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s))))
(def components '[Card AppBar LeftNav CardTitle])
(defn gen-wrapper [component]
`(defmacro ~(symbol (->kebab (str component))) [& args#]
(let [[opts# & [children#]] (if (-> args# first map?)
[(first args#) (rest args#)]
[nil args#])]
@ajchemist
ajchemist / pubsub.clj
Last active August 29, 2015 14:27
core.async
#_(boot.core/set-env!
:dependencies
'[[org.clojure/core.async "0.1.346.0-17112a-alpha" :scope "provided"]])
;; https://github.com/clojure/core.async/wiki/Pub-Sub
(ns async
(:refer-clojure :exclude [reduce map into partition partition-by merge take])
(:use clojure.core.async))
@ajchemist
ajchemist / loader.html
Created August 22, 2015 10:12
loader.html
<html>
<body>
<style>
body {background-color: #fcfcfc;}
#main, footer {padding-left: 240px;}
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
@ajchemist
ajchemist / delicious.js
Last active August 29, 2015 14:27 — forked from johnjohndoe/delicious.js
Bookmarklet of delicious.com. Latest version available at https://delicious.com/tools. This Gist tracks the changes made to the script. Javascript is formatted in Sublime Text using the Javascript Beautify package. - The authors of the script are the guys from Delicious.
javascript: (function(e, t) {
var n = e.document;
setTimeout(function() {
function a(e) {
if (e.data === "destroy_bookmarklet") {
var r = n.getElementById(t);
if (r) {
n.body.removeChild(r);
r = null
}