query_id stringlengths 4 64 | query_authorID stringlengths 6 40 | query_text stringlengths 66 72.1k | candidate_id stringlengths 5 64 | candidate_authorID stringlengths 6 40 | candidate_text stringlengths 9 101k |
|---|---|---|---|---|---|
bc09551081c4355287e11aef2f08d355577952f172187e9532b08a8050093097 | ['dc1fce92e80240ff8cffa82bc70696b7'] | You could look into the UNIX utility "nice", it lets you run processes with more or less priority.
The priority levels runs from -20 (top priority) to 19 (lowest). For example, to run tar and gzip at the lowest priority level:
$ nice -n 19 tar -czvf file.tar.gz bigfiletocompress
If you have a process running, use ps to find the process ID, and then use renice to change it’s priority level:
$ renice -n 19 -p 987 32
This would change processes 987 and 32 to priority level 19.
| 1079e12b9e7fc4b41435bbc4957358eafc65f33028d4a54b35a52cb8c06bc7c7 | ['dc1fce92e80240ff8cffa82bc70696b7'] | Good evening
I'm trying to set up a development environment on my newly Boot-Camped Windows 10.
I know how to link the include/lib in VS. On my Mac all my external libraries and include files are at either:
/use/local/ or /opt/local/
I'm wondering whether there is an easy way to do this on windows, or are there a way to force VS to always look in a particular dir?
Cheers
|
32bce16851668de7245e51288c06d696dc2c221a8c9303159af656c252fe4bfc | ['dc2a407458d64934805f3ec463475af4'] | I want to write a script to generate a 3D vector field of the electric flux density of 8 different point charges in a [-2,2]x[-2,2]x[-2,2] box in 3D space.
I have a function definition in a separate .m file as follows:
function[Dx,Dy,Dz]= question3function(Q,Loc,XX,YY,ZZ)
Q=1e-6;
Loc=[];
XX=(2,-2);
YY=[2,-2];
ZZ=[2,-2];
% Position vector from the point charge
Rx=(XX)-Loc([]);
Ry=(YY)-Loc([]);
Rz=(ZZ)-Loc([]);
% Distance between position in interest and the point charge
R=sqrt(Rx.*Rx+Ry.*Ry+Rz.*Rz);
% Unit Position vector
Ax=Rx./R;
Ay=Ry./R;
Az=Rz./R;
% Electric flux density XYZ components
K=Q./(4*pi*R.^2);
Dx=K.*Ax;
Dy=K.*Ay;
Dz=K.*Az;
And then in my main script I have the function calls:
%function calls
[Dx1,Dy1,Dz1]=question3function(Q,[1 1 1],XX,YY,ZZ);
[Dx2,Dy2,Dz2]=question3function(Q,[1 1 -1],XX,YY,ZZ);
[Dx3,Dy3,Dz3]=question3function(Q,[1 -1 1],XX,YY,ZZ);
[Dx4,Dy4,Dz4]=question3function(-Q,[1 -1 -1],XX,YY,ZZ);
[Dx5,Dy5,Dz5]=question3function(2*Q,[-1 1 1],XX,YY,ZZ);
[Dx6,Dy6,Dz6]=question3function(-2*Q,[-1 1 -1],XX,YY,ZZ);
[Dx7,Dy7,Dz7]=question3function(-Q,[-1 -1 1],XX,YY,ZZ);
[Dx8,Dy8,Dz8]=question3function(-Q,[-1 -1 1],XX,YY,ZZ);
Dx=Dx1+Dx2+Dx3+Dx4+Dx5+Dx6+Dx7+Dx8;
Dy=Dy1+Dy2+Dy3+Dy4+Dy5+Dy6+Dy7+Dy8;
Dz=Dz1+Dz2+Dz3+Dz4+Dz5+Dz6+Dz7+Dz8;
quiver3(XX,YY,ZZ,Dx,Dy,Dz);
axis square equal;
xlabel('X'); ylabel('Y'); zlabel('Z');
title('Electric Flux Density of the sum of 8 Point Charges');
I receive the following errors when I try to run my function file:
??? Error using ==> minus
Matrix dimensions must agree.
Error in ==> question3function at 11
Rx=(XX)-Loc([]);
Could somebody please help me and explain how I can fix this? I will add I am not very experienced with using MATLAB.
| 98f6c8145d2c42b3a7158f594a7bb8ba09e124111451e90bee4e4e93507bcd79 | ['dc2a407458d64934805f3ec463475af4'] | I want to display the values (in hex) of these certain registers and counters but I want to limit the number of digits being displayed.
cout << "Acc register : " << hex << Acc << ","; //display 2 digits
cout << " X register : " << hex << X << ","; //display 3 digits
cout << " Program counter : " << hex << PC << ","; //display 3 digits
I also want to display preceding zeros if the value was only 1 digit long, for example if
program counter = 4
PC should display as Program counter : 004
I have searched the internet to try and find a solution but I can not seem to find something that works. Can anybody explain how to do this please. Many thanks.
|
2c3efd9d39fc0684cd8ec42bc107d59554c3af7a12e0ee52484be4f17370d1ac | ['dc3fadfc469b480586e62938ffe644ea'] | Let $f \in \mathbb{Z}[x]$ be irreducible, and let $\bar{f} \in \mathbb{F}_{p}[x]$ be the image of $f$ in the polynomial ring over the finite field with $p$ elements. Is there a general procedure, given $f$ to find the primes $p$ such that $\bar{f}$ is irreducible over $\mathbb{F}_{p}$?
More specifically, the polynomial I am interested in is the 'Fibonacci polynomial' $\phi(x) = x^2 - x - 1$. For which primes is $\bar{\phi}$ irreducible
over $\mathbb{F}_{p}$?
| b58620cff164dfcf3513889d98168b007cff0812479013cebd3de388c4bb9fbd | ['dc3fadfc469b480586e62938ffe644ea'] | You need to remove the person in iMessage on iOS device (when typing the name of the person that should not be in your contacts anymore, that person's name may still appear. press the little "i" icon on the right and choose "remove from recent"), Quit and reopen imessage on OS X, when you start typing that name it will no longer show. It syncs from the iOS device
|
235eb0288212c7f8f3ca63f0759587d75a81400cdee7360c1a620b270368b033 | ['dc49a1e70dcf4503902244b80c0f0c3c'] | thanks for the suggestion. What I discovered is that one of the files in the patch is causing me the problem. It is Kconfig which sources Kconfig in my new dir.... for the kernel configurator ? It seems as Kconfig part of patch is applied before files are installed so the make fails.
Not a yocto expert obviously so will look at the link above .. thanks ...
| 54b5fc50830bdf4805fe9938877d12a46b8c06d508fb51fe8f86410845dc747c | ['dc49a1e70dcf4503902244b80c0f0c3c'] | I have problem where my newly added directory does not exists when patch we relies on it is present.
I added new directory (with files) to the existing directory tree (under fs). I have done this by adding the "install" to the do_configure_append. When I run this, it seems to work fine as the new dir/files show up in the source tree as expected.
However, if I add a patch to the SRC_URI which adds dependence on the new source code, the make fails. It almost appears that the patched files run before the new dir is created.
What I am missing/misunderstanding ?
No code
|
32fdfed9e00e5351d1fbb5d2ac495a9a2bb6db3a8954a9c5cb5b049c4cdb94d0 | ['dc528e7d864e40a5b163c13541e2a190'] | The structure of your code is strange. I had a similar issue by creating the Serial object in a function without making it global. Maybe you should put this line outside the loop :
arduinoData = serial.Serial("com7", 9600)
Also, your initialization seems a bit light. I usually use more parameters but it depends of your hardware.
ser = serial.Serial(
port = 'com4', \
baudrate = 19200, \
parity=serial.PARITY_NONE, \
stopbits=serial.STOPBITS_ONE, \
bytesize = serial.EIGHTBITS, \
timeout = 0.25)
A workaround for your readline() issue coud be using the read() function instead and checking if it contains data.
Hope it will help !
| 04cc85dc11fd027a490baf88b5e04811c51e0c7e43e2dc060680909138c39971 | ['dc528e7d864e40a5b163c13541e2a190'] | There are several ways of passing credentials with Cloud Foundry. Putting them in your .yml file is just one option.
You can set them manually with the command cf set-env, as explained here: https://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html#view-env
If you are afraid of the CLI, Bluemix also allows you to create user-defined environment variable with its GUI : https://github.com/ibm-cds-labs/simple-data-pipe/wiki/Create-a-user-defined-environment-variable-in-Bluemix#use-the-bluemix-user-interface
I don't want to put username and password(even it's encrypted) in yml file
FYI, the .yml file does not leave your computer/CI server and is just read once by Cloud Foundry.
|
eeb9d3cc12acfcf9139da6a5776d18f2ad3834632350d6a9850459d937d4af52 | ['dc56aaf7be6147efa96ee41e1ba47a21'] | This is definitely a feasible approach. We use Ubuntu 14.04 for our host machines and run several Oracle 11g instances within Docker containers for development purposes as well.
Currently (Docker 1.5) for both 11g and 12c the main issue is Docker's hard-coded shared memory limit Issue #2606. There are currently two workarounds for this:
Use docker run --privileged ... and remount /dev/shm with more memory before starting the instance
Modify and rebuild Docker yourself. For this case I've put together a Dockerfile for 12c which allows creating an image in one go: https://github.com/arpagaus/docker-oracle-12c
| 6828b0191aac61541f6f77c40a5a58ce1b78b71e46586be2de1791d9eea30d16 | ['dc56aaf7be6147efa96ee41e1ba47a21'] | But what are the practical implications of this? E.g., how do I get it back? Or, do I not worry about it in that the OS will take back the inactive memory as needed? Is that inactive memory still "taken"? Further, if it's inactive, can I find *which program* has it? /proc/meminfo is helpful, but it's global. |
644812a40e8c2fd8f0b896a1fc60b8c84eb0eb7c2520241960e701222ef64367 | ['dc5e03ac5437426cb2f69512642b763e'] | I'm a newbye getting his hands on Matplotlib for the first time.
I'd like to plot some (four) different set of data in the same plot and I need to offset them because otherwise they would overlap.
This is what I need to obtain: http://s4.postimg.org/skaclr06l/example.jpg
Now, it would be simple to add a constant to the different data sets to offset them, but I need every plot to have a corresponding ordinate axis starting from 0 as you can see from the example I posted.
I found a solution which gets quite close to it on matplotlib website:
# Three subplots sharing both x/y axes
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing both axes')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
The problem is that in this way I get separate plots, whereas I'd like them to overlap partly, as is usually done, for example, with absorption spectra (see an example here http://nte-serveur.univ-lyon1.fr/spectroscopie/raman/Image42.gif)
Could you help me?
| 89bdbf21f19f159ad63cebfbdf0c97d69f9130d688175932115f91aff00b4a10 | ['dc5e03ac5437426cb2f69512642b763e'] | I'm trying to fit a set of data with a function (see the example below) using scipy.optimize.curvefit,
but when I use bounds (documentation) the fit fails and I simply get
the initial guess parameters as output.
As soon as I substitute -np.inf ad np.inf as bounds for the second parameter
(dt in the function), the fit works.
What am I doing wrong?
import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize as opt
#Generate data
crc=np.array([-1.4e-14, 7.3e-14, 1.9e-13, 3.9e-13, 6.e-13, 8.0e-13, 9.2e-13, 9.9e-13,
1.e-12, 1.e-12, 1.e-12, 1.0e-12, 1.1e-12, 1.1e-12, 1.1e-12, 1.0e-12, 1.1e-12])
time=np.array([0., 368., 648., 960., 1520.,1864., 2248., 2655., 3031.,
3384., 3688., 4048., 4680., 5343., 6055., 6928., 8120.])
#Define the function for the fit
def testcurve(x, Dp, dt):
k = -Dp*(x+dt)*2e11
curve = 1e-12 * (1+2*(-np.exp(k) + np.exp(4*k) - np.exp(9*k) + np.exp(16*k)))
curve[0]= 0
return curve
#Set fit bounds
dtmax=time[2]
param_bounds = ((-np.inf, -dtmax),(np.inf, dtmax))
#Perform fit
(par, par_cov) = opt.curve_fit(testcurve, time, crc, p0 = (5e-15, 0), bounds = param_bounds)
#Print and plot output
print(par)
plt.plot(time, crc, 'o')
plt.plot(time, testcurve(time, par[0], par[1]), 'r-')
plt.show()
|
06e231a75a1b9aeb71c052eb063e1733911e215e7dae7e7f3cb1580c310ff1a5 | ['dc69b8822c96438383d4e66ccd9278ae'] | "Normal" regression requires continuous data so you shouldn't treat it as such.
"Normal" Logistic regression requires binary variable, however there is also multinomial regression.
In the case of multinomial regression you are trying to explain a nominal variable with some regressors. You can look at the following:
"Estimation of multinomial logit models in R: The mlogit Packages" by <PERSON> or "mlogit" in R.
Good luck.
| 5755bc7db28d1bd573e414cb151d319d053629611ac0a22e5a2d972cf394fc55 | ['dc69b8822c96438383d4e66ccd9278ae'] | I wouldn't approach this problem like this. What I would do is: 1) Test for structural changes. If there is a difference in the mean (permanent) it should find a structural change on the (or around) the date of the referendum. Therefore, I advice you to read on structural changes. Another thing I will do is add a dummy variable with 0 before the referendum and 1 after. I will then run a regression yt = b1D + et, where D is the dummy for the referendum. If the t-statistic is significant then, this means that knowing if the data is before matters (keep in mind that you must remove trend first). |
ca7dcaa1d99c855e90f1515b8efe6773f9f5522678a7242ae277227a75b7428f | ['dc6c3e3c1c0c4489acfc89b13d9c5ec8'] | I'm not sure what the question really is, but the error you are getting is because you finish the activity while a dialog is showing. What i often do is call dialog.dismiss() in the onPause or onStop method of my activity.
What about this code?:
Some where in your activity;
private AlertDialog dialog;
the onPause or onStop method,
@Override
public void onPause() {
super.onPause();
if(dialog != null){
dialog.dismiss();
}
}
Building the dialog,
if(someCondition){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("message")
.setPositiveButton("Yes", new OnClickListener(){
public void onClick(DialogInterface arg0, int arg1) {
//do stuff
//finish?
}
});
.setNegativeButton("No", new OnClickListener(){
public void onClick(DialogInterface arg0, int arg1) {
//do stuff
//finish?
}
});
dialog = builder.show();
}
| 8d148b567b71717886ed4f7125b8d85d49fe5732e2edcefb8b0cdb92773fdb89 | ['dc6c3e3c1c0c4489acfc89b13d9c5ec8'] | What about this:
Take a close look at the relative layout, it now uses wrap_content for it's height and match_parent for it's width. Also notice the alignParent parts inside the button xml. Using a RelativeLayout is not the only way to do this but could be better if you want the buttons to float on the right and left side. You could also use a LinearLayout with it's orientation set to horizontal.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="HardcodedText" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Button" />
</RelativeLayout>
</LinearLayout>
Rolf
|
ec25082b4be3f6b815391e9004b821f133ca5f7d572b56af39bb30b931e40871 | ['dc87c4afc8b5492c8c5c2a318d8f00e3'] | I'm assuming that log_probs is stored as a pytorch tensor.
You can take advantage of the linearity of differentiation to calculate the derivative for all samples at once: log_probs.sum().backward(retain_graph = True)
At least with GPU acceleration this will be a lot faster.
If log_probs is not a tensor but a list of scalars (represented as pytorch tensors of rank 0), you can use log_probs = torch.stack(log_probs) first.
| dbb7ae2384a9fe841cdb03b5a74bc32de1416ac62969472ae0bc74ebc9a2d380 | ['dc87c4afc8b5492c8c5c2a318d8f00e3'] | I'm assuming by
print(X_test.shape)
(3071, 128, 128, 3)
you mean that the test data has 3071 samples with 128x128 pixels and 3 color channels each.
Also I'm assuming that the model you are using doesn't transpose the inputs, so the convolution layers expect the default layout which is shape (N, C, H, W) but you provide your data as (N, H, W, C).
Solution: Try image.transpose_(1, 3) or image = image.cuda().transpose(1, 3) before handing it to the model.
|
f796728fef1bfdad35a25df6590f4a7e43c3ed1fca5aba96839ad098fbefa5ac | ['dc916ea3d55445ebb719b9e929177339'] | I'm currently building an app in Swift and I'm having some trouble implementing a feature.
When a user signs up, he enters his phone number which is then stored in the database. Right after the sign up process, I want to display a list of all the user's contacts that already use the app so he can add them, but also the others, so he can invite them via SMS.
On my API, I have an endpoint that can return all the users that match in a list of phone numbers. Right now, I'm trying to do this :
get all the phone numbers in the Address Book
send them to the API to see if some of these numbers are matching with registered users
if there's a match, get the list of users back in the app
update my table view with the data, adding correct button (add or invite) in each cell
My problem is : I don't know how I should link that returned data from the api to my contact list knowing that each contact can have multiple phone numbers. Should I go through my contact list and for each contact, find if one of the phone numbers is contained in the array of users returned by the API ?
I find the process quite heavy. I need to get through the Address book one time to get the phone numbers and display the contacts names on the table view, and then another time to link the data provided by the API to the correct cells.
Is there a better way to handle this ? I'd like to hear your thoughts !
| 4f259b8bebf9b1656b5268dcffcdbb660a13edeccda0ef24a23410b9d89cd2cc | ['dc916ea3d55445ebb719b9e929177339'] | I'm new to SVG and I'm having trouble solving this problem :
I'm trying to create a system of points, rotating around a single axis, like a solar system.
The center point is a round div, placed to the center of the viewport with the help of the CSS calc function :
left: calc(50% - myDivWidth/2);
top: calc(50% - myDivHeight/2);
I placed SVG circles around this central point with the "cx" and "cy" attributes and everything works fine.
Here's the problem : when I resize the window, the div is automatically moved to stay at the center of the screen. But my SVG circles are not moving because the coordinate system doesn't stretch to the new size of the viewport. Now if I reload the page after resizing, everything is placed correctly again.
I thought I could recalculate the coordinates of my circles when a resize occurs but isn't it a bit heavy ?
All my circles are placed in a svg tag with a 100% height and width.
I hope you can help me with this ! Thanks !
|
7590ccbee71864f0a700c932d14b62903daa4ce15b11dbf3dcc6b884001f9e28 | ['dcdc415d16324f4bb780908e93c0f840'] | sh start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
start-all.sh: 99: /home/songtian/下载/hadoop-2.6.0/sbin/../libexec/hadoop-config.sh: Syntax error: word unexpected (expecting ")")
And I open the hadoop-config.sh,but there is no error in 99.The next content is hadoop-config and there is no error in line 99.I don't know whether I understand the error of the sh start-all.sh. What should I modify.
# 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# included in all the hadoop scripts with source command
# should not be executable directly
# also should not be passed any arguments, since we need original $*
# Resolve links ($0 may be a softlink) and convert a relative path
# to an absolute path. NB: The -P option requires bash built-ins
# or POSIX:2001 compliant cd and pwd.
# HADOOP_CLASSPATH Extra Java CLASSPATH entries.
#
# HADOOP_USER_CLASSPATH_FIRST When defined, the HADOOP_CLASSPATH is
# added in the beginning of the global
# classpath. Can be defined, for example,
# by doing
# export HADOOP_USER_CLASSPATH_FIRST=true
#
# HADOOP_USE_CLIENT_CLASSLOADER When defined, HADOOP_CLASSPATH and the jar
# as the hadoop jar argument are handled by
# by a separate isolated client classloader.
# If it is set, HADOOP_USER_CLASSPATH_FIRST
# is ignored. Can be defined by doing
# export HADOOP_USE_CLIENT_CLASSLOADER=true
#
# HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES
# When defined, it overrides the default
# definition of system classes for the client
# classloader when
# HADOOP_USE_CLIENT_CLASSLOADER is enabled.
# Names ending in '.' (period) are treated as
# package names, and names starting with a
# '-' are treated as negative matches.
# For example,
# export HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES="-org.apache.hadoop.UserClass,java.,javax.,org.apache.hadoop."
this="${BASH_SOURCE-$0}"
common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
script="$(basename -- "$this")"
this="$common_bin/$script"
[ -f "$common_bin/hadoop-layout.sh" ] && . "$common_bin/hadoop-layout.sh"
HADOOP_COMMON_DIR=${HADOOP_COMMON_DIR:-"share/hadoop/common"}
HADOOP_COMMON_LIB_JARS_DIR=${HADOOP_COMMON_LIB_JARS_DIR:-"share/hadoop/common/lib"}
HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_COMMON_LIB_NATIVE_DIR:-"lib/native"}
HDFS_DIR=${HDFS_DIR:-"share/hadoop/hdfs"}
HDFS_LIB_JARS_DIR=${HDFS_LIB_JARS_DIR:-"share/hadoop/hdfs/lib"}
YARN_DIR=${YARN_DIR:-"share/hadoop/yarn"}
YARN_LIB_JARS_DIR=${YARN_LIB_JARS_DIR:-"share/hadoop/yarn/lib"}
MAPRED_DIR=${MAPRED_DIR:-"share/hadoop/mapreduce"}
MAPRED_LIB_JARS_DIR=${MAPRED_LIB_JARS_DIR:-"share/hadoop/mapreduce/lib"}
# the root of the Hadoop installation
# See HADOOP-6255 for directory structure layout
HADOOP_DEFAULT_PREFIX=$(cd -P -- "$common_bin"/.. && pwd -P)
HADOOP_PREFIX=${HADOOP_PREFIX:-$HADOOP_DEFAULT_PREFIX}
export HADOOP_PREFIX
#check to see if the conf dir is given as an optional argument
if [ $# -gt 1 ]
then
if [ "--config" = "$1" ]
then
shift
confdir=$1
if [ ! -d "$confdir" ]; then
echo "Error: Cannot find configuration directory: $confdir"
exit 1
fi
shift
HADOOP_CONF_DIR=$confdir
fi
fi
# Allow alternate conf dir location.
if [ -e "${HADOOP_PREFIX}/conf/hadoop-env.sh" ]; then
DEFAULT_CONF_DIR="conf"
else
DEFAULT_CONF_DIR="etc/hadoop"
fi
export HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_PREFIX/$DEFAULT_CONF_DIR}"
# User can specify hostnames or a file where the hostnames are (not both)
if [[("$HADOOP_SLAVES"!='')&&("$HADOOP_SLAVE_NAMES"!='')]]; then
echo \
"Error: Please specify one variable HADOOP_SLAVES or " \
"HADOOP_SLAVE_NAME and not both."
exit 1
fi
# Process command line options that specify hosts or file with host
# list
if [ $# -gt 1 ]
then
if [ "--hosts" = "$1" ]
then
shift
export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$1"
shift
elif [ "--hostnames" = "$1" ]
then
shift
export HADOOP_SLAVE_NAMES=$1
shift
fi
fi
# User can specify hostnames or a file where the hostnames are (not both)
# (same check as above but now we know it's command line options that cause
# the problem)
if [[("$HADOOP_SLAVES"!='')&&("$HADOOP_SLAVE_NAMES"!='')]]; then
echo \
"Error: Please specify one of --hosts or --hostnames options and not both."
exit 1
fi
if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
. "${HADOOP_CONF_DIR}/hadoop-env.sh"
fi
# check if net.ipv6.bindv6only is set to 1
bindv6only=$(/sbin/sysctl -n net.ipv6.bindv6only 2> /dev/null)
if [ -n "$bindv6only" ] && [ "$bindv6only" -eq "1" ] && [ "$HADOOP_ALLOW_IPV6" != "yes" ]
then
echo "Error: \"net.ipv6.bindv6only\" is set to 1 - Java networking could be broken"
echo "For more info: http://wiki.apache.org/hadoop/HadoopIPv6"
exit 1
fi
# Newer versions of glibc use an arena memory allocator that causes virtual
# memory usage to explode. This interacts badly with the many threads that
# we use in Hadoop. Tune the variable down to prevent vmem explosion.
export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4}
# Attempt to set JAVA_HOME if it is not set
if [[ -z $JAVA_HOME ]]; then
# On OSX use java_home (or /Library for older versions)
if [ "Darwin" == "$(uname -s)" ]; then
if [ -x /usr/libexec/java_home ]; then
export JAVA_HOME=($(/usr/libexec/java_home))
else
export JAVA_HOME=(/Library/Java/Home)
fi
fi
# Bail if we did not detect it
if [[ -z $JAVA_HOME ]]; then
echo "Error: JAVA_HOME is not set and could not be found." 1>&2
exit 1
fi
fi
JAVA=$JAVA_HOME/bin/java
# some Java parameters
JAVA_HEAP_MAX=-Xmx1000m
# check envvars which might override default args
if [ "$HADOOP_HEAPSIZE" != "" ]; then
#echo "run with heapsize $HADOOP_HEAPSIZE"
JAVA_HEAP_MAX="-Xmx""$HADOOP_HEAPSIZE""m"
#echo $JAVA_HEAP_MAX
fi
# CLASSPATH initially contains $HADOOP_CONF_DIR
CLASSPATH="${HADOOP_CONF_DIR}"
# so that filenames w/ spaces are handled correctly in loops below
IFS=
if [ "$HADOOP_COMMON_HOME" = "" ]; then
if [ -d "${HADOOP_PREFIX}/$HADOOP_COMMON_DIR" ]; then
export HADOOP_COMMON_HOME=$HADOOP_PREFIX
fi
fi
# for releases, add core hadoop jar & webapps to CLASSPATH
if [ -d "$HADOOP_COMMON_HOME/$HADOOP_COMMON_DIR/webapps" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_COMMON_HOME/$HADOOP_COMMON_DIR
fi
if [ -d "$HADOOP_COMMON_HOME/$HADOOP_COMMON_LIB_JARS_DIR" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_COMMON_HOME/$HADOOP_COMMON_LIB_JARS_DIR'/*'
fi
CLASSPATH=${CLASSPATH}:$HADOOP_COMMON_HOME/$HADOOP_COMMON_DIR'/*'
# default log directory & file
if [ "$HADOOP_LOG_DIR" = "" ]; then
HADOOP_LOG_DIR="$HADOOP_PREFIX/logs"
fi
if [ "$HADOOP_LOGFILE" = "" ]; then
HADOOP_LOGFILE='hadoop.log'
fi
# default policy file for service-level authorization
if [ "$HADOOP_POLICYFILE" = "" ]; then
HADOOP_POLICYFILE="hadoop-policy.xml"
fi
# restore ordinary behaviour
unset IFS
# setup 'java.library.path' for native-hadoop code if necessary
if [ -d "${HADOOP_PREFIX}/build/native" -o -d "${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR" ]; then
if [ -d "${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR" ]; then
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR
else
JAVA_LIBRARY_PATH=${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR
fi
fi
fi
# setup a default TOOL_PATH
TOOL_PATH="${TOOL_PATH:-$HADOOP_PREFIX/share/hadoop/tools/lib/*}"
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.log.dir=$HADOOP_LOG_DIR"
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.log.file=$HADOOP_LOGFILE"
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.home.dir=$HADOOP_PREFIX"
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.id.str=$HADOOP_IDENT_STRING"
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.root.logger=${HADOOP_ROOT_LOGGER:-INFO,console}"
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_LIBRARY_PATH
fi
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.policy.file=$HADOOP_POLICYFILE"
# Disable ipv6 as it can cause issues
HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true"
# put hdfs in classpath if present
if [ "$HADOOP_HDFS_HOME" = "" ]; then
if [ -d "${HADOOP_PREFIX}/$HDFS_DIR" ]; then
export HADOOP_HDFS_HOME=$HADOOP_PREFIX
fi
fi
if [ -d "$HADOOP_HDFS_HOME/$HDFS_DIR/webapps" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_HDFS_HOME/$HDFS_DIR
fi
if [ -d "$HADOOP_HDFS_HOME/$HDFS_LIB_JARS_DIR" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_HDFS_HOME/$HDFS_LIB_JARS_DIR'/*'
fi
CLASSPATH=${CLASSPATH}:$HADOOP_HDFS_HOME/$HDFS_DIR'/*'
# put yarn in classpath if present
if [ "$HADOOP_YARN_HOME" = "" ]; then
if [ -d "${HADOOP_PREFIX}/$YARN_DIR" ]; then
export HADOOP_YARN_HOME=$HADOOP_PREFIX
fi
fi
if [ -d "$HADOOP_YARN_HOME/$YARN_DIR/webapps" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_YARN_HOME/$YARN_DIR
fi
if [ -d "$HADOOP_YARN_HOME/$YARN_LIB_JARS_DIR" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_YARN_HOME/$YARN_LIB_JARS_DIR'/*'
fi
CLASSPATH=${CLASSPATH}:$HADOOP_YARN_HOME/$YARN_DIR'/*'
# put mapred in classpath if present AND different from YARN
if [ "$HADOOP_MAPRED_HOME" = "" ]; then
if [ -d "${HADOOP_PREFIX}/$MAPRED_DIR" ]; then
export HADOOP_MAPRED_HOME=$HADOOP_PREFIX
fi
fi
if [ "$HADOOP_MAPRED_HOME/$MAPRED_DIR" != "$HADOOP_YARN_HOME/$YARN_DIR" ] ; then
if [ -d "$HADOOP_MAPRED_HOME/$MAPRED_DIR/webapps" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/$MAPRED_DIR
fi
if [ -d "$HADOOP_MAPRED_HOME/$MAPRED_LIB_JARS_DIR" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/$MAPRED_LIB_JARS_DIR'/*'
fi
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/$MAPRED_DIR'/*'
fi
# Add the user-specified CLASSPATH via HADOOP_CLASSPATH
# Add it first or last depending on if user has
# set env-var HADOOP_USER_CLASSPATH_FIRST
# if the user set HADOOP_USE_CLIENT_CLASSLOADER, HADOOP_CLASSPATH is not added
# to the classpath
if [[("$HADOOP_CLASSPATH"!="")&&("$HADOOP_USE_CLIENT_CLASSLOADER"="")]]; then
# Prefix it if its to be preceded
if [ "$HADOOP_USER_CLASSPATH_FIRST" != "" ]; then
CLASSPATH=${HADOOP_CLASSPATH}:${CLASSPATH}
else
CLASSPATH=${CLASSPATH}:${HADOOP_CLASSPATH}
fi
fi
| fee35c5639f0e2764efd34083f60fe55e8c7bc5a98a938496de76b0cc75c950d | ['dcdc415d16324f4bb780908e93c0f840'] | sudo R CMD javareconf
Java interpreter : /usr/lib/jvm/default-java/jre/bin/java
Java version : 1.8.0_121
Java home path : /usr/lib/jvm/default-java
Java compiler : not present
Java headers gen.:
Java archive tool:
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: 没有那个文件或目录
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /usr/lib/jvm/default-java
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
When I run sudo R CMD javareconf,the result tells me that jni.h is not found. I install Java and Hadoop and I want to install R packages 'rJava'.But When I install 'rJava' and the Rstudio also run error.First, I want to know how to solve sudo R CMD javareconf and find the jni.h file.
|
ca2e6e32198fdcba4b818a8800c2c54ccf0670e699fe1fbf1fe6758a6db82390 | ['dcecd339685640908b16993c820d8588'] | Thanks for the response, yes I'm basically using the pumping lemma to see if the that language does not satisfy the pumping property. If it does, then it is implied that the language is not regular. I'm very new to formal language theory and have been struggling as the textbooks make pumping lemma very confusing.
**In this case, the language does satisfy the pumping lemma from my working out, but I may be wrong** | 552cfe788dc2bb932b87e1593d7596e1660c7e62088801c090a0ebc361bc3d0b | ['dcecd339685640908b16993c820d8588'] | I've been working on understanding the Pumping Lemma for 2 days now and I feel like I may have finally got somewhere. I was hoping to show you guys a question and my working out and if you think i'm on the right lines that would be great and if not, any help would be extremely appreciated.
The question I have been asked is this:
Use the Pumping Lemma to determine whether the language L = {a^n b^2n | n >= 1} is regular or not.
My answer:
I chose a pumping length 'm'.
Word chosen = a^m b^2m as it is certainly longer than m.
w = xyz
a^m b^2m = xyz
y!= empty and |xy| <= m
So the max length of xy is a^m.
y = a^k where 0 < k <= m
as y cannot be empty but could possibly be length m as x can be empty.
x = a^q where 0 <= q < m
as q can be empty but cannot be equal to m as y cannot be empty.
z = a^m-k-q b^2m
as z can hold any remaining a's and all the b's.
Therefore xyz = a^q a^k a^m-k-q b^2m => a^m a^2m so the language is regular.
PS I don't expect you to do the question yourself, but reading over my answer to see where i'm going wrong (if so) would be great as I assume some of you are quite familiar with the pumping lemma more than I.
|
11de6916e0e51f11d1339698c3290f0c194684fa2d5ed5dc065ceb9bc3a7a37b | ['dcf37d740e334530b3703b76cd71046a'] | I'm working at a project where we wanna build a web frontend using a "true" plugin architecture. Well, what do I mean saying "true".
Imagine having a web app for configuration. The frontend of this app can dynamically change as we are able to install functionality on runtime. We are therefore able to add some new features at runtime. My idea is to have a simple UI that can load multiple plugins. Those plugins can be loaded into this simple UI as single pages.
At the time I'm compiling this simple UI for configuration I don't know the plugins that will be installed later. Unfortunately. My idea is to have a rest API that provides the plugins (maybe as webpack modules?) and that the simple UI will just load those plugins on startup.
I did some research today and I'm quite not sure if doing something like this is possible with angular Ivy. As I'm not an expert maybe someone could answer this, before I'm going to dig deeper.
Is it possible to create angular components that are not known at compile time to the app but that are later loaded via a backend?
Thanks for a short response
Best Regards
| 9665955152054aeb070eb7da331f01aa49bd37df42e92a50dae82d53d3a956e7 | ['dcf37d740e334530b3703b76cd71046a'] | In my company we're going to create a new application, based on an existing Database. During the process of building the new application we will have both applications (the old and the new one) used in production environment connected to the same database structure.
For this time we can't make major changes to the database structure without having a lot of work to refactor the old application (where the source code is just a big mess)
Now to my problem:
A lot of tables do not have auto generated primary keys. In the old application there are create with something like:
SELECT MAX([id]) as id FROM [tablename];
var new id = id + 1;
To have a good performance on the new application, we don't wanted to generate the new identity in code (We are using EntityFramework 6). Instead we created a trigger to generated the id.
No the problem is, that i cant get the generated id into my entityFramework object. Refreshing the context does not help because there is no other identical criteria on the dataset that i could use to reselect it.
my idea is to use the storeGeneratedPatter.Identity to bring the id back to entityFramwork. But for that case i need the @@IDENTITY variable to be set inside of my trigger.
Is there a possibility to do something like:
SET @@IDENTITY = @id
inside of an INSTEAD OF INSERT Trigger?
Thanks for your help
|
baab64a48c664cba613e3a579caff08c0e58d8cd26d93bb1636f9ddcd5dc19da | ['dcfa74485c3d4a73a5960c50f1080bb1'] | It's always better using one layout. Which in this case I will suggest using activity_main.xml and delete the fragment_activity.xml following the below procedure:
1.Creat project normally.
2.Copy fragment_main.xml to activity_main.xml (content). Then delete fragment_main.xml
3.In MainActivity.java delete the following content :
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
and
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
}
Hope this help
| 2c717a29226f0dce5cd6dd73b77eec3ac3806ada9c40e9fcc2e07b7f7de45dc1 | ['dcfa74485c3d4a73a5960c50f1080bb1'] | I need correction on the code below.
I have 2 classes "Employee" and "Child".
When I want to create a new Employee, I would like to be able to create in that same form the related Child (2 Children maximum).
Below are the models
public class Employee
{
public int EmployeeID { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public int ChildID { get; set; }
public virtual ICollection<Child> Childs { get; set; }
}
public class Child
{
public int ChildID { get; set; }
public string NameChild { get; set; }
public string SurnameChild { get; set; }
public virtual Employee Employee { get; set; }
}
The Employee controller
public class EmployeController : Controller
{
private ComideContext db = new ComideContext();
// GET: Employe/Create
public ActionResult Create()
{
List<Child> model = new List<Child>();
return View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "EmployeID,Name,Surname,ChildID")] Employee employee)
{
if (ModelState.IsValid)
{
db.Employes.Add(employe);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(employe);
}
}
The View of the Employee form
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Employe</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Surname, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Surname, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Surname, "", new { @class = "text-danger" })
</div>
</div>
@for (int i=0; i<2; i++ )
{
<div class="form-group">
@Html.LabelFor(model => model.NameChild, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NameChild, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NameChild, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SurnameChild, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SurnameChild, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SurnameChild, "", new { @class = "text-danger" })
</div>
</div>
}
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
Any help/thoughts would be most appreciated.
Thank you.
|
fc656545553fb80e152139f87898b6f9b4cdffa83f62c9d6720f805e9713f621 | ['dcfb8d0eca424dd09b6a4faa1106cb19'] | I'm trying to write a query for an embedded Mongoid<IP_ADDRESS>Document which finds any record where the "address" field is neither nil nor "".
Using a combination of the MongoDB documentation, this issue in the Mongoid bug reports, and the Mongoid documentation, I think that something like this should work:
scope :with_address, where("$or" => [{:address => {"$ne" => nil}}, {:address => {"$ne" => ""}}])
When I run this, the selector looks ok:
1.9.2p290 :002 > report.document.records.with_address
=> #<Mongoid<IP_ADDRESS>Criteria
selector: {"$or"=>[{:address=>{"$ne"=>nil}}, {:address=>{"$ne"=>""}}]},
options: {},
class: GlobalBoarding<IP_ADDRESS>MerchantPrincipal,
embedded: true>
But when I look at the results, they contain an entry with a blank address:
1.9.2p290 :007 > report.document.records.with_address.last
<Record _id: 4f593f245af0501074000122, _type: nil, version: 1, name: "principal contact 3", title: "", dob: nil, address: "", email: "", phone: "", fax: "">
I can't figure out if I'm doing a query wrong, if this is a bug with Mongoid, or if there is some other issue. Does anyone have experience with such a query?
| 0760b0c7d09daca06240c16af22577e86796896df3cbe3cb0e642bdf51fdbded | ['dcfb8d0eca424dd09b6a4faa1106cb19'] | You can add this to your layout, in the head section:
<%= yield :javascripts %>
Then, in your view, you can do:
<%= content_for :javascripts do %>
<%= javascript_include_tag :some_js %>
<% end %>
Or, if you want to specify the whole path instead of a symbol:
<%= javascript_include_tag 'path/to/js/file' %>
In the above example, the path is relative to app/assets/javascripts/
|
97fa1efb48a2b8f17a36188cbabba0873219016515b57d0328fa1f43db662f32 | ['dd20e769e1cb42a1a9b287eb15869d89'] | Yes. Latter-Day Saints believe in the Virgin birth.
Perhaps one random sample from an official LDS Church manual called The Life and Teaching of Jesus and His Apostles Instructors Manual (Which can be found here) will help. It says the following:
The Significance of the Virgin Birth (A Discussion and Chalkboard
Diagram)
The teacher might wish to point out that many people in the Christian
world want to believe in <PERSON>, but only as a great human being, only
as a great man. They feel uncomfortable about the concept of the
miraculous, virgin birth. Yet if this is denied, all of the Atonement
must be rejected as well. It was the inheritance that came from a
mortal mother and a divine Father that made the Atonement possible.
The confusion may come where we believe that God is his Literal, physical father. There is no doctrine as to how this occurred. I know of no statements of God laying with <PERSON>. Only that God is His Father, and <PERSON> is His mother. Any speculation as to how that occurred is not doctrinal, nor is it taught. <PERSON> was still a Virgin at <PERSON>'s birth.
Was it artificial insemination? Was it a miraculous transformation of the egg to a complete set of chromosomes? Was His zygote somehow embedded in her via the Holy Spirit? There is no doctrine, nor even official speculation as to how this may have occurred. Frankly I am not really even aware of any non-official speculation as to the method within the LDS faith.
When the Journal of Discourses is used as a point of LDS doctrine, one must call it into question. These talks were not recorded except in shorthand and notes, and reconstructed by an individual for profit. They were not produced by the LDS Church, despite the talks being by official sources. Significant portions were never even approved of by the speakers.
There is a whole line of research on this topic, and it is amazing what was left out and added to the talks based on the original shorthand texts.
That doesn't mean there isn't a lot of good in there, and things one can learn, but it does mean that one should probably look to LDS.org to get accurate doctrinal points rather than the JoD.
A great discussion on the JoD with modern understanding can be found in this podcast episode. It gives some scholarly direction as to how to look at the JoD.
Today current members may refer to the JoD, but it has been relegated to more of a curiosity and a tool than a source of doctrine.
| 32544c84cc107fb951cf76b39c0b35c904f4bf3a38c81e9a68354710ef858137 | ['dd20e769e1cb42a1a9b287eb15869d89'] | The closest thing I've found to an official statement on it, is a developer tweet:
Handling is a single stat reflecting both recoil and gun sway. Higher numbers are better (meaning at higher numbers, the gun has less recoil and/or less sway).
What this means is that Handling will reduce the amount of sway and deviation the area gets from firing a gun (more so when firing continuously), while more Accuracy will make the initial area your gun can hit smaller.
Source
|
326eead6b0c1b15cdbc7907a36fa3b00a3b1591aaabb750c5cee0c6ab037d823 | ['dd25f10527b54b7fb7499245939be00a'] | If you normalise your data into three tables then the following works for what you want to do. This is using my own schema as I had to knock up some tables to test it).
Select
UserId, UserName,
(
Select
CountryName + ','
From
Country As C
Inner Join
UserCountry As UC
On C.CountryId = UC.CountryId
Where
UC.UserId = [User].UserId
ORDER BY
CountryName
FOR XML PATH('')
) As Countries
From
[User];
| f77f57b3ecdc5baaa4c16ead0a1b5481c1adb4705c22c91573388d7c86da83c3 | ['dd25f10527b54b7fb7499245939be00a'] | Creation of full text indexes is not supported in EF Core 2.1, there is an issue tracking this at https://github.com/aspnet/EntityFrameworkCore/issues/11488
In summary;
In EF Core 2.1 we have initial support for for full-text search via the FreeText predicate in LINQ, but this only works with databases that have already been indexed. EF Core and the SQL Server provider don't provide any way to configure the model so that migrations or EnsureCreated can generate the right SQL for defining the indexes.
|
9a0bbe8fddab6c517c1f9f3a5031eb33473febd57e505246125dc69c23303eca | ['dd2c9329058940dc8307c28629569c29'] | A solution that works without urllib or re (also handles preceding slash):
def split_s3_path(s3_path):
path_parts=s3_path.replace("s3://","").split("/")
bucket=path_parts.pop(0)
key="/".join(path_parts)
return bucket, key
To run:
bucket, key = split_s3_path("s3://my-bucket/some_folder/another_folder/my_file.txt")
Returns:
bucket: my-bucket
key: some_folder/another_folder/my_file.txt
| a4091e6c69ec266af0667dd26c185b545e2dd98e5aa327f58a882ce54fa7cf96 | ['dd2c9329058940dc8307c28629569c29'] | Use list comprehension to generate a non-unique list, convert it to a set to get the unique values, and then back into a sorted list. Perhaps not the most efficient, but yet another one line solution (this time with no imports).
Python 3:
sorted(list(set([val for vals in content.values() for val in vals])))
Python 2.7:
sorted(list(set([val for vals in content.itervalues() for val in vals])))
|
0ec7c64214edf12a71ff16b14a635f394d706b520bb87f81f58525d381bdcaa5 | ['dd365f91db644a4986100a78f8b733c8'] | Answer picked up from this issue. (Thanks Scottmitch@github).
Netty can provide "ordering" in the following situations:
You are doing all writes from the EventLoop thread; OR
You are doing no writes from the EventLoop thread (i.e. all writes are being done in other thread(s)).
It is subtle but important thing to remember as it can cause painful bugs. If some channel.write() calls are coming from application threads and some are coming from EventLoop then the writes can seem out of order from application's perspective. See more details on the linked issue.
This question seems to be the top search result for Netty write ordering, so wanted to make sure it mentions this important caveat.
| 644c251a5f904593ea16e1cf6affde030c8a866265c3b0f344b66408bbf9e6e3 | ['dd365f91db644a4986100a78f8b733c8'] | I need to write a multi-threaded java application where I will be creating number of threads to handle different types of operation. For example, one thread will monitor state of the application, one thread will manage communication with other nodes in the cluster, one thread will have some application logic and so on.
What is the good way to pass the data and signals between the threads? For example, the application logic thread may need to send a message which it can hand off to the communication thread. Here the data will need to be transferred between the two threads. One way I thought was to use a queue where all the threads wanting to send a message can insert their message. However, it presents few problems:
The queue and the method used for insertion will need to be static OR
Each thread that wishes to send a message has to have the object of the communication thread
Moreover, such send method will provide no way for me to tell the calling thread if the sending fails (for example, throwing an exception) because once the message is inserted in the queue, the calling thread thinks it sent its message.
What is the good way to pass signal and data between the threads for such applications?
This might be too fundamental question for software engineers (I come from electronics background). If so, can anyone point me to a good source where I can read about designing multi-threaded or multi-processed applications?
Thanks a lot.
|
c04da9f119eda5f0c460ade5d4d59883b153ad36255448b6cc2d9130355232f8 | ['dd370a0015ad4331bac29078bfc754de'] | When I assemble a file using GCC tools (from MinGW package), calls to WINAPI functions from system DLLs have this form:
call label
...
ret
label: jmp dword [ExitProcess]
Instead of:
call dword [ExitProcess]
...
ret
How can I force GCC to call directly idata section pointers instead of generating that extra code?
| 3f03ce4ae0c4765eda9519ca32c9a50bf462634c7c557130cb61261d03aebc56 | ['dd370a0015ad4331bac29078bfc754de'] | I'm implementing a completely decentralized database. Anyone at any moment can upload any type of data to it. One good solution that fits on this problem is an immutable distributed hash table. Values are keyed with their hash. Immutability ensures this map remains always valid, simplifies data integrity checking, and avoids synchronization.
To provide some data retrieval facilities a tag-based classification will be implemented. Any key (associated with a single unique value) can be tagged with arbitrary tag (an arbitrary sequence of bytes). To keep things simple I want to use same distributed hash table to store this tag-hash index.
To implement this database I need some way to maintain a decentralized consensus of what is the actual and valid tag-hash index. Immutability forces me to use some kind of linked data structure. How can I find the root? How to synchronize entry additions? How to make sure there is a single shared root for everybody?
|
46a0a43332681e7218140054ee0148ff22f707ef85548f0829e2e6234ecf637e | ['dd3f60d0628e4019b9efdc68d930c853'] | function onChange(e) {
var ss = SpreadsheetApp.getActiveSheet();
var s = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current");
var r = ss.getActiveCell();
if(e.changeType == 'FORMAT' && ss.getName() == "Current" && r.getBackground() == "#b7b7b7") {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Completed");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
targetsheet.getrange(targetSheet.getLastRow() + 1, 2).setValue(getNotes(getrange(targetSheet.getLastRow() + 1, 16)))
s.deleteRow(row);
}
};
function getNotes(cell)
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getRange(cell)
return range.getNotes();
}
I'm using a third party add-on, onChange for my needs.
This function copies a row from one sheet to another when I color the row with #b7b7b7 and deletes it from the original sheet. However,
targetsheet.getrange(targetSheet.getLastRow() + 1, 2).setValue(getNotes(getrange(targetSheet.getLastRow() + 1, 16)))
does not seem to work. It should take notes from the second cell in the row and copy it to the 16th cell of the same row in the copied sheet. Help would be appreciated.
| 424438b236592f7a36ca00bd399fc776a490784200f94941121e968537dc8efd | ['dd3f60d0628e4019b9efdc68d930c853'] | This is a followup question from the previous post. Basically I want to autopopulate the entire column with getNotes on the first row similar to that of ArrayFormula. The previous poster have kindly provided this function:
function getNotes(rng){
const ss = SpreadsheetApp.getActive().getActiveSheet();
const index = ss.getMaxRows()-ss.getRange(rng).getNotes().flat().reverse().findIndex(v=>v!='');
const range = ss.getRange(rng+index);
return range.getNotes();
}
Which then uses
getNotes("B1:B")
to populate the column cells with the respective notes from the B column. The problem though is that doing any sort of sorting on the columns does not dynamically change the locations of these Notes; the function still remembers the previously sorted locations. This function would also need to dynamically add notes to the cells as new rows get added automatically, and based on how it doesn't autopopulate properly, it does not do that either. Basically, the function runs just once to populate then I have to manually run the function again to get it to repopulate to correct positions. Help on this would be much appreciated.
As a side note, I'd also like to label this cell with the formula. I have tried
IF(ROW(A:A)=1,"Label",getNotes("B1:B"))
to see if it'll work similar to ArrayFormula and get first row as a label, and use the function for all the rows beneath in a column, but it doesn't seem to work.
|
6da9ab8877b1e72feb6a818a42263511660b73ac14933f57e5545018d56b7016 | ['dd5c13528c8d4b2fac0daf091cfb88da'] | Starting with a dummy dataset
df = pd.DataFrame({'user': ['<PERSON>', '<PERSON>', 'alice', 'alice'], 'game_result':['win', 'win', 'lose','win']})
user game_result
0 john win
1 john win
2 alice lose
3 alice win
The first step would be to count the number of wins and losses for each player.
counts = df.groupby(['user', 'game_result']).size().reset_index(name='count')
This gives:
user game_result count
0 alice lose 1
1 alice win 1
2 john win 2
We'll then pivot the data to have users as rows, game_result as columns and counts as the values
result = counts.pivot('user', 'game_result', 'count').reset_index()
result = result.fillna(0)
Which gives:
game_result user lose win
0 alice 1.0 1.0
1 john 0.0 2.0
| 61e575bc4f486207c188ce218a20f6f7905bdc657017b8b7f31c7ca821592dba | ['dd5c13528c8d4b2fac0daf091cfb88da'] | I have a Neural Network with two hidden layers. I want to add a bias unit only to the second hidden layer. How do I do that?
The code for my network is as follows:
nn = FeedForwardNetwork()
inLayer = LinearLayer(numFeatures)
hiddenLayer1 = LinearLayer(numFeatures+1)
hiddenLayer2 = SigmoidLayer(numFeatures+1)
outLayer = LinearLayer(1)
nn.addInputModule(inLayer)
nn.addModule(hiddenLayer1)
nn.addModule(hiddenLayer2)
nn.addOutputModule(outLayer)
in_to_hidden1 = FullConnection(inLayer, hiddenLayer1)
hidden1_to_hidden2 = FullConnection(hiddenLayer1, hiddenLayer2)
hidden2_to_out = FullConnection(hiddenLayer2, outLayer)
nn.addConnection(in_to_hidden1)
nn.addConnection(hidden1_to_hidden2)
nn.addConnection(hidden2_to_out)
nn.sortModules()
|
424d807ed9fbee467bdecbab93080f1bbcbdb396c01a880d3553e43722674596 | ['dd7b42746085444fbe7b0d31a51913a7'] | I have an R+M USB 3.0 that is no longer recognised by my PC (running Windows 10). The disk appears greyed out, 0 bytes available, as in this answer.
I don't mind about lost data, what I want to know is if I've done something wrong whilst backing up so I can prevent the same thing happening in the future. Here is the script I used to backup:
import subprocess
drive = subprocess.run(['sudo', 'mount', '-t', 'drvfs', 'D:', '/mnt/d'])
print(drive)
docs = subprocess.run(['sudo', 'rsync', '-av', '--progress', '/mnt/c/Users/sc/Documents/', '/mnt/d', '--exclude', '/mnt/c/Users/sc/Documents/my_data/data'])
print(docs)
unmount = subprocess.run(['sudo', 'umount', '/mnt/d/'])
print(unmount)
I ran this and it caused my USB to break. Is this a bad method of backing up? Could this have been avoided if I'd zipped my files before copying? Or could it simply be that I bought a cheap, dodgy USB?
Any help is much appreciated.
| f430bd1c2a3729d751ec71b9a1aaa40a4d68bcd51d48c65bc9c71c0e963c1ebd | ['dd7b42746085444fbe7b0d31a51913a7'] | A brief intro. I am creating a medical software. I forget some of the computation/permutation theorems in college. Let's say I have five nerves. Median, ulnar, radial, tibial, peroneal. I can choose one, two, three, four, or all five of them in any combintation. What is the equation to find the maxmimum number of combinations I can make?
For example;
median
median + ulnar
median + ulnar + radial
etc etc
ulnar + median = median + ulnar. so those would be repetitive. Thank you for your help. I know this isn't directly programming related, but I thought you guys would be familiar.
|
36bd1d5d8777b4147af48fd139b1a26c10896ae5f4ea394d52debf48ff5f84cb | ['dd7bb6562e8f44c5a301d989e033783e'] | I'd suggest having hints dealt with in their own class, including body of the hint (so you can change it). To call it, just add one line of code, like:
if ( hintsOn ) { HintHandeler.display ( ); }
The less the call to the hints needs to know, the better. Try to have whatever must be dealt with to be dealt with in the Hints class
To find out where the HintHandeler call came from, make use of: Thread.currentThread().getStackTrace(), and lex it as needed to find out where you came from. Ideally, store that in a variable, then have a massive switch{} statement, if possible (for speed), go down the list of places a call might be made from, and call additional code as necessary.
| 36f4cd7c528464405f85fab4aa52e11c5ec818e30e22ad65778b1b7d38990b93 | ['dd7bb6562e8f44c5a301d989e033783e'] | Use VisualSvn menu or context menu in Solution Explorer and choose "Show Changes". It could also be that you have fiddled with the VisualSvn->"Set Working Copy Root" option. Set it back to automatic mode if possible.
As VisualSvn uses TortoiseSvn in the background, it works only with folders so if there is a modified file in the folder not belonging to the solution side by side with a modified file belonging to the solution you will see both files.
|
b42cd0bdcf5585b1737513f0d5f9aba1035aa12c9113ddfd268f256e7c85a43c | ['dd9cd77408ea4c369e10afcbc8739992'] | it's all or nothing with object-groups, you can't specify a single static route as you are suggesting. I would have to specify smtp, http, ftp, etc. separately and it will do nothing to solve the problem, have already tried the explicit track. The problem, as stated in the linked thread, is that outbound smtp port is not at all guaranteed to be port 25; and when it's not 25 (like always), the implicit static route for smtp protocol is ignored, and the default is used instead, which just so happens to be the external ASA IP -- totally f-ing useless as far as serving legit mail is concerned ;-( | 7d39685bb928e9cdda533b2ffdf7091f03231f53c57acea4a85c47ff0f7c06a7 | ['dd9cd77408ea4c369e10afcbc8739992'] | @dunxd, while I disagree with Cisco licensing practices, I have to say, the ASA has several advantages over Linux APF/iptables OS firewall. In other words, I really, really like the power of this little unit ;-) No doubt the learning curve is steep initially, but once you get a few TAC sessions under your belt it starts to click (SmartNET is bar none the best tech support deal on the planet) |
d6d0092ac847486370e7e22b850ee03554cd260f0868b4173a7b76a1853ecf9c | ['dda25e29202b4f8a83bac98b64277226'] | Solved the issue by registering the thread for GIL as described in documentation.
Please note that original API DLL, Python extension DLL, and the script were executed in single-threaded mode and no additional thread had been created, either Python-managed, or not. However, there had been a synchronization issue for sure, because using Py_AddPendingCall() also worked. (Using is is discouraged; I found it analyzing signals module sources, it lead to the solution above.)
This statement of mine was incorrect:
Using debug print, I traced the error down to (1). Any code at (2) point doesn't execute.
I was mislead by the fact that some of Python API functions still worked (e. g. Py_BuildValue or Py_Initialize), but most didn't (e. g. PySys_WriteStdout, PyObject_Call, etc).
| b4fc7ae70b1bef1501e3415d5367895a0a9cf3eefe319c01fe6b32f6c60e390d | ['dda25e29202b4f8a83bac98b64277226'] | For output buffer (i. e. the one holding packets to be sent), sendto() or similar call will block until the space is available in the buffer.
For input buffer (i. e. the one holding received packets), it depends on OS networking stack implementation, strictly speaking. In Linux, new packets are dropped silently. In any case, it will not be an error if some packets are lost this way, as UDP does not guarantee their delivery.
BTW, there is no such thing as a "UDP connection".
|
33a44d87994c0c20bc16fd1c1c10797de1c3be7261922ca6008b7252ebcc6170 | ['ddac8d3aeedf4c6aa07e97a58d63519d'] | I think you are a bit confused about the various callbacks. onUploadChunkSuccess, as the documentation states, will be called for each chunk after the chunk has successfully uploaded. But according to your code, you are not looking for this. Instead, you want Fine Uploader to call a specific endpoint once all chunks have been uploaded, and then you require access to the response to that request in a callback. The documentation page for the concurrent chunking feature (which you have enabled) explains how to obtain the response to this request:
Expected response for the chunking success POST
For successful responses, you may return an empty body with a status
of 200-204. Any other status code is determined to be a failure. You
can also return a JSON response with any data your would like passed
to your onComplete handler. Furthermore, you can include an error
property in your response with the error message you would like to
have displayed next to the failed file (if you are using Fine Uploader
UI).
| 65ade62533f405fbef0f573dac5e6e09c492a440b9e5f942754bbf52060d333d | ['ddac8d3aeedf4c6aa07e97a58d63519d'] | When running groovyc in a Windows env, I am running into issues due to the length of the classpath, in my situation. I would like to work around this by creating a pathing jar, and then put that jar on the cp. How can I create a pathing jar w/ all of the classpath entries specified automatically in gradle and then add that jar to the cp?
|
5219675995548e5d9a096ae487cbda4e090b8cc34b6fbfb8a8f6158077fc0cd2 | ['ddb55f51b29f40e3b12ec80ef3b3ac4a'] | I am a brand new developer for Sprite Kit. I am almost done with my first game, yet I am stuck on the code for displaying an ever-changing score in real time. I have spent many days trying my best and researching for a solution without any results, so I have finally decided to post here in hopes for an answer:
I have created a Score Label Node in myScene and created this Method
-(void)adjustScoreBy:(NSUInteger)points
{
BOOL updateHud = YES;
updateHud += points;
[GameState sharedInstance].score += points;
[scoreLabel setText: [NSString stringWithFormat:@"Score: %d", [GameState sharedInstance].score]];
}
I have created my GameState that works like a Charm and displays both the score and the High Score in my GameOver Scene, BUT it does NOT update the score in real time when I play myScene. Instead it displays the end result of the previous score from the last time I played the game which remains static throughout my entire current game, and I am not able to see the current score until the next GameOver scene again along with the High Score.
Finally, this is my way of calling the update for the score :
[self adjustScoreBy:5];
[scoreLabel setText: [NSString stringWithFormat:@"Score: %d", [GameState sharedInstance].score]];
My wish is to be able to display the current score in real time. Please help.
| c37dbd786ec6ce3e2d3473dae1f837512bd3f0959734e45e8cb4adb94d9a5204 | ['ddb55f51b29f40e3b12ec80ef3b3ac4a'] | I am new to Java as well as to enum types.
I am trying to make a menu selection that uses enum types as its valid choices and that displays the following integer selections for the user:
Welcome to Frank's Banking Application.
Enter:
1. Create Bank
2. Add a branch to a Bank
3. Add a customer to a Branch
4. Make a transaction with a customer
5. Display Banks, Branches, Customers, and Transactions.
6. Quit Application.
Selection ->
However, the problem I am faced with is that enum constants do not seem to accept integer values as their names. So I am stuck making them letters for now. This is the code I have so far:
import java.util.Scanner;
enum MenuOptions
{
z("Continue"), a("Create Bank"), b("Add Branch"), c("Add Customer"),
d("Make Transaction"), e("Display Information"), q("Quit");
// field
private String meaning;
// constructor
MenuOptions(String meaning)
{
this.meaning = meaning;
}
// getters
public String getMeaning()
{
return meaning;
}
}
public class Main
{
private static Scanner input = new Scanner(System.in);
public static void main(String[] args)
{
System.out.println("Welcome to Frank's Banking Application.");
MenuOptions menuOptions = MenuOptions.z;
while (menuOptions != MenuOptions.q)
try
{
menu();
menuOptions = MenuOptions.valueOf(input.nextLine());
switch (menuOptions)
{
case a:
//createBank();
break;
case b:
//addBranch();
break;
case c:
// addCustomer();
break;
case d:
// makeTransaction();
break;
case e:
break;
case q:
System.out.println("Goodbye.");
break;
default:
System.out.println("Selection out of range. Try again");
}
}
catch (IllegalArgumentException e)
{
System.out.println("Selection out of range. Try again:");
}
}
public static void menu()
{
System.out.println("\nEnter:");
System.out.println("\ta. Create Bank");
System.out.println("\tb. Add a branch to a Bank");
System.out.println("\tc. Add a customer to a Branch");
System.out.println("\td. Make a transaction with a customer");
System.out.println("\te. Display Banks, Branches, Customers, and Transactions.");
System.out.println("\tq. Quit Application.");
System.out.print("\nSelection -> ");
}
}
As can be seen, I had to edit all the enums to have letters as their name in order to allow the user input from the scanner to match their type by using the valueOf method.
Is there a way however, to allow options: 1, 2, 3, 4, 5, 6 from user input from keyboard to be taken as a restricted enum type?
Hope that makes sense and thanks.
|
38b04e5da1859e37baf4a277af5b5b1b591fb832b186951a3288718173d14079 | ['ddb9060c672247468ef11902b5cc4508'] | It is difficult even in the Dune Universe to "sterilize" an entire world, much less 90 worlds. I am curious if anyone has any insight into the methods used such as biological or atomics that I am not aware of, similar to the methods used in the Butlerian Jihad. Specifically this one segment of the Jihad doesn't seem to be addressed anywhere else. Perhaps its in an upcoming book? | 5c95194d6eaf0196bb01e8baeb6caa08625d388c29b59082e98fadd026fe27b4 | ['ddb9060c672247468ef11902b5cc4508'] | Do you suggest to generate "center" of a chunk from a seed and its edges "smoothed" based on adjacent chunks? It makes sense, but it will increase the size of a chunk, since it should be the size of an area, that player can observe plus double the width of a transition area to adjacent chunks. And chunk area becomes even larger the more diverse the world is. |
45be883113f42d457b430a370189c4631519b06d193bd971ef86c804d905c385 | ['ddbee01bb8ca4d03bd52ecf24e52ae18'] | pues <PERSON>
Te puedes guiar de este ejemplo de como sería llenarlo para que puedas introducirlo en lo que sea tu programa
for (int i = x; i < y; i++)
{
Console.WriteLine(i);
}
Si hablamos a lo que se refiere el inicializador, es poder declarar una variable que no se encuentre en la clase que estés trabajando ejemplo
int i=5
Ahora en el condicional, hay que tener en cuenta que lo que quieras hacer deber ser declarado como BOOL en donde se hayan creado dichas variables, teniendo así que
Si la sección condición no está presente o la expresión booleana se evalúa como true, se ejecutará la siguiente iteración del bucle; en caso contrario, se sale del bucle.
A que me refiero con esto que acabo de citar, que sea la condición que tenga establecida en este te va a marcar según el espacio establecido, sino, mostrara el otro procedimiento anexado, en el caso del principio es:
i<y
Ahora finalmente el itinedaror, lo que hará es hacer un procedimiento según lo que se realice en ese bucle. En este caso será que cada vez que lo haga, sume.
i++
Espero y te sirva.
| af8c3347504096c5b582c1f3140c9eabe9c2c014f6ff863daf936656d0e588e1 | ['ddbee01bb8ca4d03bd52ecf24e52ae18'] | O <PERSON> <PERSON>:
switch(opcao){
case 1:
String nome = null;
String cpf = null;
clientes.add(new Cliente(nome, cpf));
break;
case 2:
String nomeCat = null; double pesoCat = 0.0; int <PERSON> = 0;
clientes.adicionaFelino(nomeCat, <PERSON>, idadeCat);
//a IDE <PERSON> nesta <PERSON>
break;
default:
return null;
}
Acontece que você está chamando o método adicionaFelino em uma lista, mas esse método só existe dentro de um objeto cliente. Você terá que chamar esse método no objeto cliente. Exemplo:
Cliente cliente = new CLiente(nome, cpf);
String nomeCat = null;
double pesoCat = 0.0;
int idadeCat = 0;
cliente.adicionaFelino(nomeCat, pesoCat, idadeCat);
clientes.add(cliente);
Esse seria o funcionamento correto para adicionar um felino em um cliente e um cliente na lista de clientes. Não tenho noção da regra que está desenvolvendo, mas acredito que terá que alterar seu código main pois não está lógicamente de acordo.
|
f21f5b5a931a20489e5b2c367c284b467a8bcacbe7447bbf38e9dcd8965664d6 | ['ddcbf156e7704736951eff430ba371d7'] | I'm trying to test a simple method.
I have this class:
class Cloud @Inject constructor(var posx: Double = 0.0, var posy: Double = 0.0, var velocity:
Double = 1.0, val context: Context){
val image: Bitmap = BitmapFactory.decodeResource(context.resources, R.raw.cloud)
fun updateVelocity(){
velocity += 5.0
}
fun draw(canvas: Canvas){
canvas.drawBitmap(image,posx.toFloat() - (image.width / 2),posy.toFloat(),null)
}
}
I want to unit test the updateVelocity() method but i can't figure out how, should i use an instrumental test and pass the context or can i use something like mockk?
Can i do this with mockk?
@Test
fun cloudVelocity() {
val cloud: Cloud = mockk()
//update cloud velocity
//assert that the velocity changed
}
| f15043aa490264147d15bc1a7e016fabcfc2ada602c158709a52b6c5f1676749 | ['ddcbf156e7704736951eff430ba371d7'] | Im have a Collection called: Players
Inside there each document has a value of posx and posy
i want to create an Array with Arrays for each document
Like: [[posx1,posy1][[posx,posy2]...]
if i put a print inside the .addOnSuccesListener it works and prints the list but
when im outside there and i try to print the list it returns empty
What i am doing wrong? Thanks
val myDB = FirebaseFirestore.getInstance()
var posiciones = ArrayList<Array<String>>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
myDB.collection("players")
.get()
.addOnSuccessListener { result ->
for (document in result) {
posiciones.add(
arrayOf(
document.get("posx").toString(),
document.get("posy").toString()
)
)
}
}
.addOnFailureListener { exception ->
Log.d(ContentValues.TAG, "Error getting documents: ", exception)
}
//i get []
println("Testing: "+ posiciones)
|
01ef2ed775ffea8a5f9c6330cf29b81693cff7bedf40c6e41aed673c6e07b92c | ['dde2bf7b9ff141d48373d873ad57a27b'] | I am trying to write a program that asks for a input, and encodes it as the numeric code for each letter using the ord function.
I am struggling to get it to repeat for each letter;
My current code can only get it to print the first letter in ord, but not sure how to do it for every letter.
message = "Doughnuts"
length = len(message)
while message:
l = list(message)
print(ord(l[0]))
break
My answer is outputting only one like this
Dessert idea: Doughnuts
68
Except it needs to output all of the encryption like this
Dessert idea: Doughnuts
68 111 117 103 104 110 117 116 115
having a space between each result.
Thanks for any help!
| df35807c10fb3629e5bb081be409aaf0d723018a0a329585a17eac219d63e8e8 | ['dde2bf7b9ff141d48373d873ad57a27b'] | I am trying to gather a list from a .txt file, tally the results and then print them out like this
Bones found:
Ankylosaurus: 3
Pachycephalosaurus: 1
Tyrannosaurus Rex: 1
Struthiomimus: 2
An eample of the dot text file is
Ankylosaurus
Pachycephalosaurus
Ankylosaurus
Tyrannosaurus Rex
Ankylosaurus
Struthiomimus
Struthiomimus
My current code pulls all the names from the .txt file, except im completely stuck from there
frequency = {}
for line in open('bones.txt'):
bones = line.split()
print(bones)
Any help please?
|
edd9940d4c4e0270be1a68cc3294549f35aa2bddad6db9b8d490573dabce9f2a | ['ddea03b32bfe4a7ba225bf0048ea7b60'] | <PERSON>: As a big fan of <PERSON> classic tale (it's why I commented in the first place), I would like to point out that in that story everyone can see that the emperor wears no clothes, but nearly everyone is too afraid to point it out. With regards to the infinitude of primes, it seems that most people are simply mistaken as to the content of <PERSON>'s original proof (as many of us are about many other math history issues). They are not afraid to reveal their true belief that it was a direct proof. As such, I believe a "naked emperor" is a false analogy. Best, | e38ed520095b26e51f1c37d3f37dd64c50ac5d9cad75019833f750eea04398ae | ['ddea03b32bfe4a7ba225bf0048ea7b60'] | @Empy2: yes, indeed. There is some trickiness because getting "no other points" contributes the nontrivial factor of $9 p_{\mathbb T\to\mathbb T}^{18} + p_{\mathbb T\to\mathbb T}^{20}$ for a strike but the different and still nontrivial factor $9 p_{\mathbb T\to\mathbb T}^{18} + p_{\mathbb T\to\mathbb T}^{19}$ for a spare. |
9c88dc3d23b64f17eba18375605ff9162175121a1906db66e909fdce9695944b | ['ddeca4799b8b4118972b27db5e567ac8'] | you are all done good but you have to add the plugin id to dependencies classpath in your gradle file like this
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
you always have to add that and after doing this, add the following in your gradle(app) file
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
and you are all done
| f4d717d5969005270049df1173859d9fe9cd469d8a04d79fc41f215273589097 | ['ddeca4799b8b4118972b27db5e567ac8'] | You can simply remove that from Gradle and download this file http://www.java2s.com/Code/JarDownload/junit/junit-4.9.jar.zip or latest version found on there site and add it as library to Gradle and again build the project and it's all done.
This problem may be because. Gradle may be unable to find that, but after adding that downloaded file to your project. You are good to go.
|
32890dbe92cd5fd4788c41c8190d87c87d5f6ea9b69c3a1dfd465f3d6a24974f | ['ddfeb1314dd84f38b2f5aa0fc311d496'] | So I'm creating an application which can display multiple bootstrap modals, currently I have one modal for signing out and one modal for displaying notifications(this one does not work).
The Bootstrap modal for signing out (works):
<div class="modal" id="NotificationModal" tabindex="-1" style="display:block;" role="dialog">
<div class="modal-dialog">
<div class="modal-content text-center">
<div class="modal-body" style="background-color: rgba(64,0,64,0.95);">
<h4 style="color: white;">Are you sure you want to sign out?</h4>
</div>
<div class="modal-footer justify-content-center">
<button type="button" class="btn btn-modal" @onclick="@CloseNotificationModal">Yes, sign me out!</button>
<button type="button" id="SignOutModalClose" class="btn btn-modal" data-dismiss="modal" @onclick="@CloseNotificationModal">No, keep me signed in!</button>
</div>
</div>
</div>
</div>
The bootstrap modal for showing notifications(want this to be full height on the right side) (does not work):
<!-- Modal -->
<div class="modal right fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel2">Right Sidebar</h4>
</div>
<div class="modal-body">
<p>Text</p>
</div>
</div><!-- modal-content -->
</div><!-- modal-dialog -->
</div><!-- modal -->
I followed this tutorial: https://codepen.io/bootpen/pen/jbbaRa and added the html code into my container (same place as other bootstrap modal) and added the css in my bootstrap.min.css.
Can anyone help me? I'm working on this for 2 days already and cant figure it out.
<PERSON>
| 3e10460ffc296e720b8dcfc2b7d11045e2ab84389639a29b3fa14981b6bac41f | ['ddfeb1314dd84f38b2f5aa0fc311d496'] | I'm writing an application where I obtain data like this(the string "SettingsSubPage" represents the name of the data model, in this case "User"):
[Parameter]
public string SettingsSubPage { get; set; }
Results = ApiProvider.GetAll(System.Type.GetType(SettingsSubPage));
From this data I want to show every property except "UserRoles", therefore i created an attribute that makes it able to hide data:
Attribute:
public class HideInTableAttribute : Attribute
{
}
Modal(User) class:
public class User
{
public int Id { get; set; }
[Required(ErrorMessage = "Email is required")]
[DataType(DataType.EmailAddress)]
[EmailAddress(ErrorMessage = "This is not a valid email adress")]
public string Email { get; set; }
[Required(ErrorMessage = "Password is required")]
[DataType(DataType.Password)]
[StringLength(50, MinimumLength = 5, ErrorMessage = "Password must be between 5 and 50 characters")]
public string Password { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public bool Enabled { get; set; }
public DateTime LastLogin { get; set; }
*/ HERE WE HIDE THE PROPERTY /*
[HideInTable]
public List<UserRole> UserRoles { get; set; }
}
Now I want to obtain a list of these properties except "UserRoles" and make them GridColumns so I get a list of GridColumns. An example how to make them GridColumns(used in other class) can be done like this:
.Select(x => new GridColumn()
{
Field = x.Name,
HeaderText = x.Name,
TextAlign = TextAlign.Center
})
.ToList();
So what I need is a LINQ query that obtains the Properties of "SettingsSubpage" model and convert them into GridColumns and put them into a list, what I've tried so far is this:
List<System.Reflection.PropertyInfo> list = System.Type.GetType(SettingsSubPage).GetProperties().Where(x => x.GetCustomAttributes(true).OfType<HideInTableAttribute>().Any()).ToList();
However this is giving me this error:
Hope someone can help, thanks in advance!
|
a937ebe126b8765b6a3aab87a3f1ad0bd1642da7169e14c0ca5626edd0c8b38a | ['de021e4aefa647dfa3aee898d540eac5'] | Reloading a module is rarely a good idea in a production environment; it's a mechanism intended for debugging. When you reload a module, the module's contents (classes, function, data) get replaced, but existing references to these items from other modules are not affected. This is particularly important for classes: existing objects in memory still refer to the old class, whereas objects generated after the reload refer to the new class.
There is another alternative you might want to consider: load Python code from a file and exec it. Less overhead than a complete subprocess, and less tightly coupled to the rest of a program than a module. In principle the same caveats apply to re-exec-ing as to reloading a module, but you are much less tempted to have references to exec'd code because it's more work.
| a59ce480ef6575ecee8796e4b95075bc6e050e3e63f0606ad923b490e7c64b20 | ['de021e4aefa647dfa3aee898d540eac5'] | I am using the Nix package manager under macOS to install much of my software, including dynamic libraries. And I would like to make them accessible to CFFI. That means adding a path to cffi:*foreign-library-directories*. Fine, but how can I do this
globally for my system (should work for packages loaded via Quicklisp, for example)
without loading CFFI every time I start sbcl?
Ignoring the second criterion, I can just add a few lines to ~/.sbclrc:
(ql:quickload "CFFI")
(pushnew (merge-pathnames ".nix-profile/lib/" (user-homedir-pathname))
cffi:*foreign-library-directories*
:test #'equal)
What I am looking for is a way to add the path after CFFI is loaded. A bit like eval-after-load in Emacs Lisp. Is that possible?
|
7469a66e20b3bb63933714ee41d3710f5918547ea44ef73fcc2231702c98e5a5 | ['de0ca43a465f462a9f43968d607582e9'] | I have a responsive website that works great. However, on the desktop version, I recently changed the color of the links in the upper nav bar to white but, in the mobile version, when I click on the hamburger menu, because the background is also white, it's all white. I can't see the links. How do I color the links just for the mobile menu?
Not sure what code is needed so I'll start with this:
<!-- navbar-inverse navbar-fixed-top -->
<nav class="navbar" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<!-- These create the 3 bars for the drop-down menu on mobile screen sizes -->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse nav-change">
<ul class="nav navbar-nav navbar-right">
<li><?php if ($thisPage=='analysis') { echo ''; } else { echo '<a href="/analysis/index.php">Analysis</a>'; }?></li>
<li><?php if ($thisPage=='weblog') { echo ''; } else { echo '<a href="/weblog/index.php">Blog</a>'; }?></li>
<li><?php if ($thisPage=='documents') { echo ''; } else { echo '<a href="/documents/index.php">Documents</a>'; }?></li>
<li><?php if ($thisPage=='media') { echo ''; } else { echo '<a href="/media/index.php">Media</a>'; }?></li>
<li><?php if ($thisPage=='books') { echo ''; } else { echo '<a href="/books.php">Books</a>'; }?></li>
<li><?php if ($thisPage=='gaza') { echo ''; } else { echo '<a href="/gaza-commentaries-booklets-pictures.php">Gaza</a>'; }?></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Myths <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li><?php if ($thisPage=='myths') { echo ''; } else { echo '<a href="/palestinian-myths/index.php">\'Palestine\' & \'Palestinians\'</a>'; }?></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Links <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li><?php if ($thisPage=='supportIsrael') { echo ''; } else { echo '<a href="/links2.php">Support Israel Links</a>'; }?></li>
<li><?php if ($thisPage=='interest') { echo ''; } else { echo '<a href="/links.php">Links of Interest</a>'; }?></li>
<li><?php if ($thisPage=='newsMedia') { echo ''; } else { echo '<a href="/news-services.php">News Media Listing</a>'; }?></li>
</ul>
</li>
<li><?php if ($thisPage=='about') { echo ''; } else { echo '<a href="/about.php">About</a>'; }?></li>
<li><?php if ($thisPage=='home') {echo '';} else { echo '<a href="/index.php">Home</a>';}?></li>
<li><?php if ($thisPage=='contact') { echo ''; } else { echo '<a href="/contact.php">Contact</a>'; }?></li>
</li>
Let me know if other code is required to fix this.
| 9052fab0e39bb329b076086111d4c8d1c75a94e4f4b4f92016162bdfb430c134 | ['de0ca43a465f462a9f43968d607582e9'] | Just an update. In Chrome and Vivaldi insert chrome://flags/#allow-insecure-localhost into the address bar and then enable "Allow invalid certificates for resources loaded from localhost." Even changing the domain from example.dev to example.test didn't work until I changed the above setting in the browser.
|
228927bdc5ad5c359c00c16134f488a2ab82d404af01807a615cb6493d17da13 | ['de1a7e5670fe4abc990afb237a8d578b'] | user profile is a nice clean framework for individual customization(AKA. Profile Properties). (e.g. iGoogle)
the problem of it is its not designed for query and not ideal for data sharing to public user.(you still would be able to do it, with low performance)
so, if you want to enhance the customized user experience, user profile would be a good way to go. otherwise, use your own class and table would be a much better solution.
| f039f98a2c15aeb30450926e0e609094677e49f5f3395b48fcd35350fa0ec9ce | ['de1a7e5670fe4abc990afb237a8d578b'] | Basic approach that I took for my own projects are:
use facebook javascript SDK to do user login.
after login is successful, user will be able to grand their
access_token
Pass that access_token in your postback page query string (or anything suits you)
by using Graph API with Access_token from code behind you will be
able to grab user info from facebook.
then you will able to compare user info between your own user
provider and set that user as logged in
|
e50de5ce640fe296e968065a596125e8117ceccea20441f5f17f514d3d4a4795 | ['de1d249d4e654e5180d1607f29c2e97d'] | Yes, you don't need a real device to publish an app
The problem you're facing is choosing the right provisioning profile. You need to create:
+ A Production Certificate
+ An AppID match with your app bundle
+ A Production Provisioning profile from your Cert & AppID
I recommend you should read carefully to understand what is provisioning profile: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingProfiles/MaintainingProfiles.html
and how to publish app
https://code.tutsplus.com/tutorials/how-to-submit-an-ios-app-to-the-app-store--mobile-<PHONE_NUMBER>
Good luck
| ce093a60bb5eca8fc6f2e7a117ff360860a53655710b2abcc401b781f56a7748 | ['de1d249d4e654e5180d1607f29c2e97d'] | I've just starting to using Realm and feel it's very good, fast except one thing: delete an object in Realm is easily cause an exception.
Is there any way I can delete an object in Realm safety?
In my project, I usually have to create, update, delete hundred objects on the background thread. The issue is:
If the app currently display/using one object on the main thread
In the background, I delete that object.
=> On the main thread will cause an exception when using that object's properties.
I know Realm has isInvalid method to check, but I cannot add the check in every assign properties code, it's look not good.
So, as of now, what I do is: instead of actually delete, I have a property call "deleted", and in delete, I only update that value. And on the UI, I will filtered out objects which have deleted = true
I wonder is there any way better to do this?
|
8b9f3a4b8baea5e134f5d3c1ebe22d4e28dac940cf04c8100cbea99d2f145fb8 | ['de2584db9a4f462abc3197856d8204ea'] | On a related question [Why is it possible to vote for deletion/undeletion more than once](http://meta.stackexchange.com/questions/9431/why-is-it-possible-to-vote-for-deletion-undeletion-more-than-once) we learn that the vote-once-rule was added to open/close-votes for *some* reason (the exact details lost in history). | c17bb5720a6a072ecb5e9381804f86f5aed4c59be8241cee3ec361231bb37491 | ['de2584db9a4f462abc3197856d8204ea'] | @gnat - It depends on what the poster tells us. Is it *"You can solve the problem by doing this, and this, and that. See this link for reference."*, or is it *"I had the same problem and found a truly remarkable solution that solves everything. I wrote a marvelous article explaining it all on my blog (full of non-relevant ads). Read all about it!"*. It isn't the amount of text that might accompany the link, what matters is if there is something relevant to the question. If not, it is really link-only no matter how much other text there is. |
d5e3df47f1b1c4c27a3345cccadbca63f16d975423a3eab10d9e6ef94d1b6c85 | ['de27fb0681e04ad5a8467ca199df9a9d'] | We used LIKE command to create a new MQ V7 queue using queue template of v6 to v7 migrated queues. Looks like some properties while directly creating V7 queue which prevent us not to show the application properties. Everything got working after creating queue like one of v6 to v7 migrated queues using LIKE command.
Thanks <PERSON> and <PERSON> for your reply.
| 10aaf067da9ff86efae8407a40ee19e94eab9e19817c6d5f5decd31785af70ce | ['de27fb0681e04ad5a8467ca199df9a9d'] | Just to elaborate, we are not seeing JMS application properties in the message though the JMS system properties are showing up in the newly create MQ 7 queues. The steps to recreate the error for understanding
Working Scenario
Create a new JMS message
Set the application properties in this JMS message using setStringProperty API call
Drop the message to migrated queue MQ 7 (from MQ 6 to MQ 7 queue)
Go to UI, browse the message through JMS QueueBrowser
Able to see all the application properties
Not working Scenario
Create a new JMS message
Set the application properties in this JMS message using setStringProperty API call
Drop the message to newly create MQ 7 queue
Go to UI, browse the message through JMS QueueBrowser
Not able to see all the application properties though we can see the JMS system properties ( JMS_IBM*)
We took the dump of message from the newly created queue. We see the application properties in the message dump. But when we extract the message through api
Enumeration messageEnum = queueBrowser.getEnumeration();
enumeration list messages which doesn’t show application properties in all the messages for the newly created queue. But same API can extract the message with application properties for the migrated queues.
We are using websphere application server v 6.1 and Websphere MQ <IP_ADDRESS>.
Could you please explain what I am doing wrong?
|
7a4efc4fd30508ac2088ad7b3aebece439cd23d1078baa67c49507b98d4f9c42 | ['de2d4f16699b42eca2d93e9c9f2ba2c9'] | Use @model Demo.Models.Section instead of IEnumerable and then access your array of items as Model.Items and id as Model.ID or something.
Or create new model like
class SectionModel {
public int ParentID { get; set; }
public IEnumerable<Demo.Models.StringItem> Items { get; set; }
}
and then use that as model for partial view.
Accessing parent view in this way would be code architecture error.
| 7abad5cc0d507387a1e12aa5ba589394072988525993efc467835d7460f96647 | ['de2d4f16699b42eca2d93e9c9f2ba2c9'] | I'd like to create "search" page with two routes:
/ index - the default route
/:time/:filter search - route after user enters some parameters, segment filter is manually serialized/deserialized
Currently I'm transitioning between these routes using transitionTo, however I'd like to stop doing that as it does re-render(re-insert?) the whole application.
What I'd like to do: change url (either form / to /:time/:filter or just to update :time and :filter segments), but preserve current state of application.
Is something like that possible?
Ember.js version: 1.0.0-PRE.2
JsFiddle: http://jsfiddle.net/hKzG9/2/
|
f56462ee3a7a9434272a6f37b42a17a8fb5d8e32c54221f93f2fa28add628338 | ['de2d5a8e1a324d5c8f33370970a3052b'] | Is it possible to get (coherent desktop) video output on the graphics card and the motherboard at the same time?
If so, how?
If not, why? What would have to change for it to be possible?
So far, it seems to me it is not possible as my system does not seem to detect any connections on the motherboard video output ports while outputting on the graphics card although they are listed (as disconnected by xrandr).
| 72bd5a4267c6a689c2a148d5dcfaf79d1a5aa7e019f1a44188f2cbf3085ae4ba | ['de2d5a8e1a324d5c8f33370970a3052b'] | You're using the LOCK_NB flag which means that the call is non-blocking and will just return immediately on failure. That is presumably happening in the second process. The reason why it is still able to read the file is that portalocker ultimately uses flock(2) locks, and, as mentioned in the flock(2) man page:
flock(2) places advisory locks only;
given suitable permissions on a file,
a process is free to ignore the use of
flock(2) and perform I/O on the file.
To fix it you could use the fcntl.flock function directly (portalocker is just a thin wrapper around it on Linux) and check the returned value to see if the lock succeeded.
|
62e883fc0994b739e974a36ca3be7bfe52e10dda62afc60a8acd0843dfc11812 | ['de30440a20bb4b5393e9b9f37bbaf9e4'] | I'm trying to implement a Watermark solution for my ComboBoxes I found somewhere on the web (I can't find the page again) but have problems with the binding. The original solution had static text which I would like to replace using a binding to the ComboBoxes Tag property.
This is what I have so far:
<Grid>
<Grid.Resources>
<VisualBrush x:Key="Watermark" TileMode="None" Opacity="0.4" Stretch="None" AlignmentX="Left">
<VisualBrush.Visual>
<TextBlock FontStyle="Italic" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}, Path=Tag}"/>
</VisualBrush.Visual>
</VisualBrush>
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="Margin" Value="5"/>
<Setter Property="IsEditable" Value="False"/>
<Setter Property="IsReadOnly" Value="True"/>
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{DynamicResource Watermark}"/>
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" ItemsSource="{Binding Categories}" Tag="Categories"/>
<ComboBox Grid.Column="1" ItemsSource="{Binding SubCategories}" Tag="SubCategories"/>
<ComboBox Grid.Column="2" ItemsSource="{Binding Whatever}" Tag="Whatever"/>
Unfortunately it looks like the "FindAncestor" part is not working.
Can anyone tell me why?
Thanks in advance!
| b8354d9ccc84448b68bd5e358d4abb3524ffb538ec00f226791791e69833ba0d | ['de30440a20bb4b5393e9b9f37bbaf9e4'] | @GeoMatt22 thanks. yes, for my situation, normal dist. is assumed. I am not sure why in st. dev. description it would be population mean. I take a bunch of data that have normal dist. The mean of that data is the sample mean, right? The population mean would be the mean of the entire population, no? |
a3199b8ff41f81a1b3f4096db396b9532c6bfacba971346344945ddccae9ba50 | ['de45c497472844b0bd49ae8db35d6dff'] | It depends on the OS.
For example, on GNU Hurd the executable file is loaded by the exec server.
On a more typical monolithic OS, this is done by:
the kernel maps the executable and the dynamic linker in memory;
the dynamic linker mmaps the shared-objects in memory.
The Linux kernel itself is stored as an ELF file: this one is loaded by the bootloader (such as GRUB).
| 646c8ccd7ae404c606bcd1a446e57148284d70e52a5d59c0238e541c08bed288 | ['de45c497472844b0bd49ae8db35d6dff'] | Commenting on another answer gave me the idea to use an anis spirit (ouzo, sambuca, pastis, raki) mixed with water. The ouzo-effect results in a milky solution which, according to the Wikipedia article, is very stable due to the small particle size in the range of microns and the chemical interplay. I will try this (and suggestions in the other answers) out and update the answer (comment on answers).
|
81c9e766e50a99b80e912c8afe9ec4283629b6ac38738c77d7b6adbff0abee39 | ['de4b035b91eb4549ba4292e7747789f5'] | Here is the xml/kml file that I want to change: http://pastebin.com/HNwzLppa
The problem I am trying to solve: We have a kml file generated by data in a log file. The data sometimes has a time drift from GMT. (We are addressing this.) We have no control over the data that that process uses to generate the kml otherwise this whole exercise would be moot. We have written a script that checks to see the drift from GMT.
What I want to accomplish: Use the script we have alreaady written to input the hours, minutes and seconds differnce into this script. Find all the <timestamp> tags and extract the datetime and do a timedelta and write back the new timestamp, and then save the file.
What I have done so far:
import datetime
import time
import re
import csv
from bs4 import BeautifulSoup
#Open the KML file.
soup = BeautifulSoup(open('doc.kml'), "xml")
#Take keyboard input on hours minutes and seconds offset
hdata = raw_input("How many hours off is the file: ")
mdata = raw_input("How many minutes off is the file: ")
sdata = raw_input("How many seconds off is the file: ")
#Convert string to float for use in timedelta.
h = float(hdata)
m = float(mdata)
s = float(sdata)
#Find the timestamp tags in the file. In this case just the first 68.
times = soup('timestamp', limit=68)
#Loop thru the tags.
for time in times:
timestring = time.text[8:27]
newdate = (datetime.datetime.strptime(timestring, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(hours= h, minutes = m, seconds = s))
times.replaceWith()
#Print to output the contents of the file.
print(soup.prettify())
The error I am getting:
Traceback (most recent call last):
File ".\timeshift.py", line 27, in <module>
times.replaceWith()
AttributeError: 'ResultSet' object has no attribute 'replaceWith'
My question is how do I do what I am trying to do and after the prettify statement write the file to disk.
Thanks in advance.
| 9a9c999705caf4286ddd211ad616c14827037d54686fcd444cc57d699f96da43 | ['de4b035b91eb4549ba4292e7747789f5'] | The kml file i am parsing: http://pastebin.com/kU5rPssk
I am looking for all of the <name> tags that match this regex \<name\>(\d+ \@.*)\<\/name\> and then manipulate the text of the tag.
Here is my code that I used to try to test the regex:
import re
from bs4 import BeautifulSoup
#Open the KML file.
xmldoc = open('doc.kml', "r+")
soup = BeautifulSoup(xmldoc, "xml")
p = re.compile(r"\<name\>(\d+ \@.*)\<\/name\>")
result = re.findall(p, soup)
print result
I get the following error:
Traceback (most recent call last):
File ".\regex_test.py", line 10, in <module>
result = re.findall(p, soup)
File "C:\Python27\lib\re.py", line 177, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or buffer
What am I doing wrong?
|
3427f856dc8bf885a6f33a6b6de2f0a5a48a34ba4e728e0ee4dc6f3f376a34d4 | ['de538115475c42eea897702889785c89'] | hi there I am trying to test my code java code with the JUnit test case
but there is a problem with the tester I don't know what it is, happy to get from your review and guides
check this image to see the test failed message>>
ass you see in the I, age the test run failed I do not know why happy to gee reviews and if you can guide me to fix the issue and make it run properly
here also the full java test runner failed message>>
Message:
N/A
Stack trace:
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 22 more
| 1bbc92610829501f2f575f4dac2b19016927d6cf2e93ba927877ec3485fdf21e | ['de538115475c42eea897702889785c89'] | hello there I am trying to run this code >>
public class test {
public static void main(String[] args) {
double[] p1={2,3,4};
double[] p2={2,3};
int maxlentharr;
if (p1.length > p2.length) {
maxlentharr = p1.length;
} else {
maxlentharr = p2.length;
}
double[] Array = new double[maxlentharr];
for (int i = 0; i < Array.length; i++) {
Array[i] = 0;
}
for (int k = 0; k < p1.length; k++) {
for (int j = 0; j < p2.length; j++) {
Array[j + k] += (p1[j] * p2[j]);
}
}
for (double element: Array) {
System.out.println("------------------");
System.out.println(element);
}
}
}
but it seems not works, I do not see any error on the code but here what I get on the terminal>>
[![here][2]][2]
|
be3e5c54fbe14a4bc312ed5e4123cdc76044d548c9537bdec2a1ebb88884067d | ['de539b7d67324e8fa919a10f73231d65'] | So this code is supposed to take user input and see if the brackets are balanced. The instructions just say use a while loop to input multiple lines and print "Exit program". My question: I'm not sure how to break out of the while loop after a few lines of input so that sout("Exit program") will be called - everything else works fine.
PS. still very new to this
import java.util.Scanner;
import java.util.Stack;
public class BracketChecker {
private Stack<Character> stack = new Stack<>();
public boolean check(String text) {
for (int i = 0; i < text.length(); i++){
char c = text.charAt(i);
if (c == '{') {
stack.push(c);
}
if (c == '}'){
if (stack.empty())
return false;
stack.pop();
}
}
if (stack.isEmpty()){
return true;
}
else{
return false;
}
}
public static void main(String[] args) {
System.out.println("Starting bracket checker app");
BracketChecker checker = new BracketChecker();
Scanner in = new Scanner(System.in);
String temp;
while(in.hasNextLine()) {
temp = in.nextLine();
if (checker.check(temp)) {
System.out.println("Syntax correct");
} else {
System.out.println("Syntax error");
}
}
System.out.println("Exiting checker");
}
}
| 677ff6f03e0b16623d03684dddf161e474bd406445da22f48bc018cf84de13ee | ['de539b7d67324e8fa919a10f73231d65'] | public classPrac4 {
public static intmax3(intnum1,intnum2,intnum3) {
int y = Math.max(num1, num2);
return Math.max(num2, num3);
}
}
Check to see if the newly developed method passes all the test you created in the previous checkpoint.
[There is an error in this code and you should include a test to test for this error] THIS is the part I don't understand.
Now change the implementation of the max3 to PASS all the tests. A working solution should pass all the tests.
Any help is appreciated.
@Test
public void test() {
int y = Prac4.max3(5, 2, 1);
assertEquals(5, y);
}
Once the incorrect code is corrected like so:
int max = Math.max(num1, Math.max(num2, num3));
return max;
The tests work.
|
44d6b6b070543cc99dd14a651f6c8c595536b91cf1a44e3ad10456b15b81c363 | ['de5cd02f33da46969b02ebfa8e4e2104'] | I'm using nodeJS(back-end), react(front-end), mongoDB. And I installed CKEditor5 for posting on board with many images.
It perfectly works uploading images on my server folder with CKfinder. But If someone stop to post with images uploaded, useless images remain on my server folder. And, delete uploaded images on the editor (like tab a delete key), still remain on server folder.
How can I delete images on my server folder when users delete images on editor or stop to post with images uploaded.
| f710e8773ef84b89752a8b7ced7749a38422fbee3a0b03510a37cac8420d22b5 | ['de5cd02f33da46969b02ebfa8e4e2104'] | result = map(lambda x: (x>0).mean(), np.array([[1,3], [2,4], [3,5]]))
print result
## output: [1.0, 1.0, 1.0]
what is mean of (x>0) condition in this syntax, and why do i get result like [1.0, 1.0, 1.0] ?
additional) If i use (x>0).mean((1,2)), what is mean of this (1,2)?
|
e401433a8b678e943e32396a725e9de56dd467748b00acd9ab85d057de1d7fa7 | ['de5dd305fc244161bfa9684d0af51247'] | I'm deploying a Django app in heroku, but the static files doesnt work. I was looking I i suppose that I have the right configuration.
settings.py
import os
RUTA_PROYECTO = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(RUTA_PROYECTO,'static'),
)
wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Portafolio6.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
But this still not working.
Please help.
| 8dce4501696b0aa7172766e01e49937b39d70a1d37833bd142c85707d2e70a19 | ['de5dd305fc244161bfa9684d0af51247'] | I'm trying to push my django app in heroku and I've followed all the instructions in the tutorial of heroku's page, but when i try to do the push i get this:
christian@christian-R480-R431-R481:~/Documentos/heroku/Portafolio6$ sudo git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 542 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
! Push rejected, no Cedar-supported app detected
To <EMAIL_ADDRESS>:mysterious-thicket-1865.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '<EMAIL_ADDRESS>:mysterious-thicket-1865.git'
christian@christian-R480-R431-R481:~/Documentos/heroku/Portafolio6$
I dont know why this happens. Do I have to do the push in the django project or when i have the virtualenv folder?
|
6a5093c470aaf4a13ee4070deb1e55e7438cf7248c15b43ac2ed108395a5266e | ['de6312a7716a4bf59035e6da6ad3f100'] | I am currently working on rebuilding our internal CLI tools as a command-line Node application. Part of this involves rebuilding the bash script to SSH into a specific server part of this app.
I know how to use child_process's spawn function to actually execute SSH, but this does not yield the same result as just SSH'ing in the shell directly (even when using flag -tt on the ssh command). For one, typed commands are shown on the screen twice and trying to use nano on these remote machines does not work at all (screen size is incorrect, only takes up about half of the console window, and using arrows does not work).
Is there a better way to do this in a node app? This is the general code I currently use to start the SSH session:
run: function(cmd, args, output) {
var spawn = require('child_process').spawn,
ls = spawn(cmd, args);
ls.stdout.on('data', function(data) {
console.log(data.toString());
});
ls.stderr.on('data', function(data) {
output.err(data.toString());
});
ls.on('exit', function(code) {
process.exit(code);
});
process.stdin.resume();
process.stdin.on('data', function(chunk) {
ls.stdin.write(chunk);
});
process.on('SIGINT', function() {
process.exit(0);
});
}
| 4c02d44a869e38979f5d4ef389e1b69f311d20e507d3e4121f2f9027583f7e58 | ['de6312a7716a4bf59035e6da6ad3f100'] | As others already said this can be caused by a few different things, but it never really matters, as long as your content is displayed fine. If not, it is probably a mime-type problem on the server side, which could be solved by adding a rule to the .htaccess file in Apache.
|
a791c2b1f15192e0df2d9086110c30a8248c986d6ecddc1246d9f5a0d7e2d1cb | ['de63195fc81f4883a47cccbbc98887f0'] | You include it in the <head> section. See example.
If you have any custom CSS, include it under bootstrap.min.css
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="custom_style.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<!-- Place content here -->
</body>
</html>
| 33d3e07ce6906eac3a23b8756553d5d31aa8599951972ee38c4cd87d66788a7c | ['de63195fc81f4883a47cccbbc98887f0'] | PHP code is executed on the server, and cannot reload a <div> widhout rendering the whole page. If you absolutly want to use PHP to do this, you need to make an <iframe> inside the <div class=content> and reload that.
URL parameters is stored in the $_GET variable.
For example: foo.com?page=bar can be retrieved with $_GET['page']
<?php
echo $_GET['page']; // will return "bar"
?>
Example in pure PHP without <iframe>
<nav>
<a href="register.php">Register</a>
<a href="login.php">Login</a>
</nav>
<div class="content">
<?php
if(isset($_GET['page']))
{
// Includes the content. @ is for supressing errors if the file is not found.
// Can be solved with is_file();
// http://php.net/manual/en/function.is-file.php
@include "/path/to/file/".$_GET['page'].".php";
}
?>
</div>
This is not the most secure way of doing it, because you can manipulate the URL to include other PHP files in your system, but you get the idea.
|
4b3d2a715dbbb993931e45551efcc1cd71d52f549580a817c6a4cff165fe5335 | ['de683656dfe94073ac61273896da066b'] | I have multiple profiles in maven like this,
`
<profile>
<id>one</id>
<properties>
<env>one</env>
</properties>
</profile>
<profile>
<id>two</id>
<properties>
<env>two</env>
</properties>
</profile>
<profile>
<id>three</id>
<properties>
<env>three</env>
</properties>
</profile>
<profile>
<id>four</id>
<properties>
<env>four</env>
</properties>
</profile>`
My Question is how can i create a profile which can execute all of the profiles (Except
executing in command line -Pone,two,three,four)??
| 11f18d3ac8a5897418ac876dbbf43f9bf221197f5664a4123e661acde662b0dc | ['de683656dfe94073ac61273896da066b'] | Our application is running google app engine with the java version 1.7, google could endpoints- 1.9.38 version.
Everything was fine till last 5 days, but now we are getting 503 service unavailable for all the apis.
Cron jobs are running fine, but all cloud endpoints are unavailable.
|
d91b0408c7dedd13592bb15709e19f43f6f9e5dedc4a0f4b375d19d88041008c | ['de70708f1a104eca977339d9f3007dee'] | hi I am trying to display data in a recyclerview in android by parsing a json from mysql database. But it keeps displaying just some of the data and I can't seem to find the problem.Any help will be greatly appreciated.
This is the adapter:
public class Adapter extends RecyclerView.Adapter<Adapter.MyViewHolder> {
List<Course> data;
private Context context;
public Adapter(Context context,List<Course> data){
this.data=data;
this.context=context;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.course_list,parent,false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
DecimalFormat form = new DecimalFormat("0.00");
Course current=data.get(position);
holder.tCoursecode.setText(current.getmCoursecode());
holder.tCoursetitle.setText(current.getmCoursetitle());
holder.tCredit.setText(String.valueOf(current.getmCredit()));
holder.tMarks.setText(form.format (current.getmMarks()));
holder.tGrade.setText(current.getmGrade());
}
@Override
public int getItemCount() {
return data.size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
TextView tCoursecode;
TextView tCoursetitle;
TextView tCredit;
TextView tMarks;
TextView tGrade;
public MyViewHolder(View itemView) {
super(itemView);
tCoursecode=itemView.findViewById(R.id.tcc);
tCoursetitle=itemView.findViewById(R.id.tct);
tCredit=itemView.findViewById(R.id.tc);
tMarks=itemView.findViewById(R.id.tm);
tGrade=itemView.findViewById(R.id.tg);
}
}
this the layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:padding="16dp">
<LinearLayout
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/right">
<TextView
android:id="@+id/tcc"
android:layout_width="match_parent"
android:textSize="18sp"
android:layout_height="wrap_content"
tools:text="CSC 460" />
<TextView
android:id="@+id/tct"
android:layout_width="match_parent"
android:textSize="18sp"
android:layout_height="wrap_content"
tools:text= "Information Security"/>
</LinearLayout>
<LinearLayout
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:padding="25dp"
android:textSize="18sp"
tools:text="1"/>
<TextView
android:id="@+id/tm"
android:layout_width="wrap_content"
android:padding="25dp"
android:textSize="18sp"
android:layout_height="wrap_content"
tools:text="78.4"/>
<TextView
android:id="@+id/tg"
android:layout_width="wrap_content"
android:padding="25dp"
android:textSize="18sp"
android:layout_height="wrap_content"
tools:text="A"/>
</LinearLayout>
Screenshot:the grade "A" is not displaying
Screenshot
| e310549b5b4926e8f7c6977e9fa10f147a291371e0cd3c53777aefdff87bac03 | ['de70708f1a104eca977339d9f3007dee'] | Can someone please explain this Android Volley error and if possible a solution for me.
Thank you in advance.
E/Volley: [3997] NetworkDispatcher.processRequest: Unhandled exception java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at java.net.URLEncoder.encode(URLEncoder.java:205)
at com.android.volley.Request.encodeParameters(Request.java:491)
at com.android.volley.Request.getBody(Request.java:477)
at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:245)
at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:219)
at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:97)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
|
fe5b155d32d6e7e7c5e3d4d262f88a5091338218274d28a633f4fe5bccc00867 | ['de71660b8af640e193c01e47c6b3443c'] | After doing a quick copy-paste mistake, I noticed that I get this error if the source links are outside the <head></head> tags.
<html>
<head>
<title>Awesome graph</title>
</head>
<script type="text/javascript" src="jqplot/plugins/jqplot.logAxisRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script>
<body>...
Replacing those in the head tags resolved it immediatly.
<html>
<head>
<title>Awesome graph</title>
<script type="text/javascript" src="jqplot/plugins/jqplot.logAxisRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script>
</head>
<body>...
| 8a20792de4891819d803ce05bba255d628b657bb4bdb4985277cdffa58ead88f | ['de71660b8af640e193c01e47c6b3443c'] | Hi there and thanks in advance for all of you who'll help me on this dead end (for me).
My issue is quite simple to explain: I want to display subtotals on my Excel Pivot Chart, like a line showing the total of the categories.
Here is what I have:
http://i.stack.imgur.com/16fhL.png
and here is what I want: http://i.stack.imgur.com/zEFt7.png
I simply want to add on the graph the line corresponding to "TOTAL BEFORE".
I've been searching on the web ginving one workarround doing and simple chart on the pivot table; but it's not sustainable as the graph cannot follow when I change the pivot table filter.
I cannot figure out why there is not a simple way to add the subtotal in the list field of the chart.
Thanks for your precious help...
|
22bdf716c68c5a31cf08055bd5e7f5077359a282df6b86f0be707007628fc78c | ['de7457f010af4f559e7cf65211c1d02b'] | I am getting the following error and am not sure where to fix it.
Code compiles, and runs, but i get a 500 back which means something is up in the server code. I found this while debugging....thoughts?
error CS1503: Argument 1: cannot convert from 'System.Net.Http.HttpContent' to 'System.Collections.Generic.IEnumerable'
strong text
public async void ExportData()
{
//code to request data from the server
requestUri = ipaddress:port/api/data/export?dataFileId={Id};
var response = await Client.GetAsync(requestUri);
}
Controller
[HttpGet]
[Route("export")]
public HttpResponseMessage Export
var fileContents = _dataService.ExportDataFiles(dataFileId);
var fileLines = string.Empty;
// fileContents.Lines.Aggregate(fileLines, (s, s1) => s+=s1 + Environment.NewLine);
using (var multipartContent = new MultipartContent())
{
foreach (var fileContent in fileContents)
{
foreach (var fileLine in fileContent.Lines)
{
fileLines += fileLine + Environment.NewLine;
}
var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(fileLines));
var streamContent = new StreamContent(fileStream);
streamContent.Headers.ContentType =
System.Net.Http.Headers.MediaTypeHeaderValue.Parse(
"multipart/related; boundary=cbsms-main-boundary");
streamContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = fileContent.Name
};
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/data");
multipartContent.Add(streamContent);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
response.Content = multipartContent;
return response;
}
| 37dae75ba68babfc46180dab2304f187fc290d2bb03dc3c6d191ed7d9a69a34b | ['de7457f010af4f559e7cf65211c1d02b'] | So, it appears that for my situation, I am converting individual bytes read from a UART to an integer
char data[3] = {0};
data[0] = 0x01
data[1] = 0x02
data[2] = 0x03
ParseData(data);
void ParseData(uint8_t * data)
{
uint32_t val = (data[0] * 100) + (data[1] * 10) + data[2];
ESP_LOGI(LOG_TAG, " val # %i ", val);
}
|
eeb298816f0ab12d2e2188b9f997cd32e5a6b8da6546e1632bf2b7a6f45227a0 | ['de75bf2355644d90ad7c2f511574044e'] | From docs at http://developer.android.com/reference/android/graphics/Bitmap.html#recycle%28%29.
Free the native object associated with this bitmap, and clear the reference to the pixel data. This will not free the pixel data synchronously; it simply allows it to be garbage collected if there are no other references. The bitmap is marked as "dead", meaning it will throw an exception if getPixels() or setPixels() is called, and will draw nothing. This operation cannot be reversed, so it should only be called if you are sure there are no further uses for the bitmap. This is an advanced call, and normally need not be called, since the normal GC process will free up this memory when there are no more references to this bitmap.
So it doesn't seem to be necessary to call. The only time I've ever heard a need to manually set an object to null is if its a static variable (or some variable that won't go out of scope easily) and you want to force it out of memory. Maybe if you are continuously allocating bitmaps rapidly there may be a need to try and force garbage collection, but for the majority of cases it is probably not needed.
| d9148b165036606115061b7ad8dc0cad75c78c1a4e0dc5923ed4984ddb9f6b33 | ['de75bf2355644d90ad7c2f511574044e'] | Persist a boolean in sharedPreferences in Activity B after the orientation is set. False can mean one orientation and true can mean another. Then you can check the boolean in onResume of Activity B. This way will let you persist the the orientation between the activities in the app or data getting cleaned out of memory.
Note: You can save the any primitive data and Strings in sharedPreferences. I just chose boolean because you only needed to save 2 states.
|
1afe47a946db08c66742724ca743584912760c9a0e484430022ae1a8c317bd82 | ['de76c0a2154342f381e7810655ce028b'] | I have used most of the softwares that come for this task. They are creating a bootable usb. The problem is with my computer. Everytime, I boot from the usb, the start screen giving option to enter fedora or select troubleshooting are given. I select fedora and the screen goes blank. Nothing happens after that. I'll try installing the latest version of fedora or linux mint and see how the things go from there. | 624eae1bd18ddc0eb0644d48f8d8db3114de743bb59d9e7096a6ee41d44dc4a5 | ['de76c0a2154342f381e7810655ce028b'] | The other issue I'm wondering is that all updates go through Apple. I've heard that's a bit of a problem, that Oracle can't push Java updates without them going through Apple first, causing serious delays. Who knows, maybe this has been patched and is just stuck in limbo. Though at the same time I feel like Java shouldn't even be aware of what key I'm pressing, really feel like this is a Mac problem. I'll try reporting it this weekend on the link you provided. Will likely give you the bounty since no-one else even tried to answer. Thanks for the help. |
cb31a3385b792557915b4d2e2024c951f95e516f26bc1ff9527a3d00372a48c7 | ['de8561692a7b4b26b303d2100635417f'] | Here is the code for the Answer :
private async Task<List<IListBlobItem>> ListBlobsAsync(CloudBlobContainer container)
{
BlobContinuationToken continuationToken = null;
List<IListBlobItem> results = new List<IListBlobItem>();
do
{
bool useFlatBlobListing = true;
BlobListingDetails blobListingDetails = BlobListingDetails.None;
int maxBlobsPerRequest = 500;
var response = await container.ListBlobsSegmentedAsync(BOAppSettings.ConfigServiceEnvironment, useFlatBlobListing, blobListingDetails, maxBlobsPerRequest, continuationToken, null, null);
continuationToken = response.ContinuationToken;
results.AddRange(response.Results);
}
while (continuationToken != null);
return results;
}
And then you can return values like:
IEnumerable<IListBlobItem> listBlobs = await this.ListBlobsAsync(container);
foreach(CloudBlockBlob cloudBlockBlob in listBlobs)
{
BOBlobFilesViewModel boBlobFilesViewModel = new BOBlobFilesViewModel
{
CacheKey = cloudBlockBlob.Name,
Name = cloudBlockBlob.Name
};
listBOBlobFilesViewModel.Add(boBlobFilesViewModel);
}
//return listBOBlobFilesViewModel;
| 424cabe7b123ae67a6776b1ff40a61bfc1067aa1ef1b0325d8025f1849b86a9a | ['de8561692a7b4b26b303d2100635417f'] | This is what i am trying in aspx page
group name is not same in html code how can i manage it pls suggest
i am trying with the radio button in side a repeater control
<asp:Repeater ID="rptGoogleCalenderList" runat="server">
<ItemTemplate>
<tr>
<td style="width: 10px;">
<asp:RadioButton ID="radiocalenderList" CssClass="grpGoogleCalenderList" value="grpGoogleCalenderList" GroupName="GoogleCalenderList" runat="server" />
<%--<input id="" type="radio" name="" />--%>
</td>
<td colspan="3">
<asp:HiddenField ID="hfCalenderId" runat="server" Value='<%#Eval("CalenderId") %>' />
<%#Eval("CalenderName") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
this is what HTML generated for the above code
<tbody><tr>
<td style="width: 10px;">
<span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_0" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl00$GoogleCalenderList" value="grpGoogleCalenderList"></span>
</td>
<td colspan="3">
<input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl00$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_0" value="<EMAIL_ADDRESS>">
my ct calender</td>
</tr>
<tr>
<td style="width: 10px;">
<span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_1" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl01$GoogleCalenderList" value="grpGoogleCalenderList"></span>
</td>
<td colspan="3">
<input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl01$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_1" value="">
</td>
</tr>
<tr>
<td style="width: 10px;">
<span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_2" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl02$GoogleCalenderList" value="grpGoogleCalenderList"></span>
</td>
<td colspan="3">
<input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl02$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_2" value="#<EMAIL_ADDRESS>">
Birthdays</td>
</tr>
<tr>
<td style="width: 10px;">
<span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_3" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl03$GoogleCalenderList" value="grpGoogleCalenderList"></span>
</td>
<td colspan="3">
<input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl03$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_3" value="en.indian#holiday@group.v.calendar.google.com">
Holidays in India</td>
</tr>
</tbody></table>
|
b5e19f84a37bdcc8fe924fb23fabdfd18eb9862ed6ae37abb07ff7bb0544707c | ['de8d9ea18a974e20a7c7deb7e181ff38'] | You are calling .ToString() on SelectedItem. SelectedItem is not the string you see in the drop down list. Instead it's the class that has properties of DisplayName and AuthorName.
DropDownList SelectedItem Property
I'm not sure if you've overridden the ToString method for whatever class is used to store author information (I used YourAuthorClass in my example), but this could be the source of the problem. I believe the following code is what you need.
if (lbAuthorList.SelectedItem != null)
{
if (typeof(YourAuthorClass) == lbAuthorList.SelectedItem.GetType())
{
YourAuthorClass currentSelection = (YourAuthorClass)lbAuthorList.SelectedItem;
if (currentSelection.AuthorName == "Unknown")
{
sqlInsertUnknownInfo.InsertParameters.Clear();
sqlInsertUnknownInfo.InsertParameters.Add("RequestID", DbType.Int32, Request.QueryString["Requestid"]);
sqlInsertUnknownInfo.InsertParameters.Add("AuthorID", DbType.Int32, AuthorID.ToString());
}
}
}
| c99a11bbd23bd7877e0d10f733f7625ea05566c5831e1ee31eb28ff63cb6a786 | ['de8d9ea18a974e20a7c7deb7e181ff38'] | I found an alternate solution that I feel is more straight forward.
Create the following style (I believe the property you are trying to bind ItemsSource to is named Field)
<Style x:Key="MyCVPStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="ToolTip">
<Setter.Value>
<StackPanel>
<ListView ItemsSource="{Binding Path=Cells[Field].Value}" />
</StackPanel>
</Setter.Value>
</Setter>
</Style>
But this does require that you have the field you're binding your ItemsSource to defined in FieldLayout.Fields. You may want to set the Visibility of that field to collapsed. I've also included the field that has the tooltip style applied to it.
<igDP:Field Label="Value" Name="Value" >
<igDP:Field.Settings>
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource ResourceKey=MyCVPStyle}" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Label="Field" Name="Field" Visibility="Collapsed" />
|
313b471814e389c7d57f8162499139e5de35de2b6fae2d145c28dc21781b0bbd | ['de9481ca1eb542ab86a74fde72cec21e'] | Python, 186 chars (UNIX line termination)
for j in range(1,n):
for s in p:
print s
x=2**j;y=2*x;p.extend(['']*x)
for i in range(y-1,-1,-1):
if i<x:
s=' '*x;p[i]=s+p[i]+s
else:
q=p[i-x];p[i]=q+q
| 5e928060bb4b30fb35dd3a13e2436078bddd847616810146957e8b9e7ee845c2 | ['de9481ca1eb542ab86a74fde72cec21e'] | The only thing I know of that can handle that very well.. beautifuly is python's beautiful soup. The DOM is all split up into a parse tree which you can add to or take away at <PERSON> you can write a python script to handle the html and then coordinate the scripts by database or system call. alternatively server side javascript might be worth investigating.
|
768bae8ffe531a8532bf7468580e52e43f3af0d29a897ab5d8980f547b99f6dd | ['de994e7d80234e4b88a263c7a9b92906'] | I'm trying to inject a property into an ActionFilter of mine called UnitOfWorkAttribute. I have this code:
[Inject]
public IUnitOfWork UnitOfWork { get; set; }
Before that gets executed, I tell Ninject to resolve this with:
Bind<IUnitOfWork>().To<NHibernateUnitOfWork>().InThreadScope();
My problem is that in my UnitOfWorkAttribute class, whenever I try to use my UnitOfWork property, It comes through as Null. This is my interface:
public interface IUnitOfWork : IDisposable
{
void Begin();
void Commit();
void Rollback();
}
and this is my concrete:
public interface INHibernateUnitOfWork : IUnitOfWork
{
ISession Session { get; }
}
public class NHibernateUnitOfWork : INHibernateUnitOfWork
{
private readonly ISessionSource sessionSource;
private ITransaction transaction;
private ISession session;
private bool disposed;
private bool begun;
public NHibernateUnitOfWork(ISessionSource sessionSource)
{
this.sessionSource = sessionSource;
Begin();
}
//.......
}
I am fulfilling the interface under the //......
What am I doing wrong here?
| f44684e063a7bfafefcf4828d84a7dc2c02766db2ef2b32c398919dbf904b440 | ['de994e7d80234e4b88a263c7a9b92906'] | I'm wanting to create an object that contains a body and a head that is linked to that. If I rotate the parent object, the child object needs to rotate with it. I also need the ability to go in and rotate the child without effecting the parent. I'm trying to do this using groups, but I'm getting mixed up on how to set this up. Here is structure I'm trying to build:
Character -> Body -> Head
So if I do a rotate on Character, Body and Head move. If I rotate Body, the head keeps its position relative to the body. I know that Box2d can do this, but I really just want to keep it this simple.
|
b9b3dca1b3f929105f5686a6614835737bc923f2a58338b2cf0ba00311b86f29 | ['dea976305c414a1399d585f8e937a26b'] | I have the following piece of code in my app.
let currentUserId = Auth.auth().currentUser!.uid
db.collection("users").document(currentUserId).updateData(["Token": FieldValue.delete()])
Auth.auth().signOut()
The signout completes before the delete and hence the delete is not accomplished on firestore. How do I wait to attempt sign out till the delete function is complete?
| da30dc72e85e5217529f9ad5425af53e6989fff097267c2adf5a864c128dde39 | ['dea976305c414a1399d585f8e937a26b'] | I get the following error when trying to pass data from one viewcontroller to another: "Cannot assign value of type 'activityTableViewController.request' to type 'activityDetailTableViewController.request?'"
What am I doing wrong?
First view controller:
class activityTableViewController: UITableViewController {
struct request {
var fromDateAndTime: String
var toDateAndTime: String
var createdBy: String
init(fromDateAndTime: String, toDateAndTime: String, createdBy: String) {
self.fromDateAndTime = fromDateAndTime
self.toDateAndTime = toDateAndTime
self.createdBy = createdBy
}
}
var requestList: [request] = []
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "activityToDetail" {
if let nextViewController = segue.destination as? activityDetailTableViewController {
let indexPath = tableView.indexPathForSelectedRow
nextViewController.requestDetail = requestList[indexPath!.row]
}
}
}
}
Second view controller:
class activityDetailTableViewController: UITableViewController {
struct request {
var fromDateAndTime: String
var toDateAndTime: String
var createdBy: String
init(fromDateAndTime: String, toDateAndTime: String, createdBy: String) {
self.fromDateAndTime = fromDateAndTime
self.toDateAndTime = toDateAndTime
self.createdBy = createdBy
}
}
var requestList: request!
}
|
4e7f0187ac33c2ed31c18166ed10722a16a4c141d54296280b26f456a46e2c94 | ['deabf155260047e0b5f57bb5de6957c9'] | I have bought an ubuntu pre-installed laptop and want to remove ubuntu and replace with windows 8.1 x64 pro..
It has UEFI and in GPT.. disabled secure boot.. but there is no fast boot or legacy boot options..
Problem is i can't boot my windows 8.1 installation disc.. It says an error 0xc0000225.
Here is what i did so far:
- Boot Ubuntu Live USB
- Removed all partitions and convert GPT into MBR
- Disabled Secure boot on UEFI
- After that boot my windows 8 installation. still got error
What should i do? is there no way of installing windows 8 on my laptop? or is my laptop only for Ubuntu?
| 84813cbba82575275bdc25d854033d82bbd502734dfc155425bc0f78174ca3ec | ['deabf155260047e0b5f57bb5de6957c9'] | No. my disc is fine and working with all my PCs and Laptops.. Im also using im using an external DVD drive and overide the boot to it.. after i booted the DVD i will get a Windows boot Manager error. I also tried my old windows 7 and XP disc but they wont boot because its not a UEFI bootable. Well, thats what i learned so far..
Furthermore, theres no more options for booting here, because all i can see is the secureboot option, and the boot devices and no more.. i dont know whats wrong with this laptop because its very different from the others i have used.. |
b88c9bd01e19fdbd17885f1ec157dcb7f63fed48c38f59602252f9f234aa67be | ['dec3ad7a3d354190b456a518466323ac'] | I have the following question: For $z$ not in the real interval $[0,1]$, let $f(z)=\int_{0}^{1} \frac{t^{2}dt}{t-z}$. Show that $f$ is differentiable.
I got $\lim_{z\rightarrow w}\,\,\int_{0}^{1} \frac{t^2}{(t-z)(t-w)}\,\,\,\,$ . Now I know that we can change the limit with integral if the integrand uniformly convergent, but I couldn't show that. Any help would be great.
| 9031b4f89e10893d840e787e8f8f2505dce83cb3328f0d03e2bc6c2b1a4aab1e | ['dec3ad7a3d354190b456a518466323ac'] | Show that the series $\sum_{n=1}^{\infty}\,\, \frac{z^n}{1+z^{2n}}\,\,\,$ converges in both interior and exterior of the the unit circle and represents an analytic function in each region.
I want to apply the Weierstrass M Test:I get if $|z|<r$ then $|\frac{z^n}{1+z^{2n}}\,\,\,\,|<\frac{r^n}{1-r^n}\,\,\,$and now I couldn't continue from this point. Thanks for any help
|
5ec45cd2d8ad7c378cf7ba04f47ced7c0f3e1fe51e7dd7276202c65de40e9b07 | ['dec8cf88add74527a5d8b058299e9dc3'] | As you know, you can't have capital letters in your image filenames that you use in your Android project (Ressource/Drawables folder).
I've got hundreds of small images (GOOG.GIF as an exemple) that I need to import into my project (I usually do a simple drag and drop from a desktop folder into Eclipse).
So here's the question :
How do I quickly change all the filenames (replace all capital letters to lower case) before importing into my project ?
So,
GOOG.GIF becomes goog.gif
AAPL.GIF becomes aapl.gif
etc.
Any quick command line solution or another tool to do just that ?
Thanks.
| b0affba2cdc241010a5ced9f0a853c5566098b73635e3bd1a1e39c536b575a7f | ['dec8cf88add74527a5d8b058299e9dc3'] | Take a look at the Some Intent examples section (from Common Tasks and How to Do Them in Android):
basically, you use myIntent.putExtra (...)
to send data (can be String, Int, Boolean etc) to the other receiving end (the other activity)...
then, result will be passed back into the calling Activity's onActivityResult() method:
protected void onActivityResult(int requestCode, int resultCode, Intent data){
// See which child activity is calling us back.
switch (resultCode) {
case CHOOSE_FIGHTER:
// This is the standard resultCode that is sent back if the
// activity crashed or didn't doesn't supply an explicit result.
if (resultCode == RESULT_CANCELED){
myMessageboxFunction("Fight cancelled");
}
else {
myFightFunction(data);
}
default:
break;
}
H.
|
cfa711fd505f1bcc9ba4c7930f2264908b5419e754eb388840efe14404b14c57 | ['ded19be5122c4b3ba116bc83962d11d2'] | Where's the problem really?
This path exists, but the program fails .
I want to know the cause of this problem?
const std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options options = (
std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options<IP_ADDRESS>follow_directory_symlink |
std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options<IP_ADDRESS>skip_permission_denied
);
try
{
for (const auto& dirEntry :
std<IP_ADDRESS>filesystem<IP_ADDRESS>recursive_directory_iterator("C:\\Users\\myuser",
std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options(options)))
{
std<IP_ADDRESS>cout << dirEntry.path().generic_string() << std<IP_ADDRESS>endl;
}
}
catch (std<IP_ADDRESS>filesystem<IP_ADDRESS>filesystem_error & fse)
{
std<IP_ADDRESS>cout << fse.what() << std<IP_ADDRESS>endl;
}
C:/Users/myuser/Contacts/{857B728B-5B31-4F94-B832-522DF52E4335}/VertiPaq_68547BCEF3A344CDA3CE/724C7FC1B3284E4BBE1C.3.db/Model.193.cub/Cuentas por Cobrar_f7776207-ea17-4002-8801-3561d1b2d1fc.92.det/Cuentas por Cobrar_f7776207-ea17-4002-8801-3561d1b2d1fc.23.prt
recursive_directory_iterator<IP_ADDRESS>operator++: The system cannot find the path specified.
| f7bcb572f17bc83bb22e946ed8d18e258791d788eed37c939b97cc7dff0c2c87 | ['ded19be5122c4b3ba116bc83962d11d2'] | please help me ....
I want to show & return path of some of my files .
But unfortunately it does not return the path of all files ,
Please see the photo below
my code :
const std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options options = (
std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options<IP_ADDRESS>follow_directory_symlink |
std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options<IP_ADDRESS>skip_permission_denied
);
try
{
for (const auto& dirEntry :
std<IP_ADDRESS>filesystem<IP_ADDRESS>recursive_directory_iterator("C:\\",
std<IP_ADDRESS>filesystem<IP_ADDRESS>directory_options(options)))
{
std<IP_ADDRESS>cout << dirEntry.path().u8string() << std<IP_ADDRESS>endl;
}
}
catch (std<IP_ADDRESS>filesystem<IP_ADDRESS>filesystem_error & fse)
{
std<IP_ADDRESS>cout << fse.what() << std<IP_ADDRESS>endl;
}
error :
status: The process cannot access the file because it is being used by another process.: "C:\pagefile.sys"
what is the problem?
How do I reject this error?
|
3002b17c7f07730afad292f11718f03d11d0dec8752790d72017e8b428e0b27b | ['ded4c0010ff344c49433780a87e91fc4'] | How come whenever I clear my app data, my previously working SQLite database doesn't work anymore?
here is my code for my database:
package tsu.ccs.capstone;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DBUser {
public static final String KEY_ROWID = "_id";
public static String KEY_USERNAME= "username";
public static String KEY_PASSWORD = "password";
public static String KEY_NUMBER = "number";
private static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "usersdb";
private static final String DATABASE_TABLE = "users";
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_CREATE =
"create table users (_id integer primary key autoincrement, "
+ "username text not null, "
+ "password text not null, "
+ "number text not null);";
private Context context = null;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBUser(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
//creating the DB
@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS users");
onCreate(db);
}
}
//open DB for writing/reading mode
public void open() throws SQLException
{
db = DBHelper.getWritableDatabase();
}
//close the DB
public void close()
{
DBHelper.close();
}
//insert Initial Values to the DB
public long AddUser()
{
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_USERNAME, "admin");
initialValues.put(KEY_PASSWORD, "admin");
return db.insert(DATABASE_TABLE, null, initialValues);
}
//delete the entire rows
public long DeleteUser()
{
return db.delete(DATABASE_TABLE, "1", null);
}
public boolean CheckContent()
{
Cursor mCursor = db.rawQuery("SELECT * FROM " + DATABASE_TABLE + " WHERE _id=1", null);
if (mCursor != null) {
if(mCursor.getCount() > 0)
{
return true;
}
}
return false;
}
//update the DB
public boolean UpdateUser(long rowId, String username, String password)
{
ContentValues newCon = new ContentValues();
newCon.put(KEY_USERNAME, username);
newCon.put(KEY_PASSWORD, password);
return db.update(DATABASE_TABLE, newCon, KEY_ROWID + "=" + rowId, null) > 0;
}
// searching the DB for username and password match
public boolean Login(String username, String password) throws SQLException
{
Cursor mCursor = db.rawQuery("SELECT * FROM " + DATABASE_TABLE + " WHERE username=? AND password=?", new String[]{username,password});
if (mCursor != null) {
if(mCursor.getCount() > 0)
{
return true;
}
}
return true;
}
//Store Recipient's Number to the DB
public boolean EditNumber(long rowId, String number)
{
ContentValues editNumber = new ContentValues();
editNumber.put(KEY_NUMBER, number);
return db.update(DATABASE_TABLE, editNumber, KEY_ROWID + "=" + rowId, null) > 0;
}
public Cursor newNumber() {
String query = "SELECT * FROM " + DATABASE_TABLE + " WHERE _id=1";
System.out.println(query);
Cursor cur = db.rawQuery(query, null);
cur.moveToFirst();
return cur;
}
}
and here is my FirstActivity:
package tsu.ccs.capstone;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.View;
public class FirstActivity extends Activity {
final String PREFS_NAME = "FirstTimeCheker";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
overridePendingTransition (R.anim.incoming, R.anim.outgoing);
DBUser dbUser = new DBUser(FirstActivity.this);
dbUser.open();
if(dbUser.CheckContent()){
//do nothing
} else {
dbUser.AddUser();
}
dbUser.close();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_first, menu);
return true;
}
public void gotoLogin (View v) {
SharedPreferences mPrefs;
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// second argument is the default to use if the preference can't be found
Boolean RegisterScreenShown = mPrefs.getBoolean(PREFS_NAME, false);
if (!RegisterScreenShown) {
Intent intentIntro = new Intent(this, RegisterActivity.class);
startActivity(intentIntro);
overridePendingTransition (R.anim.incoming, R.anim.outgoing);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(PREFS_NAME, true);
editor.commit(); // Very important to save the preference
}else{
Intent intentAlecc = new Intent(this, AleccActivity.class);
startActivity(intentAlecc);
overridePendingTransition (R.anim.incoming, R.anim.outgoing);
}
}
public void gotoCctv (View v) {
Intent intent = new Intent(this, CctvActivity.class);
startActivity(intent);
overridePendingTransition (R.anim.incoming, R.anim.outgoing);
}
public void editUser (View v) {
Intent intent = new Intent(this, EditUserActivity.class);
startActivity(intent);
overridePendingTransition (R.anim.incoming, R.anim.outgoing);
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition (R.anim.incoming, R.anim.outgoing);
}
}
| 3052a15ebc6580ed1303186b424b9061e11f6d2c0c5fca7210b43f3a6dd1b0a8 | ['ded4c0010ff344c49433780a87e91fc4'] | I'm creating an android app that has "User Login" page. I've try using SQlite and this is my code:
package tsu.ccs.capstone;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DBUser {
public static final String KEY_ROWID = "_id";
public static final String KEY_USERNAME= "username";
public static final String KEY_PASSWORD = "password";
private static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "usersdb";
private static final String DATABASE_TABLE = "users";
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_CREATE =
"create table users (_id integer primary key autoincrement, "
+ "username text not null, "
+ "password text not null);";
private Context context = null;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBUser(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS users");
onCreate(db);
}
}
public void open() throws SQLException
{
db = DBHelper.getWritableDatabase();
}
public void close()
{
DBHelper.close();
}
public long AddUser(String username, String password)
{
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_USERNAME, "p");
initialValues.put(KEY_PASSWORD, "p");
return db.insert(DATABASE_TABLE, null, initialValues);
}
public boolean Login(String username, String password) throws SQLException
{
Cursor mCursor = db.rawQuery("SELECT * FROM " + DATABASE_TABLE + " WHERE username=? AND password=?", new String[]{username,password});
if (mCursor != null) {
if(mCursor.getCount() > 0)
{
return true;
}
}
return false;
}
}
as you can see, I have a InitialValue for my username and password field in my layout.
my problem is I want to give the user an option to change the default username and password that I set. Simply put, just overwrite the InitialValues then save my database.
Can anyone help me, I'm only beginning android programming and I'm at lost with this one.
|
637e62058c569442f06cc91d5223bcaad6d8b7d924e7c07858390a7da0f3449b | ['ded8120b0636440ea2ec5bce50f2b156'] | I'm using INRIA person dataset, i iterate the images and everything is fine and after i have this function
vector<Mat> HOG_extract(Mat input_image, bool patch_size, int width, int height)
{
Mat gray_image;
cvtColor(input_image, gray_image, CV_BGR2GRAY);
HOGDescriptor hog;
hog.winSize = Size(width, height);
hog.blockSize = Size(block_size, block_size);
hog.blockStride = Size(block_stride, block_stride);
hog.cellSize = Size(cell_size, cell_size);
hog.nbins = bin_size;
vector<float> hog_value;
vector<Point> locations;
hog.compute(gray_image, hog_value, Size(0, 0), Size(0, 0), locations);
}
when he gets to hog.compute i receive an exception and libpng error: IDAT: invalid distance too far back.
like how i can solve this? looks like something happend when using imread and converting in gray
| a2f889b9ccbdae603689276b34d54a3ba72f050481519243dc2b11a1c93f9105 | ['ded8120b0636440ea2ec5bce50f2b156'] | I need some help with using contextual binding with ninject
I Have something like this :
public interface ISound
{
String Sound();
}
public class Cat : Animal
{
private string category;
private ISound sound;
public Cat(ISound sound, int age, string name, string sex, string category)
: base(age, name, sex)
{
this.sound = sound;
this.category = category;
}
public class CatSound : ISound
{
public String Sound()
{
return "Meow";
}
}
and exactly the same Dog Sound who implemets Sound
and my bindingmodule:
public class BindingModule:NinjectModule
{
private readonly SelectorMode _typeofsound;
public new StandardKernel Kernel => ServiceLocator.Kernel;
public BindingModule(SelectorMode mode)
{
_typeofsound = mode;
}
public override void Load()
{
if (_typeofsound == SelectorMode.Dog)
{
Kernel.Bind<ISound>().To<DogSound>();
}
else if(_typeofsound==SelectorMode.Cat)
{
Kernel.Bind<ISound>().To<CatSound>();
}
else
{
Kernel.Bind<ISound>().To<HorseSound>();
}
}
public class SelectorMode
{
public static SelectorMode Cat;
public static SelectorMode Horse;
public static SelectorMode Dog;
}
}
and the test i'm trying to run
public class WhenBindingCat:GivenABindingModule
{
[TestMethod]
public void SouldBindItToCat()
{
// var kernel=new Ninject.StandardKernel(new )
var sut = new BindingModule(SelectorMode.Cat);
sut.Load();
}
and it don't know how i should assert here
|
58912ee84bc1f0b4641d73a1b607f93f6793061862de8cad3839b7d7baf36a84 | ['dee9548351994a069eb8708df13f45f3'] | This is part of my code... I didn't post it here because it is a bit long, lol.
What I was trying to do is that, I try to grab user input (from a UITextField) and display it in the screen (by a UITextView). After that, I grab the .text value from the UITextView, convert it from NSString to NSData, then upload the NSData object to a HTTP server, with a php upload script.
NSString *completeName = [NSString stringWithFormat:@"%@/%@.txt",mainDelegate.gCourseCode,mainDelegate.gUID];
NSString *finalWordList = wordList.text;
NSData *data = [finalWordList dataUsingEncoding:NSUTF8StringEncoding];
NSString *urlString = @"http://cetl.no-ip.org:50080/upload.php";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@\"\r\n",completeName] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:data]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(returnString);
The txt file can be uploaded to the server. But it misses the \n character.
Thank you very much for your help.
| 12e91e6bbff38301fde21aedc8ac8587d97e0dca813b432b6cbffc6d7ffe9642 | ['dee9548351994a069eb8708df13f45f3'] | When I tried to export an IPA for enterprise distribution on XCode 7, I cannot select the correct development team.
All teams are showing under XCode Preference > Profiles
I can see all the teams when I select a export method rather than Enterprise Distribution
I have tried to remove and add the team again
I have checked that my developer account is not expired and there is no agreement pending for approval.
I have tried to restart XCode and my Mac, still no luck
Any kind of help would be greatly appreciated.
|
0b2399af41f9a8dbe421bc13c9eca33921dd0f03be1bb4819d37ed96c910054b | ['deec1cee3776438484706452f6fe5768'] | Silly, but this should work.
public extension ProcessInfo {
func osName() -> String? {
let version = self.operatingSystemVersion
switch version.minorVersion {
case 15: return "Catalina"
case 14: return "Mojave"
case 13: return "High Sierra"
case 12: return "Sierra"
case 11: return "El Capitan"
case 10: return "Yosemite"
case 9: return "Mavericks"
case 8: return "Mountain Lion"
case 7: return "Lion"
case 6: return "Snow Leopard"
case 5: return "Leopard"
case 4: return "Tiger"
case 3: return "Panther"
case 2: return "Jaguar"
case 1: return "Puma"
case 0: return "Kodiak"
default: return nil
}
}
| 84715f8fdbd799ffc1bb173fdadf7d893b96226060bd03e45fe50fb27bfb3daa | ['deec1cee3776438484706452f6fe5768'] | In case your app is launched from the Daydream app, calling Application.Quit() will only take you back to the daydream app, not the Android 2D app launcher.
What you need to do is to write the following code in Java
public void Quit(Activity currentActivity) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_LAUNCHER);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
currentActivity.startActivity(startMain);
}
And then invoke the above Java method from Unity.
|
53c29f93dd147b9ce722731e0cf1fefee944db2bf16afb03cf950aa130cfdb4d | ['defb3ad266954bc6b69caac0f65279c0'] | I found in my class notes the following comment regarding branch choice:
It is important to choose a branch consistently, otherwise one can get absurd results, for example: $-1 = i^2 = \sqrt{-1}\times\sqrt{-1} = \sqrt{(-1)\times(-1)} = \sqrt{1} = 1$
I don't understand this example. Can you please explain to me which branch we started with and when did we changed branches?
Thank you!
| f08490abd2e9f1706d8b472221e85c560defd1c892369535b0e64233ba63323d | ['defb3ad266954bc6b69caac0f65279c0'] | Thank you very much for the reply. when you mean 'in the short term', do you mean adding 95 octane will cause problems in the long run? or do you mean that I might have to experience issues here anad there till the engine gets used to the new fuel octane? :) |
2814c55dea20fa1456646f34cce528d756c660a8a3876995316fb325ee40204a | ['defce963771e4913954c53c27b49914c'] | The problem lays in your definition of the SQL variable.
You are creating a tuple/collection of two elements. If you print type(SQL) you will see something like this: ('''SELECT...?;''', ('your_user's_input')).
When you pass this to cursor.execute(sql[, parameters]), it is expecting a string as the first argument, with the "optional" parameters. Your parameters are not really optional, since they are defined by your SQL-query's [Train]. Parameters must be a collection, for example a tuple.
You can unwrap your SQL statement with cursor.execute(*SQL), which will pass each element of your SQL list as a different argument, or you can move the parameters to the execute function.
Train_ID = input('Train ID')
SQL = '''SELECT F.Cargo_ID, F.Name, F.Weight, T.Train_ID, T.Assembly_date
FROM FreightCargo F LEFT JOIN [Train] T
ON F.Cargo_ID = T.Cargo_ID
WHERE Train_ID = ?;'''
cursor = conn.cursor()
cursor.execute( SQL, (Train_ID,) )
names = [x[0] for x in cursor.description]
rows = cursor.fetchall()
Temp = pd.DataFrame( rows, columns=names)
Temp
| 218aa5a1207cf4947d0b03abfdcb603a6c56bd36394f44db63226f50303c9167 | ['defce963771e4913954c53c27b49914c'] | There are no built-in functions to do the factorial of a number in JavaScript, but you could make a .js file just for this purpose, and import it in each file you intend to use it for.
Take a look at this question: How do I include a JavaScript file in another JavaScript file? for importing files. I believe this is the closest you can get for what you want.
As <PERSON> already mentioned in a comment, you should beware overflowing for large factorial numbers, as the highest number you can get to is 2^53 - 1 for integers, or 2^32-1 for bitwise operations. Make your own BigInt library, or search for one: there exist many open-source ones out there.
|
029e6630fe2ec957dcd41cdeb6c6f8d0b0cc753ec14e91b73a1f01b308f6afba | ['deff96f2595f42ca8d2b2999b08c0f0c'] | If you don't need to float the box and can rework your layout a bit you can try this out. display:table-cell and vertical-align:middle added to .box and float:left removed.
.box
{
display:table-cell;
vertical-align:middle;
width:100px;
height:40px;
border:1px solid;
background:blue;
color:yellow;
-moz-border-radius: 5px;
border-radius: 5px;
padding:0;margin:0;
text-align:center;
font : 50% "Trebuchet MS", verdana, arial, tahoma, sans-serif;
}
.box>h2{padding:0;margin:0;}
| c9acd09fe680a44a395e061cf733289e638b35b60cbe92a6327fa0d22a3649b1 | ['deff96f2595f42ca8d2b2999b08c0f0c'] | This is an old posting but I came across it while helping out elsewhere, just wanted to add some code regarding your request of not having an explicit index var for keeping track of the index. The value returned from index() is zero-based.
var myCheckboxes = $("input[type=checkbox].it");
myCheckboxes.each(function(){
alert(myCheckboxes.index(this));
// do whatever you need with the index of the checkbox
}
More on .index() can be found here: http://api.jquery.com/index/
|
b709cb37347b6fe87024f9dca474409b83efb8e745a7494305046f8c20a33ed9 | ['df148240de9a477680a90f589197630f'] | when starting a script, create a lock file to know that this script is running. When the script finish, delete the lock file. If somebody kill the process while it is running, the lock file remain forever, though test how old it is and delete after if older than a defined value. For example,
#!/bin/bash
# 10 min
LOCK_MAX=600
typedef LOCKFILE=/var/lock/${0##*/}.lock
if [[ -f $LOCKFILE ]] ; then
TIMEINI=$( stat -c %X $LOCKFILE )
SEGS=$(( $(date +%s) - $TIEMPOINI ))
if [[ $SEGS -gt $LOCK_MAX ]] ; then
reportLocking or somethig to inform you
# Kill old intance ???
OLDPID=$(<$LOCKFILE)
[[ -e /proc/$OLDPID ]] && kill -9 $OLDPID
# Next time that the program is run, there is no lock file and it will run.
rm $LOCKFILE
fi
exit 65
fi
# Save PID of this instance to the lock file
echo "$$" > $LOCKFILE
### Your code go here
# Remove the lock file before script finish
[[ -e $LOCKFILE ]] && rm $LOCKFILE
exit 0
| 4da44bca58f1fe04be34aa61c9b26b88298075aea712d3b5476b8244a9ea3462 | ['df148240de9a477680a90f589197630f'] | I use Ubuntu Server as you can see:
#uname -a
Linux grosella 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Supose a data file like this (/tmp/data.txt):
1 AAAA
2 BBBB
3 CCCC
4 DDDD
5 EEEE
6 FFFF
Run the following Bash script:
typeset -i ACUM=0
typeset -a V=('')
cat /tmp/data.txt | \
while read LINEA ; do
[ "x$LINEA" == "x" ] && break
V=( $LINEA )
VAL="${V[0]}"
[ "x$VAL" == "x" ] && continue
[[ $VAL =~ ^[0-9]+$ ]] || continue
((ACUM+=VAL))
echo -e "VAL=$VAL\t\tACUM=$ACUM"
done
echo -e "\nFinal Result: $ACUM"
And here is the printed output:
VAL=1 ACUM=1
VAL=2 ACUM=3
VAL=3 ACUM=6
VAL=4 ACUM=10
VAL=5 ACUM=15
VAL=6 ACUM=21
Final Result: 0
Instead of 21, final result is 0. What is wrong?
|
28d17f1374b760c0fc3d35c49a34d43e5d658614e12a5c704c1773ed60669b96 | ['df1c665ce60b4d06bc234da1a82af191'] | Create a new xml style as shown below.
<style name="AppTheme.PopupWindow">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
</style>
All you need to do after creating the theme is apply it to the fragmentactivity in the manifest.
<activity android:name=".PopupWindow" android:theme="@style/AppTheme.PopupWindow"></activity>
| 1995a9ecfbb280755fd316829d27fb2cae7fe6a6cb09efd83e4b73e4a20e35ca | ['df1c665ce60b4d06bc234da1a82af191'] | You have to update the targetSdkVersion in your app's build.gradle file. The build.gradle file takes precedent over the manifest. If you still want to look at what is being merged into your manifest from external dependencies you can open your app's manifest file and click on the merged manifest tab at the bottom.
|
877e422847d65f02730134436e8ecfc7b8a2e0983dd8683ff50e0f069e942827 | ['df2812bc6a98454d8fc655284ef5d9cf'] | I think you better get old document, copy data, remove document and add new with modified data.
mgr = XmlManager()
uc = mgr.createUpdateContext()
container = mgr.openContainer("labs.dbxml") # Here must be your database name
qc = mgr.createQueryContext()
document = container.getDocument("Lab11")
name = document.getName()
content = document.getContent()
# Change fields here using XPath
container.deleteDocument('La1 1', uc)
container.putDocument(name, content, uc)
| 394dd718623d45dad793a14b2b0ecb6c17306826b458d7dfdb41436f81befb8c | ['df2812bc6a98454d8fc655284ef5d9cf'] | I have configuration in CMAkeLists.txt
set(SOURCE_FILES client/client.cpp)
add_executable(Client ${SOURCE_FILES} client/client.cpp)
So I can launch client.cpp in CLion (Shift + F10). But if I need to launch client.cpp with argv parameter (it has one integer as parameter) I must change configuration in CLion adding program arguments.
Maybe I can add some parameters using CMakeLists.txt?
|
c4be412d2ff4a7389434b9cbe0c03d8c40cc733ccaf0bfe10946d01cf9c080c3 | ['df33ffe95bbe484d8b6019680a97dff7'] | I found out what was wrong. Not sure I understand though. The .card-list were not the only elements in my row.
The $('.card-list:nth-child(3n)') was not only counting the .card-list but also what came before, even though it didn't have the .card-list class.
I should have checked that earlier, thank you for the help by the way.
Here is what I had :
<div class="row">
<div class="col-xs-12 text-center">
<h2 class="title-bullet-small">Title</h2>
</div>
<div class="col-xs-12 list-filters">
Some forms
</div>
<div class="card-list">
<PERSON>
</div>
<div class="card-list">
<PERSON>
</div>
<div class="card-list">
<PERSON>
</div>
</div>
Here is what I had to do in order for the $('.card-list:nth-child(3n)') to work:
<div class="row">
<div class="col-xs-12 text-center">
<h2 class="title-bullet-small">Title</h2>
</div>
<div class="col-xs-12 list-filters">
Some forms
</div>
</div>
<div class="row">
<div class="card-list">
<PERSON>
</div>
<div class="card-list">
<PERSON>
</div>
<div class="card-list">
<PERSON>
</div>
</div>
| 527f357c4b09131da819ea74f7969b694363be3c6c06a86eee27faf76d9d0b80 | ['df33ffe95bbe484d8b6019680a97dff7'] | I'm having trouble adding a "close" button to my Bootstrap tab content. Not only should the tabs open and close on hover, but I have to add a button to allow users to click and close the tab.
<!-- SIDE NAV -->
<div class="col-xs-3 hidden-xs">
<div class="row">
<nav class="side-nav">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="full-width">
<a href="#accueil" aria-controls="accueil" role="tab" data-toggle="tab">TAB 1</a>
</li>
<li role="presentation" class="full-width">
<a href="#connaitre-la-ccmv" aria-controls="connaitre-la-ccmv" role="tab" data-toggle="tab">TAB 2</a>
</li>
</ul>
</nav>
</div>
</div>
<!-- Tab panes -->
<div class="tab-content col-xs-9 hidden-xs">
<div role="tabpanel" class="tab-pane row" id="accueil">
<div class="col-xs-4">
<h5 class="title-tab">TAB CONTENT 1</h5>
<ul class="list-tab">
<li>
<a href="">Some text</a>
</li>
<li>
<a href="">Some other text</a>
</li>
</ul>
</div>
<div class="col-xs-12">
<button type="button" class="close">X</button>
</div>
</div>
</div>
...
Can someone please help with the js part ? I haven't found anything about it in the Bootstrap documentation...
|
185d73f33a8c72d48c2c4f471b3d2a337094b15950badcf44c57e6e4c02ba119 | ['df5dc5307b2449a5a39b178d0d45ac84'] | I've already created the table successfully:
function jal_install () {
global $wpdb;
global $jal_db_version;
$table_name = $wpdb->prefix . "liveshoutbox";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT, time bigint(11) DEFAULT '0' NOT NULL, name tinytext NOT NULL, text text NOT NULL, url VARCHAR(55) NOT NULL, UNIQUE KEY id (id) );";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
$welcome_name = "Mr. <PERSON>";
$welcome_text = "Congratulations, you just completed the installation!";
$insert = "INSERT INTO " . $table_name .
" (time, name, text) " .
"VALUES ('" . time() . "','" . $wpdb->escape($welcome_name) . "','" . $wpdb->escape($welcome_text) . "')";
$results = $wpdb->query( $insert );
}
}
jal_install ();
But when I try to refer to this table as how WP refers to its internal tables like $wpdb->posts:
var_dump($wpdb->liveshoutbox);
The output is :
null
Why?
| 3d9bda3849ecf06a4d4b4ea7e5f5ec8f4a32b0c0ca467b6811c0ed34d740251d | ['df5dc5307b2449a5a39b178d0d45ac84'] | <form style="text-align:center;" id="paypalform" action="https://www.paypal.com/cgi-bin/webscr" method="POST">
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' <EMAIL_ADDRESS>'>
<input type='hidden' name='item_name' value='201001114262121'>
<input type='hidden' name='amount' id="amount" value='1.00'>
<input type='hidden' name='currency_code' value='CAD'>
<input type='hidden' name='return' value='http://www.xxx.com/paypal_process.php'>
<input type='hidden' name='invoice' value='82'>
<input type='hidden' name='charset' value='utf-8'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='no_note' value=''>
<input type='hidden' name='notify_url' value='http://www.xxx.com/return.php'>
<input type='hidden' name='rm' value='82'>
<input type='hidden' name='cancel_return' value='http://www.xxx.com/index.html'>
</form>
Anyone knows?
|
901bba1b8dadfb4f2e5db405a70d891bbae702a6f0c6a6b385c5a76fc5c279aa | ['df66a979fbca4563835bfcb9ef1f454c'] | You don't give enough information about what you are trying to do, but I think the answer to this question may help you: http://facebook.stackoverflow.com/questions/7258394/i-get-a-could-not-find-com-facebook-android-apk-error-when-i-run-my-android-pr/7265972#7265972
At least it sounds like the same problem you have.
| be1cc10464ec5f97e150ab70286b407a5a44e54626d247ce4cad6ed33a9b4cae | ['df66a979fbca4563835bfcb9ef1f454c'] | This page explains Android activity lifecycle: http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle
Activity's onResume() will be called every time the activity is brought to foreground but that happens also when launching it for the first time. If you are looking for a method that is called only when the focus regained, try onRestart().
|
88715fae738d5cf5157c63aa2600dcd717e58f50fc184ba3f5c9a0f3120eaea0 | ['df7b54d04cf4414eb9bf2006aef99ac4'] | I have created a python dictionary for expanding acronyms. For example, the dictionary has the following entry:
Acronym_dict = {
"cont":"continued"
}
The code for the dictionary lookup is as follows:
def code_dictionary(text, dict1=Acronym_dict):
for word in text.split():
for key in Acronym_dict:
if key in text:
text = text.replace(key, Acronym_dict[key],1)
return text
The problem is that the code is replacing every string that contains substring 'cont' with continued. For example, continental is getting replaced by 'continuedinental' by the dictionary. This is something that I don't want. I know I can add space before and after each key in the dictionary but that will be time-consuming as the dictionary is quite long. Any other alternative?? Please suggest.
| 978b051cb606237bcb1fb75cab8f93d4750549a43f7d2938812606a07ab533b4 | ['df7b54d04cf4414eb9bf2006aef99ac4'] | I am trying to use BERT for translating non-English text to English. Till now, code I am using is as follows -
from pytorch_pretrained_bert.file_utils import
PYTORCH_PRETRAINED_BERT_CACHE, WEIGHTS_NAME, CONFIG_NAME
from pytorch_pretrained_bert.modeling import BertForSequenceClassification,
BertConfig
from pytorch_pretrained_bert.tokenization import BertTokenizer
from pytorch_pretrained_bert.optimization import <PERSON>,
WarmupLinearSchedule
tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-uncased')
text = "La Banque Nationale du Canada fête cette année le 110e anniversaire
de son bureau de Paris."
marked_text = "[CLS] " + text + " [SEP]"
tokenized_text = tokenizer.tokenize(marked_text)
token_no=[]
for token in tokenized_text:
#print(tokenizer.vocab[token])
token_no.append(tokenizer.vocab[token])
# The below code obtains the tokens from the index
new_token_list=[]
for i in token_no:
new_token_list.append(list(tokenizer.vocab.keys())[i])
print(new_token_list);
After this, I am confused about how to obtain English Translation of the text? Am I going right?
|
c087ef9601c85601402880862473af230d957458675e41f0d405b135f41c9a63 | ['df8104ba57644754a5d2c02ed5768491'] | We have an application built in Python which has to run on different databases, e.g. SQLServer, MySQL and Postgres. When we do inserts into SQL Server using the pyodbc library this is much slower (20 times!) than when doing the same inserts into Postgres using psycopg2 or into MySQL using mysql.connector. I have two questions:
1. What could be the reason of this difference in performance?
2. What could we do (apart from using Postgres/MySQL) ?
| 638ce5f69bcbbf009902ea02d8bf55394bb46151c83c6d6e40dae84a9f1c3cbe | ['df8104ba57644754a5d2c02ed5768491'] | I'm using Python 3.6 and I have this code:
text = "ç"
print(text)
When I execute is there's no problem. When I generate an executable using pyinstaller the program executes just fine. However, when I execute the generated application the program crashes when executing. How can I prevent this?
|
f95a5ef4f760f6b05d353ea41cc20c0e20181a6b32a85f26265596dc043f3ece | ['df88c503afe24c49bf40834ae83b6654'] | Google blocks AdSense requests if they feel the site may have misleading or fraud content or anything that isn't complying with their rules.
If you already have good track in case of traffic and genuine content. They will accept you.
Trademarks won't be a problem with verification. Just a problem if the company thinks they should warn you.
| d29e767de681bf028c1537f112f128af5bcd75a53851666602e0a3a28d0f9505 | ['df88c503afe24c49bf40834ae83b6654'] | The Data that are displayed in the search results are based on Structured Data and you can learn more about it from the link below.
https://developers.google.com/search/docs/guides/intro-structured-data
If you are having a WordPress site, you can attain many of the features you want using the Yoast SEO plugin which can be downloaded from the official WordPress plugin store for free.
Let me know if my suggestions helped you.
|
0bac94568df481e3b2004846680d1bbdc64cf1d7481a0e39cfa37d12f9263aab | ['df8906202ea5418493d855a327e1166d'] | I just tried that and it worked fine. I checked the permissions and used *openssl s_server* under the *freerad* user and that worked. I tried putting a bad filename in the config and it didn't run, so I'm thinking the client cert. Not sure where to go from here | 0ff0081c3b027f973fc1918861c9980264929383632bb5d58318963f39f1c335 | ['df8906202ea5418493d855a327e1166d'] | Found the fix here: http://blogs.msdn.com/b/selvar/archive/2012/07/14/reporting-services-unexpectedly-loads-net-framework-4-0-by-default-and-fails-with-http-500-19-while-browsing-report-server-and-report-manager-url.aspx
Turns out that the registry key HKLM\SOFTWARE\Microsoft\.NETFramework\OnlyUseLatestCLR was set to 1. No idea how it got there. Once we changed it, everything worked again.
|
7646b5f29fe9467fac84c0aa03536dacc0456b2af1d17879bea798642295125c | ['df8fd59ab40a4e49ad6f23e52095a9e3'] | I just finished reading it for the 2nd time, and i have to say this is an absolute gem! I understood everything, such a nice feeling!! I finally grasped what is meant by partial trace, and if im not mistaken it s exactly analogous when one "integrates out" degrees of freedom in stat. mech, e.g. when we want the distribution function of a subspace of particles, so we write $f^{(n)} =\int f^{(N)} dr^{N-n}dp^{N-n}$ meaning the probability that the particles of subspace n are in volume $dr^ndp^n$ regardless of the state of the N-n ones, right? | bb955a0e80865fe39ece151d4348744b6e13d77fdfbf865b99b431639bb22574 | ['df8fd59ab40a4e49ad6f23e52095a9e3'] | @WetSavannaAnimalakaRodVance ... But why is it that even in this case, the superposition depends on the path lengths? Even a simpler scenario: lets just put two detectors at the end of each path after the BS (no mirrors). With a single photon, after the BS we have a superposition of transmission and reflection paths, but how can we explain that the amplitudes in this superposition depend on the path length? (i.e., if I change the lengths, I change the likelihood of the photon being detected at one detector with respect to the other). Really hard to grasp... |
39e3947817cb337c9134c9974dd70b85ec3e50491dd63867924524b65c80dbc1 | ['dfa630d063264eb3b203171e8cc8fe2f'] | I'm trying to let the code create a data file for my marzipano project, it uses this data.js and I don't want to create every link for each project so I tried to loop it but it doesnt print it into my html page. I want to print it as a text so I can copy and paste the result in my js file, is there a way to fix my code or a better way to do it?
P.S: I'm a total noob with javascript
Thank you in advance
function auto(number){
i = 0;
while (i < number) {
//Fist Scene
if(i === 0){
document.write('
<p>
{
"id": "0",
"name": "0",
"levels": [
{
"tileSize": 256,
"size": 256,
"fallbackOnly": true
},
{
"tileSize": 512,
"size": 512
},
{
"tileSize": 512,
"size": 1024
},
{
"tileSize": 512,
"size": 2048
}
],
"faceSize": 2000,
"initialViewParameters": {
"yaw": -3.<PHONE_NUMBER>,
"pitch": 0.06648956035942888,
"fov": 1.5707963267948966
},
"linkHotspots": [
{
"yaw": -3.128953846954726,
"pitch": 0.47317799909128944,
"rotation": 0,
"target": "1"
}
],
"infoHotspots": []
},</p>
')
}
//Last Scene
else if (i === number){
document.write('
<p>
{
"id": "'i'",
"name": "'i'",
"levels": [
{
"tileSize": 256,
"size": 256,
"fallbackOnly": true
},
{
"tileSize": 512,
"size": 512
},
{
"tileSize": 512,
"size": 1024
},
{
"tileSize": 512,
"size": 2048
}
],
"faceSize": 2000,
"initialViewParameters": {
"yaw": -3.1332154632455715,
"pitch": 0.062442602034723294,
"fov": 1.5707963267948966
},
"linkHotspots": [
{
"yaw": 0.008275683165861025,
"pitch": 0.3876084470351344,
"rotation": 0,
"target": "'i-1'"
}
],
"infoHotspots": []
}</p>'
)
}
//Actual loop
else if (i < number){
document.write('
{
"id": "i",
"name": "i",
"levels": [
{
"tileSize": 256,
"size": 256,
"fallbackOnly": true
},
{
"tileSize": 512,
"size": 512
},
{
"tileSize": 512,
"size": 1024
},
{
"tileSize": 512,
"size": 2048
}
],
"faceSize": 2000,
"initialViewParameters": {
"yaw": -3.<PHONE_NUMBER>,
"pitch": 0.<PHONE_NUMBER>,
"fov": 1.5707963267948966
},
"linkHotspots": [
{
"yaw": 0.007751782217697567,
"pitch": 0.39202518148107757,
"rotation": 0,
"target": "'i-1'"
},
{
"yaw": -3.1285088198075375,
"pitch": 0.48530966110218543,
"rotation": 0,
"target": "'i+1'"
}
],
"infoHotspots": []
},<br>
')
}
}
}
}
auto(13);
<html>
<head>
</head>
<body>
<script src="auto.js"></script>
</body>
</html>
| 857a574a83f36c7a8710d5ed7fc52e510ddf0bac199109097be7b61f8a079955 | ['dfa630d063264eb3b203171e8cc8fe2f'] | I have a web app inside a QWebView in a python code, this html/javascript code have a button with a click event, I would like to get that event once is triggered so it can be used for an aplicacion outside the QWebView.
tl;dr: is there a way to capture a javascript's click event to be used in the python code?
|
10154fe9aa14764d61cbea3088655bd26228b1907580c4a0dda5f89b196f9ada | ['dfb78fe1202644f9b2207431dd81e3b8'] | There are no laws specifically against Nazi symbols or Nazi paraphenalia (clothing, medals, etc.) in the United States, and there are NO laws against religious symbols, even if they are swastikas. Airport authorities will not give you any trouble, and if a police officer or customs officer asks, simply inform them it is a religious symbol.
That said, many places, like university campuses or workplaces, have regulations or policies against 'offending people', so people who don't understand that the swastika is an ancient religious symbol used in many cultures might complain and make trouble for you. In that case, prove your swastikas are religious with a quick internet search on your phone, demand that they respect your right to religious freedom, and then accuse them of racism if they don't stop bothering you. They have NO RIGHT to bother you because of your religion.
If you look like a person from India, and your swastika looks Eastern and not Nazi, I doubt people will bother you unless you are somewhere extremists congregate, like university campuses. If people try to pressure you into not wearing your religious symbols, it could be a violation of your civil rights.
| 863d2af521144fc2c4002e039f3e940c041e1875b2016d7742aaf2d2ffa2c2f6 | ['dfb78fe1202644f9b2207431dd81e3b8'] | It sounds as though the issue resides in the LTE bands supported by the device. If the iPhone is model A1533 it will not support LTE bands: 6 and 9. A1533 is the model of most American unlocked devices. On Apple's LTE site it gives a list of each unlocked device, and the supported bands that has been organized geographically. iPhone 5S model A1453 is the correct model.
|
e0a62e930c4a5ca60bd900dd36b5cd9e00cd28f91a3b81b1195e4cf4a3257919 | ['dfd351d7b55c4180b5d28768d0b09bee'] | Currently, to add content, you have to click on "Click Here to Add Content" but since it's a required field (and I think this is sort of unsightly), I'd like to automatically have a WYSIWYG editor in that section already. Even after you click, the content editor is small and I'd like it larger.
See images below.
What I'm looking to do is something like the following for content (side note: I also would like to add a Browse for Attachments button):
Any direction would be helpful. Thanks.
| b3b4b1e61a4820ec8167857cb886688a34f8870d0d71dcf18de5c1ff67cbb389 | ['dfd351d7b55c4180b5d28768d0b09bee'] | tengo múltiples campos de selección en el formulario, estos campos se agregan de forma dinámica, pueden haber desde 2 hasta 4, lo que busco es un método para validar todos los campos select por medio de jquery, por el momento tengo un código que si bien funciona al detectar los campos vacíos, el demás código me sigue ejecutando y lo que quiero es que el código pare hasta que todos campos estén validados. Muchas gracias por la ayuda.
$('.slt_d').change(function(e){
$('.slt_d').find("option:selected").each(function(){
if ($(this).val().trim() == '') {
alert('falta un campo');
}
})
//debe ejecutarse <PERSON> si todos los campos estan completos;
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="slt_d">
<option value="">Seleccione un dato</option>
<option value="1">Dato 1</option>
<option value="2">Dato 2</option>
</select>
<select class="slt_d">
<option value="">Seleccione un dato</option>
<option value="a">Dato A</option>
<option value="b">Dato B</option>
</select>
//demas select
|
ce1db6baf10ecd4824f71376fe2751fd56d49e3d174a8e39db1216c9697d4d4a | ['dfeae460c95f474d8fd913a7d9167ab4'] | Being security conscious, I want to audit the use of admin rights. I would like to assign specific permissions to a user (following the concept of least privilege) that current has the SysAdmin role and I want to know what rights they are using above DBO to the database. Is there a good way to audit these actions so that I can grant those specific rights?
| a7b3ccd5da71d8b253adaec1e63c7920f7976d4cb5a91228ff650195450c2b15 | ['dfeae460c95f474d8fd913a7d9167ab4'] | I have Fedora 18 installed as the OS in my machine. I created a user called myworld. I installed the MapFish virtual environment and created a MapFish application. Now I tried to run that application using wsgi on httpd(Apache) server. I configured the python_egg_cache file to /var/www/html/python-eggs. When I launch the application it throws following error:
ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg cache:
Permission denied: '/var/www/html/python-eggs/psycopg2-2.0.12-py2.7-linux-i686.egg-tmp'
The Python egg cache directory is currently set to: /var/www/html/python-eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
I have browsed so many sites with the same issue. Unfortunately none of the solutions have resolved my issue.
later I have given full permissions(777) to that folder and still not resolved the issue.
Could any please help me in resolving the issue.
|
3fc67a2578720b617f7c38c2a23a75c75f0f73a9ad41a273b171d7e19f690e32 | ['dfeeffba840842b8bd273b9e9d0c4c2d'] | Получение такой ошибки может быть связано с тем, что нет необходимых разрешений.
Для того, чтобы их получить необходимо сделать следующее:
Нажать ПКМ по пункту реестра, для которого надо получить разрешения.
В появившемся окне нажать Дополнительно.
Далее Владелец, выделяем Администраторов, Заменить владельца... и соглашаемся.
В первом окне ставим флажки для Администраторов, соглашаемся.
После того, как все изменения в реестре будут сделаны, необходимо вернуть системе её права:
В окне Дополнительные параметры... нажимаем на Другие пользователи или группы..., записываем систему.
Соглашаемся, также ставим флажок на Заменить владельца, и убираем флажки у Администраторов.
P.S. Все изменения с реестром вы делаете на свой страх и риск!!!
| f54a93820f94262a1115cc3ead7c4bcc7bdb4e38055330b49e71d64aa7563928 | ['dfeeffba840842b8bd273b9e9d0c4c2d'] | Я думаю, что для генетического алгоритма достаточно создать нейросети с нейронами, отвечающими за передвижение, стрельбу, поворот. Мне кажется, что ботам в начале достаточно просто передвигаться и при встрече с противником убивать. Потом в течение нескольких игр выбрать лучшие нейросети и скрестить их.
Выбор оружия можно сделать, присвоив каждому оружию число в порядке возрастания (от самого слабого оружия до самого мощного). И если бот имеет оружие более слабое чем у убитого им противника, то меняет его, или если деньги позволяют, то можно купить более сильное оружие.
|
98b095ba0e856cc2a5ba9bcaa23336be2db37e10cc35ec3e8786c1ab67770696 | ['dff8da012e9a41b4a2c0bf9be56a0a15'] | I'm new to java patterns and I'm trying to figure out how it fits in to the REAL WORLD.
Most sites and books on patterns seems to be written by non-programmers.
I'm trying to define how patterns help with coupling, and this is my definition so far. What I would like to know is what patterns are really useful for loose coupling, and are they worth the effort. Also, is my definition/understanding correct so far:
"Coupling is the degree, two or more different objects, accesses and/or interacts with each other."
Tight coupling between two objects:
Referencing/Instantiation : Many reverence to the other object, in
many places, in one or both objects (many to many references)
Complexity : Usually many parameters required accessing functions, or
the sequence of accessing different functions. No common interface
for related objects.
Responsibility : Doing work that should rather be done in the object
being accessed, or another object. Accessing nested functions
directly.
Performance : Biggest reason why tight coupling is sometimes
required, but should be minimized.
Loose coupling between two objects:
Referencing/Instantiation : Few, but at least one reference in one
object but not in both (one to few references)
Patterns that help : Factory, Singleton, Builder, Composite
Complexity : Few, well defined parameters (usually defined by an
interface), with least possible sequence of functions (exp. open,
fetch, close)
Patterns that help : Adaptor, Bridge, Decorator, Facade, Command
Responsibility : Only do work the object is responsible for doing and
try to only access functions one level down.
Patterns that help : Decorator, Chain of Responsibility, MVC
Performance : Identify where performance needs to be, and keep those
classes together - maybe even as nested classes, per definition
tightly coupled.
| aa12cf7e65b043d4c202401b3df266d7d4e516922176d56bc25f7e146291f94d | ['dff8da012e9a41b4a2c0bf9be56a0a15'] | I had same problem, turned out to be a proxy problem. Gradle does not see your proxy setting and you have to add them manually to the gradle.properties file in the project.
It then donwloads all relevant jar files when you build the project.
Used this page setup : http://www.gradle.org/docs/current/userguide/build_environment.html
|
300c66e1cb0936b1f085edec78f349111f66c5552c60321ca328abf26a0ee5b3 | ['e00146e170fd4361a1c0e0543b544149'] | There is no solution to this problem. If you kill process with task manager, it does not receive termination notification, and hence can not remove its icon from the tray. Try avoiding killing process this way. You can use net start/stop to kill a service or services.msc GUI.
| c2923d511153867f1650a536d5507a703db700b73c856f5da7bb896471659d92 | ['e00146e170fd4361a1c0e0543b544149'] | You can't do it without RTTI or some kind of map. Or a solution like this:
class Foo {
public:
void run( string method ) {
bar(method);
foo2(method);
// ... more methods here
}
void bar(string method) {
if (method != "bar") return;
printf( "Function bar\n" );
}
void foo2(string method) {
if (method != "foo2") return;
printf( "Function foo2\n" );
}
}
Foo foo;
int main( void ) {
foo.run( 'bar' );
foo.run( 'foo2' );
}
this will give you the same result you wanted
|
6ba29f22443fe8c3ca2e4efff0979b26f52ca50b6c4eed9682a2cf2aece256a7 | ['e009f565d0ed4786a82a45299c842312'] | I want to describe a process that, although not industrial, behaves closely to industrial processes. I have an hesitation between a description with "industrial-like process" or "industry-like process". The wording is not pretty, other options are welcome. Yet, I would like to better understand the "-like" construction.
The first form was already used by a fellow non-native English speaker. I do prefer the second form, since words in -like I know of (like businesslike, porcelainlike) are based on the substantive. As I understand it, the suffix "like" may turns a substantive into an adjectival form, either as a compound adjective (with hyphen) or closed.
So, "industrial-like" seems to me an adjectival redundancy.
Is there a better different choice?
If not, should I use "industrial-like" or "industry-like"?
Could you point to sources on how to build words in .like or .-like, and a rationale in the presence of the hyphen?
| dbf45240418bb4d71bb9a1c5623793dfba2fbbd818faac9d21b155ca04fa1c95 | ['e009f565d0ed4786a82a45299c842312'] | The given example is not a sequence per se, considering that the "digits" are not separated (by a comma, space).
A natural number whose digits are repeating in some positional number system is called, in recreational mathematics, a repdigit. This comes from repeated and digit. In the case it is composed of digit 1 (1, 11, 111, 11111), it is called a repunit. The latter was coined by <PERSON> in 1966. See Repunit and Repdigit Numbers for other details.
Otherwise, this would just be a constant sequence:
Constant sequences are sequences for which all terms are the same.
|
ab575dd9f768793426f4ff7da3a884b3dbb2d1812e4278cdeab2adaec25066e9 | ['e01279fa05b2432e8806d7fb6462287d'] | I am using a TextArea in my project along with jQuery autocomplete.
HTML CODE:
<textarea class='autoExpand' rows='5' data-min-rows='5' id='textarea'></textarea>
I have the javascript code to handle drop-down by using jQuery autocomplete. I can easily change the style of the TextArea itself:
textarea{
font-family: "Helvetica", Times, serif;
display: block;
background-color: #fffdb5;
resize: none;
}
However, I can't figure out how to CSS style the drop-down menu.
I need to be able to change the background of the drop-down as well as the colour of the text and selected item background.
To illustrate, this is what I am referring to:
| b9265426ef60b22162b41667504b7551e1f952c7f3b6ea09f01db018aa0bc285 | ['e01279fa05b2432e8806d7fb6462287d'] | I am using Keyboard global hook library in Python (https://github.com/boppreh/keyboard) to simulate key pressing in other applications (during text entry I am replacing accents on words).
Everything works fine for simple combinations such as 'ctrl+c' or 'ctrl+v', but I also need to simulate a bit more complex combinations, most importantly 'ctrl+shift+left', which is essentially a 'ctrl+shift and left arrow key' on the keyboard (to highlight the last word in text).
Does anyone know how to do this in Python using above library? Or even without the library?
Currently I do something like this, to first press ctrl+shift, keep it pressed, then pass left arrow key and then release ctrl+shift:
keyboard.press_and_release('ctrl+shift', True, False)
keyboard.press_and_release('left', True, True)
keyboard.press_and_release('ctrl+shift', False, True)
But for some reason this doesn't work, it doesn't highlight the last word in text.
Same as this, which also doesn't work:
keyboard.press('ctrl+shift+left')
Nor this:
keyboard.send('ctrl+shift+left', True, False)
keyboard.send('ctrl+shift+left', False, True)
Any ideas how to get this working?
|
cdee9c683851b3f0e57155d2518abd020c66e32001d2268e1155a7240ce38a36 | ['e016c587a100490b8b4154a52fa38b8b'] | I have a folder containing images of JPEG format , what I would like to do is to read the size of each image and save it in 2 variables using bash.
Height
Width
The thing is when I use this code
for dir in /opt/ADL_db/Users/mkhalil/OpenCV/positive/*; do
OUTPUT="$(identify "$dir"/*.{jpg,png,jpeg)}"
my_val1=$(echo $a3 | awk -F'x' '{print $1}')
my_val2=$(echo $a3 | awk -F'x' '{print $2}')
I don't loop over all the images in the folder !
| 016da34a0dad600d1ddec74dd73bb9abb035ddcf898682b346cf4608fab0a183 | ['e016c587a100490b8b4154a52fa38b8b'] | I have this xml file
</license>
<parameters pca-dim="32"/>
<parameters resize_minpix="100000" npix="100000" ptch="24" step="4" nscale="5" maxscale="4"/>
<parameters notify-classes-removed="1"/>
<parameters grid-regions="1x1,1x3"/>
<feature_extractions>
<feature_extraction id="orh" params="8,4:0.7,0.5:0.4,0.6:0.01"/>
<feature_extraction id="col" params="4:mv:0.4,0.6:0.01"/>
</feature_extractions>
<vocabulary rebuild="IfDoesNotExist" gmm-iter="8" sig-norm-type="l2" sig-norm-pow="0.5"/>
<classifier type="sgd" lambda="1.0E-5" max-iterations="20"/>
<validation name="V1CrossValidation" folds="5" mode="fast" method="modulo" result-file="/opt/ADL_db/Users/mkhalil/CshellTest/ScriptTests/temp/V1CrossValidation-results.stats" score-flags="combine,normalize"/>
I would like to use sed command to change folds="5" to folds="6"
|
757e29aff09cd3413633a287131dd4db275f91ac06ba896faccd556baaa71bf0 | ['e01aa232cb6d418c82ae0456dbe5601c'] | With the tap plugin installed I was able to get my declarative pipeline script to display test results from tap files with the following command:
stage('publish test results') {
steps {
step([$class: "TapPublisher", testResults: "**/reports/*.tap"])
}
}
How do i use the "Publish TAP Results" plugin on Jenkins 2.0 Pipeline?
| c1a85cdcff223498487009f57bdb7a818581c0baaeb9a5f0713011a259d7a422 | ['e01aa232cb6d418c82ae0456dbe5601c'] | Looks like there are two options for linting pipeline scripts, one via the cli on the leader or an http POST call:
Linting via the CLI with SSH
# ssh (Jenkins CLI)
# JENKINS_SSHD_PORT=[sshd port on master]
# JENKINS_HOSTNAME=[Jenkins master hostname]
ssh -p $JENKINS_SSHD_PORT $JENKINS_HOSTNAME declarative-linter < Jenkinsfile
Linting via HTTP POST using curl
# curl (REST API)
# Assuming "anonymous read access" has been enabled on your Jenkins instance.
# JENKINS_URL=[root URL of Jenkins master]
# JENKINS_CRUMB is needed if your Jenkins master has CRSF protection enabled as it should
JENKINS_CRUMB=`curl "$JENKINS_URL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)"`
curl -X POST -H $JENKINS_CRUMB -F "jenkinsfile=<Jenkinsfile" $JENKINS_URL/pipeline-model-converter/validate
https://jenkins.io/doc/book/pipeline/development/#linter
|
53070772273343ef8c3fec379e0e95101a64576de7ee678a882879427914596c | ['e01b7cc3b4d344c8b3bd18e78c89e909'] | I faced the same confusion a while ago and upon digging down to the issue I learnt that all the data which gets loaded in the 'Data' tab of Firestore page does count towards the overall Firestore usage.
However, I was concerned with the same question as yours thus I contacted Firebase support. They reverted back confirming the first instinct of mine(Document reads in 'Data' tab does count) BUT initially it reads only the first 300 documents of ANY selected collection, so even if your collection has over 1 million docs, it will still load only the first 300 documents.
They suggested a way around it until the Firebase team finds a legit solution
Bookmarking the Usage tab of the Firestore page. (So you basically 'Skip' the Data Tab and the useless 300 reads)
Adding a dummy collection in a certain way that ensures it is the first collection(alphabetically) which gets loaded by default on the Firestore page.
| a40f230c3cf624554bcc7e9502f3da75ffa0d4d9f9ba17b3ee0a2cbed3bbb310 | ['e01b7cc3b4d344c8b3bd18e78c89e909'] | There are two ways to fetch data from firebase realtime database.
Either you can set a listener, which will automatically sync the data whenever there is a change in the database or you can do one time fetch
in your particular case (to fetch it one time)
you can do
const linesRef = firebase.database().ref("/lines");
linesRef.once("value")
.then(response => console.log(response.val()));
|
c862077af248ee1aa9ce60e3dbbf38e3f20cc3195fc9911e52d90e176ddc2627 | ['e01d522d14ef4c31be96eba6ebefda7c'] | Crazy stackexchange rules mean I need to put extra citations here:
[2] http://menehune.opt.wfu.edu/Kokua/Irix_6.5.21_doc_cd/usr/share/Insight/library/SGI_bookshelves/SGI_Developer/books/XLib_WinSys/sgi_html/ch12.html
[3] http://www.qnx.com/developers/docs/6.5.0_sp1/index.jsp?topic=%2Fcom.qnx.doc.photon_prog_guide%2Fgeometry.html
[4] http://www.drdobbs.com/motif-geometry-management/184409755 | 1c6f1ca1c257f0c5394414e5791093f8cfd5a652d93a832d9b4566203be60c6e | ['e01d522d14ef4c31be96eba6ebefda7c'] | Your third example shows `22048` should output `good` but thats not true. You cant combine `2` with `2048` and the grid is `4x4` if all numbers should be seperate you'll get 5 cells. so maybe you should remove the `0`? Also your 5th example seems to be invalid since the game stops at `2048` :) |
830ed55202e0b7157094372d2c4e93ad2d62864fd0fa531a6715cbd35bb79655 | ['e02ef2addd324a31b7f49ee1f0a96221'] | I have a seemingly innocuous problem that I can't seem to wrap my head around. The following is mentioned in passing on one of my lecture slides, but when I try to arrive at the same conclusion I get stuck.
Consider N independent draws from a uniform distribution over [0, 1]. On average, what is the highest draw? I know that the answer is:
$$ \frac{N}{N+1} $$
but I can't arrive there myself. Honestly, I'm not even sure how to start. Can someone sketch a procedure or show me exactly what needs to be done? Thanks!
| 2e559cce87f5e367475f1f02176d6ea07cb2444559e9548c4abc808ae4c6ca31 | ['e02ef2addd324a31b7f49ee1f0a96221'] | How much do you guys get in revenue from ads each month, and could some users simply pay you to cover the cost and not have to deal with the ads at all? I'd gladly pay rather than deal with ads of any sort anywhere, although of course SE ads are nothing compared to most of the rest of the internet :( |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.