Skip to content

Instantly share code, notes, and snippets.

from mezzanine.conf import register_setting
###########################
# FOR CLEAN_BLOG SETTINGS #
###########################
register_setting(
name="TEMPLATE_ACCESSIBLE_SETTINGS",
description=("Sequence of setting names available within templates."),
editable=False,
default=("TWITTER_ACCOUNT_NAME",
# -*- coding:utf-8 -*-
#!/usr/bin/python
"""
top_2_csv.py
linux top コマンドのアウトプットをgraph出力用途にcsvに変換する
"""
__author__ = "ken sakurai"
__status__ = "development"
@kemsakurai
kemsakurai / WebApplication.java
Created January 19, 2017 14:15
wicket devutils に含まれるページをMountするために以下のコードを書いたが、listページがあってそのページのみMountすればよかったので、捨てたコード
try {
// Directory配下のtaskを取得する
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) {
if (info.getName().startsWith("org.apache.wicket.devutils.")) {
final Class<?> clazz = info.load();
if (Page.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers()) && isExistsDefalutConstructor(clazz)) {
String simplaName = clazz.getSimpleName();
mountPage("/development/" + simplaName, (Class<? extends Page>) clazz);
}
@kemsakurai
kemsakurai / WebApplication.java
Created January 19, 2017 14:18
classがデフォルトコンストラクターを保持するかBooleanで返す
public boolean isExistsDefalutConstructor(Class<?> clazz) {
try {
clazz.getConstructor(null);
return true;
} catch (NoSuchMethodException e) {
return false;
}
}
@kemsakurai
kemsakurai / git_init.md
Last active January 22, 2017 08:06
GIthub Repository フォーク後、PullRequest作成までに実行するコマンドのメモ書き

Github の repository folk 後に、打つコマンド

remote リポジトリを upsteam ブランチとして追加

git remote add upstream git://git.apache.org/wicket.git

ブランチのリスト取得 upstream が作成されたことを確認

git branch -a
@kemsakurai
kemsakurai / StatelessChecker.java
Created January 22, 2017 08:13
StatelessCheckerはStatefulだと、Exceptionなのでログを吐くようにした。
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@kemsakurai
kemsakurai / ResponsePageEx.java
Last active February 4, 2017 13:03
javascriptのlocation.replaceを実行するResponsePage.java
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@kemsakurai
kemsakurai / WebApplication.java
Created February 17, 2017 11:48
Wicket Ajax Request Exception 発生時の振る舞いを切り替える
getExceptionSettings().setAjaxErrorHandlingStrategy(ExceptionSettings.AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);
@kemsakurai
kemsakurai / StatelessAjaxPreventSubmitBehavior
Created March 11, 2017 03:07
StatelessAjaxPreventSubmitBehavior を作成しましたが、`AjaxCallListener` がStatefull のためStatelessにはならなかった。
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxCallListener;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.wicketstuff.stateless.behaviors.StatelessAjaxEventBehavior;
/**
@kemsakurai
kemsakurai / StatelessAjaxFormValidatingBehavior.java
Created March 11, 2017 03:14
FeedbackPanel を一緒に使用する際は、FeedbackPanel#setMarkupId() でwicket id と同じ名称でid を設定したところ、上手く動作しました
import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.attributes.ThrottlingSettings;
import org.apache.wicket.ajax.form.AjaxFormValidatingBehavior;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.feedback.IFeedback;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;