Skip to content

Instantly share code, notes, and snippets.

View ymkjp's full-sized avatar
:shipit:
while true

Kenta Long Yamamoto ymkjp

:shipit:
while true
View GitHub Profile
@ymkjp
ymkjp / custom.css
Created September 3, 2016 10:36
WordPress /wp-admin/themes.php?page=editcss
@import "https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css";
/*
Welcome to Custom CSS!
To learn how this works, see http://wp.me/PEmnE-Bt
*/
.entry-content h1, .entry-content h2, .entry-content h3, .entry-content h4 {
font-weight: bolder;
}
@ymkjp
ymkjp / batch_transaction.rb
Created August 4, 2016 09:43
Update with transaction
pool = []
User.find_in_batches do |users|
pool << users.map(&:call_heavy_method)
end
User.transaction do
success = pool.flatten(1).map(&:save)
raise ActiveRecord::Rollback unless success.all?
end
{
"created_at": "Tue Aug 02 07:19:23 +0000 2016",
"id": 760374420292591600,
"id_str": "760374420292591618",
"text": "え,そうだっけ?w\n南国気分で気持ちよさそう https://t.co/OSeqImXfkP",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
@ymkjp
ymkjp / gist:dd121e0ed2818287871376b4b7d7c8a8
Created July 26, 2016 02:01
NameError: undefined local variable or method `item' for #<Class:0x007feb931cf8a0>
** Invoke redis_search:index:model (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redis_search:index:model
Redis-Search index data to Redis from [Keyword]
..................................................................................................................................................................................................................................................................................rake aborted!
NameError: undefined local variable or method `item' for #<Class:0x007feb931cf8a0>
/usr/local/var/rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
/usr/local/var/rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/redis-search-1.0.2/lib/redis-search/base.rb:155:in `block in redis_search_index_batch_create'
/usr/local/var/rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation/batches.rb:124:in `find_in_batches'
@ymkjp
ymkjp / brew_doctor
Last active February 15, 2016 09:51
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Putting non-prefixed coreutils in your path can cause gmp builds to fail.
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
@ymkjp
ymkjp / LENB.js
Created February 9, 2016 08:25 — forked from hyamamoto/LENB.js
Google Doc & Spreadsheets's LENB() function which is present in Microsoft Excel. LENB() returns a number of bytes, while LENH() returns a width of the given text. These functions are useful when you check if your translation resources can be fit inside original screens.
// To add these functions to your Google Doc documents,
// see https://developers.google.com/apps-script/guides/sheets/functions
/**
* @fileOverview Google Doc Apps Script: LENB() / LENH() functions for Spreadsheet.
* @author Hiroshi Yamamoto (higon@freepress.jp)
* @license <a href="http://www.wtfpl.net/">WTFPL version 2.0</a>
* @version 0.2.0
*/
/**
Hey Jude
https://en.wikipedia.org/wiki/Hey_Jude
*/
/**
Words
*/
name_of(jude, "Jude").
hey(Person, Sentence) :-
ja:
devise_token_auth:
sessions:
not_confirmed: "'%{email}' に確認用のメールを送信しました。メール内の説明を読み、アカウントの有効化をしてください。"
bad_credentials: "ログイン用の認証情報が正しくありません。再度お試しください。"
not_supported: "/sign_in に GET はサポートされていません。POST をお使いください。"
user_not_found: "ユーザーが見つからないか、ログインしていません。"
token_validations:
invalid: "ログイン用の認証情報が正しくありません。"
registrations:
@ymkjp
ymkjp / elb_update_cert.sh
Last active January 22, 2016 06:05 — forked from hidekuro/elb_update_cert.sh
Fetch certification from Let's Encrypt → Upload to IAM → Set it up to ELB
#!/bin/bash
# https://gist.github.com/ymkjp/4f54ecb3446fa42ff2a8
set -e
cd $(dirname $0)
# Current date YYYYMMDD_HHMMSS
DATE_CURRENT_YMD=$(date '+%Y%m%d_%H%M%S')
# AWS Profile
@ymkjp
ymkjp / ViewController.swift.diff
Created September 24, 2015 12:11
NewsPlayer/ViewController.swift
diff --git a/NewsPlayer/ViewController.swift b/NewsPlayer/ViewController.swift
index 55fe627..ecdcd7e 100644
--- a/NewsPlayer/ViewController.swift
+++ b/NewsPlayer/ViewController.swift
@@ -205,9 +205,13 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
}
func initVideoCell(indexPath: NSIndexPath) -> VideoTableViewCell {
- videoTable.registerNib(UINib(nibName: cellName, bundle:nil), forCellReuseIdentifier:cellName)
- return videoTable.dequeueReusableCellWithIdentifier(