CentOS6の場合、デフォルトでPHP 5.3系が使用できるので、外部リポジトリのRemiを使わないでサーバー環境を構築し直した。
Remiリポジトリを使ってインストールしたMySQL、PHPをアンインストールする際、postfix、SASLとかも一端アンインストールさせないとインストールできない。
*.conf.rpmsaveとかアンインストール際残っているので、標準リポジトリでインストールしたあと、このファイルを*.confに戻してやれば問題なく復旧します。
2012年11月25日
から hiruta
Remiリポジトリを使わないでサーバー再構築 はコメントを受け付けていません
CentOS6の場合、デフォルトでPHP 5.3系が使用できるので、外部リポジトリのRemiを使わないでサーバー環境を構築し直した。
Remiリポジトリを使ってインストールしたMySQL、PHPをアンインストールする際、postfix、SASLとかも一端アンインストールさせないとインストールできない。
*.conf.rpmsaveとかアンインストール際残っているので、標準リポジトリでインストールしたあと、このファイルを*.confに戻してやれば問題なく復旧します。
2012年11月24日
から hiruta
テキストスクロール はコメントを受け付けていません
以下はjavafx scriptでテキストスクロールを実装している。javafx 2.0で使えるように実現してみた。なお、javafx 2.xではjavafx scriptは廃止される意向(Oracle)
Swing UIよりvisualなことが実現できるし、Java 8だとJavaFXが標準UIになることから、SwingUIを使っている場合はJavaFXにマイグレーションするのがよさそう。
JavaFx Animations – Auto text scrolling using Timeline and KeyFrame
public class TextScroll extends VBox { private Number x; private Number y; private double width; private double height; private Paint stroke; private Number strokeWidth; private Text scrollingText; public TextScroll() { Group root = new Group(); String scroll_char = "ここにスクロールする文字を入れる"; scrollingText = TextBuilder.create() .text(scroll_char) .layoutX(50) .textOrigin(VPos.TOP) .textAlignment(TextAlignment.JUSTIFY) .fill(Color.PINK) .font(Font.font("SansSerif", FontPosture.ITALIC, 25)) .build(); Group myGroup = GroupBuilder.create() .children(scrollingText) .clip(RectangleBuilder.create() .width(1000) .height(40) .build() ) .build(); width = scroll_char.length()* 20; root.getChildren().add(myGroup); this.getChildren().add(root); scrollUp(); } public boolean isScrollingText () { return true; } public void scrollUp () { autoTimer.play(); } public void stopScrolling () { autoTimer.stop (); } @SuppressWarnings("unchecked") private Timeline autoTimer = TimelineBuilder.create() .cycleCount(Timeline.INDEFINITE) .keyFrames(new KeyFrame( new Duration(10L), new EventHandler(){ public void handle(Event arg0) { if (scrollingText.getTranslateX() + width < 0) { scrollingText.setTranslateX(0.0); } // scrollingText.setTranslateY(scrollingText.getTranslateX()-0.5); scrollingText.setTranslateX(scrollingText.getTranslateX()-0.5); } } )).build(); }
2012年11月23日
から hiruta
Secure WordPressを導入しました。 はコメントを受け付けていません
2012年11月23日
から hiruta
Dropbox chooser はコメントを受け付けていません
Dropboxに保存されているファイルを選択できるエクスプロラーみたいなのが、ある。WEBアプリでDropboxと連携するものを作る場合使えそう。
https://www.dropbox.com/developers/chooser
動画など大容量ファイルを通常のWEBサーバーでは扱うのはトラフィック、負荷(アップロードサイズを上げることも可能だが、あまり上げ過ぎるとサーバーがメモリ不足が不安定になる)のことを考えるとAmazonS3に代表されるクラウド型ストレージを使うのが得策と思う。
CGIはperlの仕様上、アップロードサイズの制限はないようだが、大きすぎるファイルをアップロードすると、同じくメモリ不足になる可能性があります。プログラム側でサイズを制限するのが必須。
2012年11月23日
から hiruta
Dropbox java SDKにて認証情報をファイル(jsonフォーマット)への保存 はコメントを受け付けていません
Dropboxへ接続できるようにWEB認証を利用して認証情報をファイルに保存するサンプルになります。認証情報をファイルに保存しておくことでWEB認証しなくてもファイルのアップロードなどが行えるようになります。HTTP POSTでアップロードするとWEBサーバーの設定、スペックによりアップロードできない場合がありますが、HTTPを使用しないで行えばHTTP POSTの制約はなくなります。
AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET); WebAuthSession targetSession = new WebAuthSession(appKeys, WebAuthInfo authInfo = targetSession.getAuthInfo(); RequestTokenPair pair = authInfo.requestTokenPair; String url = authInfo.url; Desktop.getDesktop().browse(new URL(url).toURI()); JOptionPane.showMessageDialog(null, "Press ok to continue once you have authenticated."); String uid = targetSession.retrieveWebAccessToken(pair); State state = new State(appKeys); state.links.put(uid, targetSession.getAccessTokenPair()); state.save(STATE_FILE); }
// ------------------------------------------------------------------------ private static RuntimeException die(String message) { System.err.println(message); return die(); } private static RuntimeException die() { System.exit(1); return new RuntimeException(); } // ------------------------------------------------------------------------ // State model (load+save to JSON) public static final class State { public final AppKeyPair appKey; public final Map links = new HashMap(); public State(AppKeyPair appKey) { this.appKey = appKey; } public void save(String fileName) { JSONObject jstate = new JSONObject(); // Convert app key JSONArray japp = new JSONArray(); japp.add(appKey.key); japp.add(appKey.secret); jstate.put("app_key", japp); // Convert 'Link' objects (uid -> access token) JSONObject jlinks = new JSONObject(); for (Map.Entry link : links.entrySet()) { String uid = link.getKey(); AccessTokenPair access = link.getValue(); JSONArray jaccess = new JSONArray(); jaccess.add(access.key); jaccess.add(access.secret); jlinks.put(uid, jaccess); } jstate.put("links", jlinks); try { FileWriter fout = new FileWriter(fileName); try { jstate.writeJSONString(fout); } finally { fout.close(); } } catch (IOException ex) { throw die("ERROR: unable to save to state file \"" + fileName + "\": " + ex.getMessage()); } } public static State load(String fileName) { JsonThing j; try { FileReader fin = new FileReader(fileName); try { j = new JsonThing(new JSONParser().parse(fin)); } catch (ParseException ex) { throw die("ERROR: State file \"" + fileName + "\" isn't valid JSON: " + ex.getMessage()); } finally { fin.close(); } } catch (IOException ex) { throw die("ERROR: unable to load state file \"" + fileName + "\": " + ex.getMessage()); } try { JsonMap jm = j.expectMap(); JsonList japp = jm.get("app_key").expectList(); AppKeyPair appKey = new AppKeyPair(japp.get(0).expectString(), japp.get(1).expectString()); State state = new State(appKey); JsonMap jlinks = jm.get("links").expectMap(); for (Map.Entry jlink : jlinks) { JsonList jaccess = jlink.getValue().expectList(); AccessTokenPair access = new AccessTokenPair(jaccess.get(0).expectString(), jaccess.get(1).expectString()); state.links.put(jlink.getKey(), access); } return state; } catch (JsonExtractionException ex) { throw die ("ERROR: State file has incorrect structure: " + ex.getMessage()); } } } public static final class Link { public final String uid; public final AccessTokenPair accessToken; public Link(String uid, AccessTokenPair accessToken) { this.uid = uid; this.accessToken = accessToken; } } private static String getLinkid(String fileName) { JsonThing j; String linkid = ""; try { FileReader fin = new FileReader(fileName); try { j = new JsonThing(new JSONParser().parse(fin)); } catch (ParseException ex) { throw die("ERROR: State file \"" + fileName + "\" isn't valid JSON: " + ex.getMessage()); } finally { fin.close(); } } catch (IOException ex) { throw die("ERROR: unable to load state file \"" + fileName + "\": " + ex.getMessage()); } try { JsonMap jm = j.expectMap(); JsonMap jlinks = jm.get("links").expectMap(); for (Map.Entry jlink : jlinks) { linkid = jlink.getKey(); break; } return linkid; } catch (JsonExtractionException ex) { throw die ("ERROR: State file has incorrect structure: " + ex.getMessage()); } } }