Skip to content

Instantly share code, notes, and snippets.

View ryo88c's full-sized avatar
🤩

HAYASHI Ryo ryo88c

🤩
View GitHub Profile
@ryo88c
ryo88c / translate.js
Created August 15, 2023 11:05
指定したDOM配下の任意の文字列を置換する関数
export default (rootElement, lang = 'ja') => {
const texts = [
{
before: new RegExp('Parallel translation', 'g'),
after: { ja: '対訳' }
},
];
const translate = node => {
@ryo88c
ryo88c / auth.js
Last active August 29, 2015 14:06
Authenticate WordPress by Node.js (Socket.IO) ref: http://qiita.com/ryo88c/items/bf255343d6e54259cd2a
// For database connection.
var DSN = '';
// WordPress database name.
var WPDB = '';
// Salt constants in wp-config.php.
var LOGGED_IN_KEY = '';
var LOGGED_IN_SALT = '';
// siteurl option in wp_options table.
var SITEURL = 'http://example.com/';
@ryo88c
ryo88c / dot.rb
Created September 1, 2014 09:06
Dot drawer plugin on Jekyll and Octopress.
# Title: Dot drawer
# Author: Ryo HAYASHI <ryo88c@gmail.com>
#
# Syntax:
# {% dot %}
# dotCode
# {% enddot %}
require 'open3'
require './plugins/raw'
@ryo88c
ryo88c / listing.py
Last active August 29, 2015 13:58
Sublime text で開いているタブを開くコマンドリストをクリップボードに保存するプラグイン ref: http://qiita.com/ryo88c/items/cb4dfdcb6b5eb401fe85
import sublime, sublime_plugin
class ListingCommand(sublime_plugin.TextCommand):
def run(self, edit):
list = []
for x in range(0, self.view.window().num_groups()):
for file in self.view.window().views_in_group(x):
if file.file_name() == None:
continue
list.append('subl "%s"\n' % file.file_name())
@ryo88c
ryo88c / 0_reuse_code.js
Created March 20, 2014 05:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# CTags based autocompletion plugin for Sublime Text 2
# You can add the file to the User Package in ~/Library/Application Support/Sublime Text 2/Packages and restart Sublime Text 2.
# generate the .tags file in your project root with "ctags -R -f .tags"
import sublime, sublime_plugin, os
class AutocompleteAll(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
tags_path = view.window().folders()[0]+"/.tags"
@ryo88c
ryo88c / InsufficientScope.php
Created July 17, 2012 09:05
Example of "OAuth 2.0 Bearer" end point, using the BEAR.Saturday
<?php
class App_Exception_OAuth_InsufficientScope extends BEAR_Exception{
protected $_defaultMessage = 'This request is insufficient scope.';
protected $_default = array('code' => 'insufficient_scope');
public function __construct($msg = null, array $config = array()){
if(empty($msg)){
$msg = $this->_defaultMessage;
}
$config = array_merge($this->_default, (array) $config);
@ryo88c
ryo88c / Lock.php
Created March 30, 2012 01:54
[BEAR] 排他ロックする around アドバイス
<?php
class App_Aspect_Lock implements BEAR_Aspect_Around_Interface{
public function around(array $values, BEAR_Aspect_JoinPoint $joinPoint){
$lock = sprintf('%s/tmp/locks/%s', _BEAR_APP_HOME, sha1(serialize($joinPoint->getMethodReflection())));
if(!file_exists($lock)){
touch($lock);
}
if(file_get_contents($lock)){
return false;
}
@ryo88c
ryo88c / gist:1809886
Created February 12, 2012 17:49
結果を JSON として返すための output ハンドラ
<?php
/**
* JSON出力
*
* @param array $values 値
* @param array $options オプション
* @return BEAR_Ro
* @author Ryo HAYASHI<ryo88c at gmail.com>
* @version 1.0.0
* App/Resource/output/json.php
@ryo88c
ryo88c / tpl2php.php
Created January 2, 2012 14:35
Generated translation resources from the Smarty tags
#!/usr/local/bin/php -qn
<?php
/**
* Generated translation resources from the Smarty tags
* Tag: <!--t "STRING"-->
*
* @author Ryo HAYASHI <ryo88c at gmail.com>
*/
class tpl2php{