プログラミング

プロおよび熱狂的プログラマーのためのQ&A

8
「URL」で「createObjectURL」を実行できませんでした:
Safariで以下のエラーを表示します。 「URL」で「createObjectURL」を実行できませんでした:指定された署名に一致する関数が見つかりませんでした。 私のコードは: function createObjectURL(object) { return (window.URL) ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object); } これは私の画像のコードです: function myUploadOnChangeFunction() { if (this.files.length) { for (var i in this.files) { if (this.files.hasOwnProperty(i)) { var src = createObjectURL(this.files[i]); var image = new Image(); image.src = src; imagSRC = src; $('#img').attr('src', src); } } } }

4
Vim Regexキャプチャグループ[bau-> byau:ceu-> cyeu]
私は言葉のリストを持っています: bau ceu diu fou gau そのリストを次のように変えたいです。 byau cyeu dyiu fyou gyau 私はコマンドを失敗しました: :%s/(\w)(\w\w)/\1y\2/g これが機能しない場合、Vimで正規表現のキャプチャグループを機能させるには何を変更する必要がありますか?

23
ページが更新されたときにフォームの再送信を防ぐ方法(F5 / CTRL + R)
SQLテーブルにテキストを送信する単純なフォームがあります。問題は、ユーザーがテキストを送信した後、ページを更新でき、フォームに再度入力しなくてもデータが再度送信されることです。テキストが送信された後、ユーザーを別のページにリダイレクトすることはできますが、ユーザーに同じページを表示させ続けたいです。 各ユーザーに一意のセッションIDを与え、それを別の値と比較して、私が抱えている問題を解決したことについて何か読んだのを覚えていますが、どこにあるのか忘れてしまいました。
132 php  html  forms  post  form-submit 

1
value = nullのマップエントリを無視するGson
Gson gson = new Gson(); Map<String,Object> map = new HashMap<String, Object>(); map.put("a", 1); map.put("b", null); System.out.println(gson.toJson(map)); //prints {"a":1} すべてのエントリを含めるにはどうすればよいですか?
132 java  json  gson 

3
カスタムボタンの状態を追加する方法
たとえば、デフォルトボタンには、状態と背景画像の間に次の依存関係があります。 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/btn_default_normal" /> <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/btn_default_normal_disable" /> <item android:state_pressed="true" android:drawable="@drawable/btn_default_pressed" /> <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/btn_default_selected" /> <item android:state_enabled="true" android:drawable="@drawable/btn_default_normal" /> <item android:state_focused="true" android:drawable="@drawable/btn_default_normal_disable_focused" /> <item android:drawable="@drawable/btn_default_normal_disable" /> </selector> 独自のカスタム状態(smth like android:state_custom)を定義するにはどうすればよいですか。それを使用して、ボタンの外観を動的に変更できますか?
132 android  button  state 

8
複数の条件が機能するNumpy
距離と呼ばれる距離の配列があります。2つの値の間にあるdistsを選択します。それを行うために、次のコード行を書きました。 dists[(np.where(dists >= r)) and (np.where(dists <= r + dr))] ただし、これは条件のみを選択します (np.where(dists <= r + dr)) 一時変数を使用してコマンドを順番に実行すると、正常に機能します。上記のコードが機能しないのはなぜですか、どうやって機能させるのですか? 乾杯
132 python  numpy 

6
ローカル変更を維持するgit pull
アップストリームの変更がある場合でも、特定のファイルを変更せずにgitプロジェクトを安全に更新(プル)するにはどうすればよいですか? myrepo / config / config.php このファイルがリモートで変更されていたとしても、git pullすると他のすべてが更新されますが、このファイルは変更されていません(マージされていません)。 PS。私はgitベースのデプロイスクリプトを作成しているだけなので、私が求めていることを行う必要があります。設定ファイルをテンプレートに変更できません。 そのため、ローカルで変更された内容を失わない更新スクリプトを作成する方法が必要です。私は次のような単純なものを望んでいました: git assume-remote-unchanged file1 git assume-remote-unchanged file2 その後 git pull
132 git 


2
pylintrcファイルを作成する方法
Linuxを実行しています。のようなことをしてpylint --generate-rcfile > .pylintrcから、結果の.pylintrcファイルに変更を加えてデフォルト設定を上書きできますか?もしそうなら、それは私の~/ディレクトリにあるべきですか、それとも.pylint.dに入れるべきですか?
132 pylint 

