play 2.3 で securesocial3.0 を使う

公式のドキュメントが古いので、使い方をまとめる。 手順 securesocialを導入する 設定 1.導入 1.1 build.sbt の libraryDependencies に securesocialを追加 libraryDependencies ++= Seq( ... "securesocial" %% "securesocial" % "3.0-M3" , ... ) conf/r…

play.api.libs.json.JsonでオブジェクトをJson化

case class Human(lastName: String, firstName: String, age: Int) こいつをJsonに変換しようと思います。結果からいうとこういうソースになります。 case class Human(lastName: String, firstName: String, age: Int) { implicit val humanWrites = new W…

Scalaでpostリクエスト

actorでpostしたいと思って、ぐぐったらまっさきにこれが出てきた。 http://alvinalexander.com/scala/scala-http-post-json-gson-restful-client-exampleapache httpclient を使っている。しかし、少し回りくどい気がする。。。そこで、もう少し探していた…

pythonのrequestsでfc2動画にログインする

fc2動画のリンク切れチェックのために、ログインして動画のページをスクレイピングする必要があったので、めもPython Requests and persistent sessions - Stack Overflowようはここを見ろと import requests session def loginToFc2(): global session if s…

play のコンパイル時にエラー

[info] LESS compiling on 3 source(s) [error] [object Object] (/Users/koya/dev/nudele/nudele/project/target/node-modules/webjars/less/lib/less/parser.js#594) at /Users/koya/dev/nudele/nudele/project/target/node-modules/webjars/less/lib/less…

アダルト動画収集クローラ作成中

FKoy/erowler · GitHubアダルトサイト作成のためにクローラを作成中pythonのBeautiful soupを使っているJoin me !

Beautiful soup 同じ階層の要素を列挙

現在の階層からルートまで検索したい時があったので while elm is not None: for next in elm.next_siblings: print next.name for prev in elm.previous_siblings: print prev.name elm = elm.parent if elm is not None: print elm.name1.後の要素をすべ…

vagrant で "The working directory for Vagrant doesn't exist! This is the specified working directory:"

$ vagrant global-status b7a606c default virtualbox running /Users/koya/dev/Showtime/vagrant-nodejs-redis-mongodb 6d6c61f default virtualbox running /Users/koya/vagrant/vagrant-nodejs-redis-mongodb d99c027 default virtualbox running /Users/…

手っ取り早くScalaを勉強できるサイト

Scala School Twitterが公開しているチュートリアルSimply Scala A Tour of Scala - an interactive scala tutorial - Scalculator Scala Tour playgroundが用意されている。すごい楽。https://www.playframework.com/documentation/2.3.x/Home playは公式が…

play framework アプリが起動できない

環境 java 1.8.0_25 scala 2.11.4 sbt 0.13.7 対処 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128M; support was removed in 8.0 error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/jdk…

Node.js ファイルのタイプを調べる

ファイルのタイプを知りたかったら、file-typeというモジュールを使う。file-type fileTypeにファイルのバッファーを渡して判別します。ファイルのデータから取得してるので、拡張子を偽装しても正確に取得することができます。

mongoに接続時エラー

環境 ubuntu 14.04 mongo shell 起動時にこんなエラーが出ました。 $ mongo MongoDB shell version: 2.6.6 connecting to: test 2015-01-07T00:07:08.029+0900 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 2015-0…

Nodejs httpsのpostでデータを送る。

requestモジュールを使って httpsクライアントを作成して、簡単なデータを送信したいと思います。まずはrequestをインストール npm i -save request以下のようにコードを書く 自前の証明書などを使っていて、以下の様なエラーが起きているときは [Error: DEP…

Node.js で JSON を文字列に

JSONを文字列にするためには stringify-object というモジュールを利用します。インストール npm install -save stringify-object使用方法 var stringifyObject = require('stringify-object'); var obj = [ { fuga : [ 'hogehoge', 'hoge' ] }, { hoge : [ …

npm install level 時にエラー

$npm install -save level ... ... ... In file included from ../src/batch.cc:5: ../node_modules/nan/nan.h:680:46: error: call to non-static member function without an object argument return NanPersistentToLocal(handle)->Get(NanSymbol("callba…

nodejsでhttpsサーバーを立てる

node.js | HTTPSサーバーの作り方 - 生存戦略型プログラミング node.js | HTTPSサーバーの作り方 - 生存戦略型プログラミングを参考にさせていただいたところ、 Error: error:0906406D:PEM routines:PEM_def_callback:problems getting password at Object.e…

nodejs で leveldb を利用する

コンパイルの方法とかいろいろ探してしまったけど、そんなの必要なかった。。。githubのサンプルコードを動かしてみる。 var levelup = require('levelup') // 1) Create our database, supply location and options. // This will create or open the under…

Berkshelf + Vagrant で Node.js + MongoDB の仮想環境構築

今更ながら、他のBerkshelfの記事がわかりづらかったので書いていこうと思う。 環境 mac osx 10.10.1 Vagrant 1.7.1 chef-dkのインストール Chef Development Kit | Chef Downloads | Chef から環境にあったものをダウンロード&インストール。できたら確認…

bootstrapのmodal dialogを動的に変化させる

bootstrapのmodal dialogの具体的な使い方は公式で http://getbootstrap.com/javascript/#modalsまずは公式のをカスタマイズしたソースを載せておきます。 <script> $(function(){ $(function(){ $('#modal-trigger').hide(); $('#dummy').on('click', function(){ $…

Online Snippet帳 Binder

オンラインでスニペットを管理できるアプリBinder公開!登録して、検索して、ワンクリックでクリックボードにコピー!お試しあれ!github:FKoy/Binder · GitHub demo:Binder

Android StudioでVolleyを使ってみる

Volley.jarの作成 $cd ~/Development $git clone https://android.googlesource.com/platform/$frameworks/volley $cd volleyターゲットを確認 $android list target Available Android targets: ---------- id: 1 or "android-19" Name: Android 4.4.2 Type…

mongooseでlike検索

検索などでsqlのlike文的なのを使いたい時があると思います。 object.find( { $or:[ {a: new RegExp( ".*"+query+".*")}, {b: new RegExp( ".*"+query+".*")}, {c: new RegExp( ".*"+query+".*")} ] } function(err, docs){ if(err)console.log(err); res.js…

androidとnodeの連携

androidでDB使いたいなー、他の機と通信したいなーなんてことあると思います。 そこで、android と node の連携のサンプルを作ってみたいと思います。まずはnodeで簡単な文字列を送信して、androidで表示させてみようと思います。 node側 今回はexpressを使…

sshの設定で

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0640 for '/Users/koya/.ssh/konoha01.key' are too open. It is req…

Connection to http://localhost:3000 refused って言われる

http://blog.ceed.jp/?p=298 AVDのlocalhostとは自分自身を指すらしい 特別に 10.0.2.2 がローカルマシンを指すように割り当てられている String url = "http://10.0.2.2:3000"; //String url = "http://localhost:3000"; HttpPost post = new HttpPost(url);

androidで一意なハッシュ生成

ハッシュを生成するにはApacheCommonsLangライブラリを使います。 ApacheCommonsLangライブラリ導入 build.gradleのdependenciesに compile 'commons-lang:commons-lang:+'を追記 そしてSync 使い方 //アルファベットと数字 RandomStringUtils.randomAlphanu…

android ギャラリーから画像選択

http://furudate.hatenablog.com/entry/2013/06/01/064115 を参考にさせてもらい //画像選択ボタンイベント private View.OnClickListener clicked_image_select = new View.OnClickListener() { public void onClick(View v) { pickFilenameFromGallery(); …

android 下部にレイアウトを固定する

http://tech-gym.com/2013/03/android/1173.html のようにandroid:layout_weight="1"を追加しても固定されなかった。なので android:layout_alignParentBottom="true"を追加したら行った。固定するレイアウトの高さに注意(wrap_content)

Cannot enqueue Query after being destroyed.

以下のコードを実行すると、 var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', database: 'hoge', user: 'root', password: 'hogehoge' }); var query = connection.query("select * from hogehoge;"); query.o…

jPlayer で簡単に動画再生

http://jplayer.org/latest/quick-start-guide/ を参考に http://jplayer.org/download/ からjPlayer本体とskinをダウンロード・設置 <head> <link type="text/css" href="/skin/jplayer.blue.monday.css" rel="stylesheet" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </link></head>