Skip to content

Instantly share code, notes, and snippets.

@miyucy
miyucy / faker-markdown.rb
Last active August 29, 2015 13:56
faking markdown sentence
require 'faker'
module Faker
class Markdown < Lorem
class << self
def sentence(*args)
super[0..-2]
.gsub(/[^ ]+/) { |m| modify m }
.sub(/\A /, '')
.sub(/ \z/, '') + '.'
require 'tmpdir'
require 'timeout'
require 'erb'
require 'rack'
require 'rack-livereload'
require 'redcarpet'
require 'pygments'
require 'eventmachine'
require 'em-websocket'
#!/bin/bash
function funcA() {
ROOM=foo
}
function funcB() {
echo $ROOM
}
funcA && funcB
require 'strscan'
module Parser
E = %r'='.freeze
NE = %r'[^=]+'.freeze
Q = %r'"'.freeze
NQ = %r'[^"]+'.freeze
S = %r'\s'.freeze
NS = %r'\S+'.freeze
(with-eval-after-load 'web-mode
(dolist (face-name (face-list))
(if (face-italic-p face-name)
(message "%s" face-name)))
;; イタリックを解除する
(let ((italic-web-mode-faces (delq nil (mapcar '(lambda (face-name)
(if (and (face-italic-p face-name)
(string-match "^web-mode-" (symbol-name face-name)))
face-name)) (face-list)))))
(dolist (face-name italic-web-mode-faces)
@miyucy
miyucy / generator.rb
Created December 12, 2014 07:58
country2language
require 'yaml'
require 'ostruct'
require 'nokogiri'
require 'open-uri'
xml = Nokogiri::XML(open('http://unicode.org/repos/cldr/trunk/common/supplemental/supplementalData.xml'))
# https://github.com/AtelierConvivialite/locale_data/blob/master/data/cldr_1.9.1/common/dtd/ldmlSupplemental.dtd#L76-L83
# https://github.com/AtelierConvivialite/locale_data/blob/master/data/cldr_1.9.1/common/dtd/ldmlSupplemental.dtd#L90-L97
Backbone.localForage = {}
Backbone.localForage.sync = (prefix) ->
(method, model, options) ->
options.success ?= ->
options.error ?= ->
save = (key, options) ->
localforage.setItem key, model.toJSON(), (err, val) ->
if err
options.error err
else
@miyucy
miyucy / find_each.rb
Created December 21, 2014 08:40
Stripe::APIOperations::List::ClassMethods.find_each
module Stripe
module APIOperations
module List
module ClassMethods
def find_each(filters={}, api_key=nil, &block)
loop do
list = all(filters, api_key).tap { |e| e.each(&block) }
break unless list.has_more
filters = filters.merge(starting_after: list.data.last.id)
end
Thu, 08 Jan 2015 00:00:00 EST -05:00 : Thu, 08 Jan 2015 05:00:00 UTC +00:00
Thu, 08 Jan 2015 01:00:00 EST -05:00 : Thu, 08 Jan 2015 06:00:00 UTC +00:00
Thu, 08 Jan 2015 02:00:00 EST -05:00 : Thu, 08 Jan 2015 07:00:00 UTC +00:00
Thu, 08 Jan 2015 03:00:00 EST -05:00 : Thu, 08 Jan 2015 08:00:00 UTC +00:00
Thu, 08 Jan 2015 04:00:00 EST -05:00 : Thu, 08 Jan 2015 09:00:00 UTC +00:00
Thu, 08 Jan 2015 05:00:00 EST -05:00 : Thu, 08 Jan 2015 10:00:00 UTC +00:00
Thu, 08 Jan 2015 06:00:00 EST -05:00 : Thu, 08 Jan 2015 11:00:00 UTC +00:00
Thu, 08 Jan 2015 07:00:00 EST -05:00 : Thu, 08 Jan 2015 12:00:00 UTC +00:00
Thu, 08 Jan 2015 08:00:00 EST -05:00 : Thu, 08 Jan 2015 13:00:00 UTC +00:00
Thu, 08 Jan 2015 09:00:00 EST -05:00 : Thu, 08 Jan 2015 14:00:00 UTC +00:00
require 'spec_helper'
class Doc
include MongoMapper::Document
one :em_doc
timestamps!
ensure_index [['em_doc.foo', Mongo::ASCENDING]]
end