4
node.js process.memoryUsage()の戻り値は何を表していますか?
公式ドキュメントから(ソース): process.memoryUsage() ノードプロセスのメモリ使用量をバイト単位で表すオブジェクトを返します。 var util = require('util'); console.log(util.inspect(process.memoryUsage())); これは以下を生成します: { rss: 4935680, heapTotal: 1826816, heapUsed: 650472 } heapTotalおよびheapUsedは、V8のメモリ使用量を示します。 rss、heapTotal、およびheapUsedは正確には何を表していますか? 些細な質問のように思えるかもしれませんが、これまで探していたため、明確な答えを見つけることができませんでした。
132 node.js  v8 

2
VB.NET IntelliSense:ENTERオートコンプリートで改行を無効にする
Visual Studio 2010でC#コードを編集する場合、ENTERキーを押すと、IntelliSenseは新しい行を追加せずに現在の提案を完了します。 VB.NETでは、ENTERキーのデフォルトのIntelliSense動作は、現在の提案の完了後に新しい行を追加することです。 IntelliSenseを構成してVB.NETの動作をC#の動作に変更するにはどうすればよいですか? TABまたはを押すことができることはすでに知っていますSPACEが、癖があるといつもヒットしてしまいますENTER(そしてラインを変更します)。

10
MongoClient v3.0を使用する場合、db.collectionは関数ではありません
私は、MongoDBを使用してnodeJSでW3schoolsチュートリアルを試しています。 この例をnodeJS環境に実装し、AJAX呼び出しで関数を呼び出すと、次のエラーが発生します。 TypeError: db.collection is not a function at c:\Users\user\Desktop\Web Project\WebService.JS:79:14 at args.push (c:\Users\user\node_modules\mongodb\lib\utils.js:431:72) at c:\Users\user\node_modules\mongodb\lib\mongo_client.js:254:5 at connectCallback (c:\Users\user\node_modules\mongodb\lib\mongo_client.js:933:5) at c:\Users\user\node_modules\mongodb\lib\mongo_client.js:794:11 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickCallback (internal/process/next_tick.js:104:9) 以下に私の実装したコードを見つけてください: var MongoClient = require('mongodb').MongoClient; var url = "mongodb://localhost:27017/mytestingdb"; MongoClient.connect(url, function(err, db) { if (err) throw err; db.collection("customers").findOne({}, function(err, result) { if (err) …
132 node.js  mongodb 

10
Thymeleafでif-elseを行う方法は?
簡単な操作を行うための最善の方法は何だif- elseThymeleafに? Thymeleafで同じ効果を達成したい <c:choose> <c:when test="${potentially_complex_expression}"> <h2>Hello!</h2> </c:when> <c:otherwise> <span class="xxx">Something else</span> </c:otherwise> </c:choose> JSTLで。 私がこれまでに考えたこと: <div th:with="condition=${potentially_complex_expression}" th:remove="tag"> <h2 th:if="${condition}">Hello!</h2> <span th:unless="${condition}" class="xxx">Something else</span> </div> potentially_complex_expression2回評価したくありません。そのため、ローカル変数を導入しましたcondition。それでも、th:if="${condition}との両方を使用するのは好きではありませんth:unless="${condition}"。 LETの発言:重要なことは、私は2個の異なるHTMLタグを使用することであるh2とspan。 それを達成するためのより良い方法を提案できますか?

5
Git:フェッチ専用のリモートをセットアップしますか?
git remote -vリモートが構成されているGitリポジトリの1つで実行すると、各リモートにフェッチ仕様とプッシュ仕様の両方があることがわかります。 $ git remote -v <remote-name> ssh://host/path/to/repo (fetch) <remote-name> ssh://host/path/to/repo (push) ピア開発者をポイントするリモートの場合、プッシュする必要はありません。Gitは、とにかく裸でないリポジトリへのプッシュを拒否します。これらのリモートをプッシュアドレスや機能のない「フェッチ専用」として構成する方法はありますか?
132 git  workflow 

7
ConstraintLayout内のWrap_contentビューが画面の外側に広がる
を使用して簡単なチャットバブルを実装しようとしていConstraintLayoutます。これは私が達成しようとしていることです: ただし、wrap_content制約では正しく機能しないようです。マージンを尊重しますが、使用可能なスペースを適切に計算しません。これが私のレイアウトです: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/chat_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="16dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0" tools:background="@drawable/chat_message_bubble" tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sodales accumsan tortor at bibendum." android:layout_marginStart="64dp" android:layout_marginLeft="64dp" android:layout_marginEnd="32dp" android:layout_marginRight="32dp" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" /> </android.support.constraint.ConstraintLayout> これは次のようにレンダリングされます。 使用していcom.android.support.constraint:constraint-layout:1.0.0-beta4ます。 私は何か間違ったことをしていますか?それはバグですか、それとも単なる直感的でない動作ですか?を使用して適切な動作を実現できますかConstraintLayout(他のレイアウトを使用できることがわかっているので、ConstrainLayout具体的に質問します)。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.