Skip to content

Instantly share code, notes, and snippets.

module Jpmobile::Mobile
class Au < AbstractMobile
def supports_cookie?
if @request.protocol =~ /\Ahttps/
false
else
true
end
end
end
@oukayuka
oukayuka / inputmode.rb
Created July 23, 2009 09:03
Setting default input mode to text form for mobile client.
module ActionView
module Helpers
module FormHelper
alias :text_field_without_inputmode :text_field
# ==== Options
# * <tt>:inputmode</tt> - 入力モード。Jpmobile::InputMode::HIRAGANA-全角ひらがな、Jpmobile::InputMode::HANKAKUKANA-半角カナ、Jpmobile::InputMode::ALPHABET-半角英字、Jpmobile::InputMode::NUMERIC-半角数字
# ==== Examples
# text_field_tag(:user, :name, :size => 20, :inputmode => Jpmobile::InputMode::HIRAGANA)
# # => <input id="name" name="name" type="text" size="20" istyle="1" style="-wap-input-format:&quot;&lt;ja:h&gt;&quot;">
@oukayuka
oukayuka / fb_test_users.sh
Created July 7, 2011 01:49
A shell Script that creates/reads/deletes Facebook app test users.
#!/bin/sh
CLIENT_ID={MY_CLIENT_ID} # Please EDIT
CLIENT_SECRET={MY_CLIENT_SECRET} # Please EDIT
# handling params
MODE="READ"
if [ $# -eq 1 ]; then
if [ $1 = "-c" ]; then
MODE="CREATE"
else
@oukayuka
oukayuka / trgm.patch
Last active December 17, 2015 07:29
PostgreSQLのpg_trgmでマルチバイト文字を使えるようにするためのHomebrewパッチ。
--- a/contrib/pg_trgm/trgm.h 2013-05-14 11:20:48.000000000 +0900
+++ b/contrib/pg_trgm/trgm.h 2013-05-14 11:20:42.000000000 +0900
@@ -12,7 +12,7 @@
/* options */
#define LPADDING 2
#define RPADDING 1
-#define KEEPONLYALNUM
+/* #define KEEPONLYALNUM */
/*
* Caution: IGNORECASE macro means that trigrams are case-insensitive.
@oukayuka
oukayuka / tslint.json
Created February 12, 2018 05:34
My TSLint configuration
{
"extends": [
"tslint:latest",
"tslint-config-airbnb",
"tslint-config-prettier",
"tslint-eslint-rules",
"tslint-react"
],
"rulesDirectory": [
"tslint-plugin-prettier"
@oukayuka
oukayuka / keybindings.json
Last active April 26, 2018 06:23
VSCode Vim plugin undo / redo settings
[
{
"key": "ctrl+]",
"command": "extension.vim_escape",
"when": "editorTextFocus"
},
{
"key": "ctrl+e",
"command": "workbench.action.toggleSidebarVisibility"
},
@oukayuka
oukayuka / axiosInterceptor.ts
Last active April 9, 2019 09:17
axios のレスポンスからスネークケースのキーをキャメルケースに変換して、日付をDateTimeオブジェクトにする
import { AxiosResponse } from 'axios';
import { camel } from 'change-case';
import { isArray, isObject, isString } from 'lodash';
import { DateTime } from 'luxon';
export const reform = (
obj: object,
keyConverter: (k: string) => string,
): any => {
if (isArray(obj)) {
@oukayuka
oukayuka / InfinitScroll.tsx
Last active November 9, 2019 01:51
Infinit scroll component sample with React Hooks
import React, { FC, useEffect, useRef } from 'react';
import ListLoader from '../atoms/ListLoader';
type InfinitScrollProps = {
loadMore?: () => void;
hasMore?: boolean;
isLoading?: boolean;
threshold?: number;
};
@oukayuka
oukayuka / use-find-book.ts
Last active December 7, 2019 09:30
findBook() をコールする Custom Hook
import { useContext, useEffect, useRef, useState } from 'react';
import { Book } from 'domains/mangarel/models/book';
import findBook from 'domains/mangarel/services/find-book';
import { FirebaseContext } from 'contexts';
const useFindBook = (id: string) => {
const [book, setBook] = useState<Book>();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<Error | null>(null);
@oukayuka
oukayuka / findBooks.ts
Created December 10, 2019 11:04
Firestore のスナップショットをいい感じにキャッシュしてくれるライブラリの構想
import { getByQuery, strategies } from 'firestore-snapbox';
const maxEntries = 100;
const maxAgeSeconds = 60 * 60;
const expiredDate = new Date(2020, 0, 10, 15);
const snap = await getByQuery(query, strategies.CacheFirst, { maxEntries, maxAgeSeconds, expiredDate });
const books = snap.docs.map(doc => { ...doc, id: doc.id } as Book);