こんにちは。今回は現実逃避を兼ねて Jade の素晴らしさをお伝えしたいと思います。
[Jade][0] は JST (JavaScript Templates) の一つであり、HTML を書くための[軽量マークアップ言語][1] である [Haml][2] に影響を受けた JavaScript テンプレートエンジンでもあります。
#!/usr/bin/env python | |
""" | |
This module will bootstrap a machine using chef. The purpose of this | |
script is actually to work with AWS Auto Scaling Groups. The user data | |
for the Launch Configuration is set to download this script and then | |
run it. This is also stores the results in a private gist and sends | |
a message to logstash with the results. | |
""" |
/* | |
* Simple MD5 implementation | |
* | |
* Compile with: gcc -o md5 -O3 -lm md5.c | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#coding: utf8 | |
""" | |
1. Download this gist. | |
2. Get the MNIST data. | |
wget http://deeplearning.net/data/mnist/mnist.pkl.gz | |
3. Run this code. | |
python autoencoder.py 100 -e 1 -b 20 -v | |
""" | |
import numpy | |
import argparse |
#!/bin/bash | |
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/ | |
set -e | |
sourceApp="$1" | |
targetApp="$2" | |
while read key value; do |
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath { | |
return @"More"; | |
} | |
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me..."); | |
// Hide the More/Delete menu. | |
[self setEditing:NO animated:YES]; | |
} |
import Foundation | |
extension NSData { | |
func MD5() -> NSString { | |
let digestLength = Int(CC_MD5_DIGEST_LENGTH) | |
let md5Buffer = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLength) | |
CC_MD5(bytes, CC_LONG(length), md5Buffer) | |
var output = NSMutableString(capacity: Int(CC_MD5_DIGEST_LENGTH * 2)) | |
for i in 0..<digestLength { |
// Based on Swift 1.2, ObjectMapper 0.15, RealmSwift 0.94.1 | |
// Author: Timo Wälisch <timo@waelisch.de> | |
import UIKit | |
import RealmSwift | |
import ObjectMapper | |
import SwiftyJSON | |
class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType { | |
typealias Object = List<T> |
private val HEX_CHARS = "0123456789ABCDEF".toCharArray() | |
fun ByteArray.toHex() : String{ | |
val result = StringBuffer() | |
forEach { | |
val octet = it.toInt() | |
val firstIndex = (octet and 0xF0).ushr(4) | |
val secondIndex = octet and 0x0F | |
result.append(HEX_CHARS[firstIndex]) |
usage: | |
------ | |
// include codemirror.js, addon/mode/overlay.js | |
// include async typo.js from https://github.com/cfinke/Typo.js/pull/45 | |
// include loadTypo.js from: https://github.com/cfinke/Typo.js/pull/50 | |
// loading typo + dicts takes a while so we start it first | |
// hosting the dicts on your local domain will give much faster loading time | |
// english dictionaries taken from https://github.com/cfinke/Typo.js/pull/47 |