Skip to content

Instantly share code, notes, and snippets.

var kit = require('nokit');
var _ = kit._;
var Promise = kit.Promise;
/**
* A simple openstack client.
* @param {Object} opts
* ```js
* {
#!/usr/bin/env python
# Question:
# If user_1 followed user_2, we will get an array item like:
# [id_1, id_2]
# Here is a sample user relationship list:
# [ [2, 3], [1, 4], [3, 2], [1, 3], [4, 2], [7, 2], [5, 3], [4, 1] ]
# If two items have two same IDs, print one of the them out.
# So if we print out [3, 2] and [1, 4], that should be a right result.
nobone = require 'nobone'
{kit, renderer} = nobone { renderer: {} }
kit.watch_dir {
dir: '.'
pattern: ['*/', '*.styl']
handler: (type, path) ->
kit.log path
renderer.render(path, '.css', {}, false)
@ysmood
ysmood / https_example.coffee
Last active August 29, 2015 14:16
https example
###
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
###
{ kit } = require 'nobone'
@ysmood
ysmood / shortest_mp3.js
Created April 21, 2015 10:49
shortest mp3
dataUri = 'data:audio/mpeg3;base64,SUQzAwAAAAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4xjAAAAAAlwAAAAAtASxAAAAAAAARQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4xjAMQAAAlwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4xjAbAAAAlwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
Promise_Yaku = require '../src/yaku'
Promise_Bird = require 'bluebird'
Promise_Yaku.enableLongStackTrace()
Promise_Bird.longStackTraces()
test = (Promise) ->
Promise.resolve()
.then ->
a()
function (opts, data, method, headers) {
if (_.isString(opts))
opts = { url: opts };
opts = _.defaults(opts, {
method: method || 'GET',
data: data || null,
header: headers || {},
statusFilter: function (status) {
return status < 300;
var Observable = require('yaku/lib/Observable')
var Promise = require('bluebird');
var assert = require('assert');
function mkTransaction(tId) {
var queries = []
return {
query: function query(q) { queries.push(q); return query },
close: function() { queries.push('close ' + tId); return queries; }
}
@ysmood
ysmood / gplus-auto-hide-photo-comment.css
Last active December 17, 2015 14:39
Auto-hide the googleplus's photo comment column.
.KmGBLb {
right: -300px !important;
z-index: 1004;
-webkit-transition: all .15s cubic-bezier(0,1.12,.39,.98);
-moz-transition: all .15s cubic-bezier(0,1.12,.39,.98);
-ms-transition: all .15s cubic-bezier(0,1.12,.39,.98);
-o-transition: all .15s cubic-bezier(0,1.12,.39,.98);
transition: all .15s cubic-bezier(0,1.12,.39,.98);
}
.KmGBLb:hover {
@ysmood
ysmood / cocoa_launchApp.m
Created June 24, 2013 18:45
Example: Cocoa launch application via path.
+ (void) launchApp:(NSString *)path {
NSURL *url = [NSURL fileURLWithPath:path];
NSError *err = nil;
if ([url checkResourceIsReachableAndReturnError:&err]) {
[[NSWorkspace sharedWorkspace] launchApplication:[url path]];
} else {
NSLog(@"%@", [err localizedDescription]);
}
}