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 / UserSearchForm.tsx
Last active October 10, 2021 08:34
Formik sample with TypeScript
import { InjectedFormikProps, withFormik } from 'formik';
import * as React from 'react';
import * as Yup from 'yup';
interface FormValues {
login: string;
}
interface FormProps {
login?: string;
@oukayuka
oukayuka / FlashMessage.tsx
Last active August 6, 2020 12:39
Recompose withStateHandlers with TypeScript
import * as React from 'react';
import { compose, lifecycle, pure, StateHandler, StateHandlerMap, withStateHandlers } from 'recompose';
import { Message, Transition } from 'semantic-ui-react';
import './FlashMessage.css';
export interface FlashMessageProps {
message: string;
isWarning?: boolean;
}
@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;
};