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 |
|---|---|---|---|---|---|
078ee6dff2afd6dc643cb25ee7dba9659e2ed110e657f3deafc57e5126fbb912 | ['bd909313ccfb44eb9c54f87ac14d0155'] | I try to use gcsfuse in order to store application source code on a GCP bucket, here's my Dockerfile:
ARG VERSION
FROM golang:1.12.5-alpine3.9 as gcsfuse-builder
ENV GOPATH /go
RUN apk --update add git=2.20.1-r0 fuse=2.9.8-r2 fuse-dev=2.9.8-r2 \
&& go get -u github.com/googlecloudplatform/gcsfuse
FROM php:$VERSION as base
ARG REVISION
ENV APP_DIR=/srv/app \
APP_ENV=prod \
APP_FRONT_CONTROLLER=index.php \
APP_LOCALE=fr \
APP_USER=test-user \
APP_USER_GROUP=test \
APP_PORT=8080 \
COMPOSER_ALLOW_SUPERUSER=1 \
NGINX_DIR=/etc/nginx \
NGINX_VERSION=1.14.2-r1 \
PHP_FPM_CONF_DIR=/usr/local/etc/php-fpm.d/ \
SUPERVISORD_CONF_DIR=/etc/supervisor \
SUPERVISOR_VERSION=3.3.4-r1 \
BUILD_SCRIPTS_DIR=/build-scripts \
GOOGLE_APPLICATION_CREDENTIALS=/srv/app/bucket.json
# Supervisord conf to be copied at the end.
COPY docker/prod/php/scripts/*.sh $BUILD_SCRIPTS_DIR/
# Core dependencies installation (installed as a virtual package in order to remove it later)
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& apk add --no-cache --virtual .fuse-deps curl sshfs fuse \
&& apk add --no-cache --virtual .bash bash=4.4.19-r1 \
&& apk add --no-cache --virtual .core-php-deps icu-dev=62.1-r0 \
&& rm -rf /var/cache/apk/* \
&& docker-php-ext-install \
intl \
opcache \
&& docker-php-ext-configure intl \
&& docker-php-ext-enable opcache \
&& apk del .build-deps .phpize-deps-configure
# User creation
RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted --virtual .user-deps gosu=1.10-r0 \
&& rm -rf /var/cache/apk/* \
&& addgroup $APP_USER_GROUP \
&& adduser -D -h /home/portfolio -s /bin/bash -G $APP_USER_GROUP $APP_USER \
&& chown -R $APP_USER $BUILD_SCRIPTS_DIR \
&& apk del .user-deps
# Nginx & Supervisor installation
RUN apk add --no-cache --virtual .http-deps nginx=$NGINX_VERSION supervisor=$SUPERVISOR_VERSION \
&& rm -rf /var/cache/apk/* \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
# Filesystem (gcsfuse)
COPY --from=gcsfuse-builder /go/bin/gcsfuse /usr/local/bin
COPY bucket.json $APP_DIR/bucket.json
# Filesystem (gcsfuse binding)
RUN apk add --no-cache --virtual .filesystem-deps curl fuse fuse-dev rsync \
&& mkdir -p $APP_DIR $BUILD_SCRIPTS_DIR \
&& chown -R $APP_USER $APP_DIR \
&& chmod -R 755 $APP_DIR \
&& gcsfuse mybucketname $APP_DIR
COPY docker/prod/php/conf/php.ini $PHP_INI_DIR/php.ini
COPY docker/prod/php/conf/fpm.conf $PHP_FPM_CONF_DIR/fpm.conf
COPY docker/prod/nginx/conf/nginx.conf $NGINX_DIR/nginx.conf
COPY docker/prod/supervisord/supervisord.conf $SUPERVISORD_CONF_DIR/supervisord.conf
# Used to check that PHP-FPM works
HEALTHCHECK --interval=5s --timeout=3s \
CMD curl -f http://localhost/ping || exit 1
# Production build
FROM base as production
COPY docker/prod/nginx/conf/test.conf $NGINX_DIR/conf.d/test.conf
WORKDIR $APP_DIR
COPY . .
# The vendors are installed after the whole project is copied, this way, we can dump the autoload properly.
# The unrequired directories are also removed.
RUN /bin/bash "$BUILD_SCRIPTS_DIR/install_composer.sh" \
&& /bin/bash "$BUILD_SCRIPTS_DIR/composer_dependencies.sh" \
&& rm -rf $BUILD_SCRIPTS_DIR \
/usr/bin/git* \
/lib/apk/db/installed \
/usr/local/bin/composer \
node_modules/
EXPOSE $APP_PORT 443
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
The image can be built without gcsfuse but when the build use:
gcsfuse mybucketname $APP_DIR
Here's the error that I encounter:
fusermount: fuse device not found, try 'modprobe fuse' first
Is there any workaround to get it working during docker build?
Thanks for the support
| 62cda2065ec8a39d9ebf9541b3370ae09662a93bb6226271cbe1e3de81050388 | ['bd909313ccfb44eb9c54f87ac14d0155'] | For Postal Code, I find that the data from onemap.sg is pretty accurate. However for some postal code, there will be more than one result. This is because there might be multiple listing of the same postal code within the same building. Nevertheless, it is still accurate.
For simplicity, I would recommend looking at this github repo on the usage of the api.
The key fields to look at will be Address, Building, SearchVal.
|
06529d1232d9ef61958db03cacfe36e32e7338f5ab20088a6fedf6490d988ca5 | ['bd90954d247d4db492dd9fd7cc4e35fd'] | I made a 2D project with a lot of tile sprites, and one player sprite. I'm trying to get the camera to follow the player, and for the most part it's working. However, there's one problem:
If you go to the edge of the map, it scrolls normally, but instead of the black background, it displays copies of the sprites on the edge of the map instead of the background (black). It has the same problem if I leave some squares empty, when I move it displays a copy of the tile that was previously there.
The camera works like this:
Select sprites that should be visible
Do sprite.visible = 1 for them, and sprite.visible = 0 for all other sprites
Set the position sprite.rect of all sprites to coords - offset
Update the screen (I use flip(), because the camera moves every turn, so the whole screen has to be updated every turn)
All DirtySprites have dirty = 2.
Does anyone know why it's displaying copies of the sprites on the edge instead of the background?
Help would be appreciated!
| 72a332e28babb23404d209aec9b6ccfa71e832d5eab4e445dfe6c990ba2d8d78 | ['bd90954d247d4db492dd9fd7cc4e35fd'] | How can one use code in a LiveScript file from another LS file? For example:
# In script-one.ls
foo = 5
# In script-two.ls
bar = -> foo + 3
Simply including both files in the HTML via script tags does not seem to work. Changing the first script to export foo = 5 and using require! './script-one' (or variants) in the second script doesn't work either.
And what about circular dependencies?
|
25209a810de1feb27a4926647b164fc2d50b2e719b5627f79395b868f17952f4 | ['bd928956e8844c869e26823f3618e7bc'] | If you refer to the source for the quotation above, I'm sure the user http://superuser.com/users/93284/greg posted it originally here: http://superuser.com/questions/20386/audio-line-in-on-ubuntu-linux-mint. I just thought it could be of value to relate to this post. | d8b7ee7706630f204d669535b497ae864babb15181ebbbe521edf86a92eac8cd | ['bd928956e8844c869e26823f3618e7bc'] | It's hard to tell where most time is spent especially not knowing well the framework. I believe most time is spent in `amp.amaps.FCLS(var_y, EM_mat)` but it's an educated guess at best. Running the code under a profiler, such as cProfile, is probably the way to go here. Nothing obvious to me concerning performance improvement, anyway. |
6088f17519ad0e709aff24acb685afb94892bae8b63c47625039f9f058b47211 | ['bd9d5e8544f04f98a89a2a654fa0e43e'] | I found a solution for this.
I have defined a function like this-
def Vectorize(text):
try:
count_vect.fit_transform([text])
return count_vect.vocabulary_
except:
return-1
and applied above function-
from sklearn.feature_extraction.text import CountVectorizer
count_vect = CountVectorizer()
products['word_count'] = products['review_without_punctuation'].apply(Vectorize)
This solution worked and I got vocabulary in new column.
| 0056dbe8e80402a1ad34ad761deec3370ef2d46cd93eb3c098951af8c5887efb | ['bd9d5e8544f04f98a89a2a654fa0e43e'] | I have dataframe column 'review' with content like 'Food was Awesome' and I want a new column which counts the number of repetition of each word.
name The First Years Massaging Action Teether
review A favorite in our house!
rating 5
Name: 269, dtype: object
Expecting output like ['Food':1,'was':1,'Awesome':1]
I tried with for loop but its taking too long to execute
for row in range(products.shape[0]):
try:
count_vect.fit_transform([products['review_without_punctuation'][row]])
products['word_count'][row]=count_vect.vocabulary_
except:
print(row)
I would like to do it without for loop.
|
383fb95c3fc87722042e2aea972652285e8650b387d2d6d123b9a5a161b117c0 | ['bdde4c7bd4ce4a2b925e55045da13dde'] | I have been taking a closer look at HBCU 4 year institutions and am looking at their 6 and 8 year completion rates (C200_4 & C150_4). I have noticed that several of the 8 year completion rates are lower than the 6 year rates. Why would this be true? Shouldn't the 8 year completion rates always be higher?
| 68f358ad1f93088ce674cbc82509e64d433de5c71d86a89c2108b1533b29ee69 | ['bdde4c7bd4ce4a2b925e55045da13dde'] | Moreover after thinking things a little more through, I believe that as a matter of fact a binary random variable cannot be correlated to a logistic random variable over those thresholds. I don't have a full rigorous mathematical proof, only a heuristic argument which makes intuitively sense. I will post later my full answer. Best regards |
2b4619cc60ddd1a137be3c8b23034c0be04ba06988c572020373eb659ad0adee | ['bde07b0f0e084b0c87c5e0c9ccc7aded'] | I have date in string like 7 october 2019 but in polish
7 sierpnia 2019 and i would like to change it to date (Y-m-d)
I did:
$day = '7 sierpnia 2019';
setlocale( LC_TIME, array('pl_PL.UTF-8','pl_PL@euro', 'pl_PL', 'polish'));
$date = DateTime<IP_ADDRESS>createFromFormat( 'j F Y', $day);
echo $date->format( 'Y-m-d');
but i got this error:
Fatal error: Call to a member function format() on boolean
I need to insert it into DB in format Y-m-d.
| ca00bae545b8b2b47b01b8b40acec789a49814e295053087136ea1c1e53b5466 | ['bde07b0f0e084b0c87c5e0c9ccc7aded'] | I am trying upload xml file using simplexml_load_file but when in file is special character i'm getting an error ( There is everything alright without special character in it).
First of all, I am using XML file from another program so i can't change it.
This is sample of xml:
<wuo>
<header>
<title>title1</title>
</header>
<body>
<lp>1</lp>
<sign>124.455</sign>
<text>sample text with & character</text> //<-- this is causing the problem
</body>
<body>
<lp>2</lp>
<sign>12556.455</sign>
<text>sample text 2</text>
</body>
</wuo>
My code:
if(isset($_POST["submit"]))
{
if(isset($_FILES['wuo']) && ($_FILES['wuo']['error'] == UPLOAD_ERR_OK))
{
if(!simplexml_load_file($_FILES['wuo']['tmp_name']))
{
// if file has special character in it this fires up
echo 'Error';
}
else
$file = simplexml_load_file($_FILES['wuo']['tmp_name']);
print_r($file);
/**
showing file to html etc... unimportant code for this case
**/
}
else
echo 'Error:' . $_FILES['wuo']['error'];
}
I know, I should do something before simplexml_load_file but i don't know what exaclty. Or maybe I should use something else...
Btw: I don't need to secure it because this is only for me.
|
80fcadf3cb88a6e667f09ddd539274d0607baa2ba5040229a4f077debda7343f | ['bdf0f5e0a14a4330afb56858b5877d72'] | I agree with this list except for The Ellimist Chronicles - I usually read it directly before the start of the final arc (so book 49, if I recall correctly) as the books which tie up the story read more like one long book and reading TEC so near the end messes up the flow of the story for me.
| f19e85ba540d948761ffe6430cea231adea0a65197b451bd6115e59819d1eb82 | ['bdf0f5e0a14a4330afb56858b5877d72'] | Just as an example, taken from this site about two minutes ago: "From what I have seen, it is quite common for far more subtle and hidden negative messages to be put into an academic reference than what you have described. In these cases the references are not used because the letters are there to convey a warning." (https://academia.stackexchange.com/questions/96205/bad-reference-vs-no-reference) |
3608f398a39b3492ac71e34df1887256acf92a623cd0aa495358e413d5349d10 | ['be0ae92144c54f4e8cd3ba7c5b0a10b0'] | Try the following code. Multiple variables are not required for the validation of user input. I used an array to store all the errors.
<?php
if(isset($_GET['flag']) and isset($_GET['msg'])) {
if($_GET['flag'] == 1 ) {
echo "<span style='color: green'>$_GET[msg]</span>";
}
if($_GET['flag'] == 0) {
echo "<span style='color: red'>$_GET[msg]</span>";
}
}
?>
<form action="<?=$_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data">
<table>
<tr>
<td><input type="text" name="firstname" placeholder="First Name*"/></td>
</tr>
<tr>
<td><input type="text" name="lastname" placeholder="Last Name"/></td>
</tr>
<tr>
<td><input type="number" name="number" placeholder="Number"/></td>
</tr>
<tr>
<td><input type="email" name="email" placeholder="Email*"/></td>
</tr>
<tr>
<td><textarea name="remarks" placeholder="Remarks/Questions*" cols="30" rows="10"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Submit" name="btnSub"/> <input type="reset" value="Reset"/></td>
</tr>
</table>
</form>
<?php
if (isset($_POST['btnSub'])) {
$errors = array();
if (empty($_POST['firstname'])) {
$errors[] = 'Please enter your first name';
} else {
$firstname = $_POST['firstname'];
}
if (empty($_POST['lastname'])) {
$lastname = '';
} else {
$lastname = $_POST['lastname'];
}
if (empty($_POST['number'])) {
$number = '';
} else {
$number = $_POST['number'];
}
if (empty($_POST['email'])) {
$errors[] = 'Please enter your email address';
} else {
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errors[] = 'Invalid email address supplied';
} else {
$email = $_POST['email'];
}
}
if (empty($_POST['remarks'])) {
$errors[] = 'Please enter your remarks or question';
} else {
$remarks = $_POST['remarks'];
}
//Now check for the errors
if (!empty($errors)) {
$error = '';
foreach($errors as $err) {
$error .= $err.'<br>';
}
header("Location: $_SERVER[PHP_SELF]?flag=0&msg=$error");
exit;
}
$to = '<EMAIL_ADDRESS>';
$subject = 'Contact Form: domain.nl';
$body = 'test';
$headers = 'From: '.$email."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if(mail($to,$subject,$body,$headers)){
$success = 'Form is send';
header("Location: $_SERVER[PHP_SELF]?flag=1&msg=$success");
exit;
} else {
$error = 'Something goes wrong...';
header("Location: $_SERVER[PHP_SELF]?flag=0&msg=$error");
exit;
}
}
| 4d7450cd91f618d3b7e11f51a5ba55825a34dcb2caaffb1f9a058836e1cda7c1 | ['be0ae92144c54f4e8cd3ba7c5b0a10b0'] | I am working on an application which contains two different portals (admin and members).
http://localhost/app/ is used for the members login and http://localhost/app/admin is used for admin's login.
When I log in into members and admins portal both works fine but if I logout from one portal another portal logged out automatically.
I checked that the session file created in /tmp/ directory stores the sessions information for both the portals in a single file which causes the above problem. The work around I think is to save the session information of both portals in different directories. I searched a lot for this but didn't get any resolution :(
Please help. Thanks in advance!
|
225fdc66f03ac440be291328526eff3e4f45f598e8c99b828288b023daf1b4cd | ['be29408eaeab468fbe5cd308d2af95a4'] | I'm sorry but true anti-aliasing does not consist in getting the average color from the neighbours as commented above. This will undoubtfully soften the edges but it's not anti-aliasing but blurring. True anti-aliasing just cannot be done properly on a bitmap, since it has to be calculated at drawing time to tell which pixels and/or edges must be "softened" and which ones must not. For instance: imagine you draw an horizontal line which must be exactly 1 pixel thick (say "high") and must be placed exactly on an integer screen row coordinate. Obviously, you'll want it unsoftened, and proper anti-aliasing algorithm will do it, drawing your line as a perfect row of solid pixels surrounded by perfect background-coloured pixels, with no tone blending at all. But if you take this same line once it's been drawn (i.e. bitmap) and apply the average method, you'll get blurring above and below the line, resulting a 3 pixels thick horizontal line, which is not the goal. Of course, everything could be achieved through the right coding but from a very different and much more complex approach.
| fa423140271e1ffb1138ee8f308114f51f2da2f47e06eccb955d282f408fdf50 | ['be29408eaeab468fbe5cd308d2af95a4'] | I guess you finally solved your question (6 years have passed...), but I just wanted to say your application seems to work actually better than Photoshop in this particular case. Although I think I know what your aim was (avoiding those pixel clusterings), the "constant thickness" is better achieved with your App (despite those unwanted groupings), while Photoshop makes a "sausage rope" pattern which may be smarter, but no so width-constant and, thus, not so "real". It's likely due to a different handling of decimal values (rounding) and selecting which pixels to fill or skip. But again, this is an old topic.
|
cca614e5b9fbe2a77aa5e1e414f693cd2c8c83d78995ab754e502fbda1d6bb5d | ['be2ddd8a95eb4e5589be9199a6d8addf'] | My company is using a Parse backend for user accounts & I need to build out a password reset and other web based pages that will support our mobile apps. I've not done web dev like this in a while, so I'm wondering if anyone knows of a good tutorial?
I've found some that show me how to build out the whole system (users, password reset & email confirmation)...but nothing about hooking that up to Parse.
Any help would be greatly appreciated!
| d95e1d1072eb672f0f0711a9a264f3282a8507c79ba4290957427ed72482a378 | ['be2ddd8a95eb4e5589be9199a6d8addf'] | So I have a redirect working, but it's a little janky & I'm hoping to make it less janky :)
I'm using deep linking to basically open the app only....nothing beyond that at the moment.
Below is the redirect for ios. It works ok, but it's throwing a URL error in safari that I have to tap to close before it will redirect to the app store. (This is the case of a user not having the app installed)
So...I know universal linking is what iOS9 is doing, but I'm trying to avoid implementing too much on the native code side. All I've done is add my custom URL scheme to the plist of the app.
So wise internet...is there a better way?
else if(isMobile.iOS())
{
window.onload = function() {
window.location = 'vrbhome://';
setTimeout("window.location = 'https://itunes.apple.com/us/app/vrb/id1066438072?ls=1&mt=8';", 1000);
}
}
else {
document.location.href="http://vrb.is";
}
|
a8d555eb008be665e252a16e6de5b457b2c2cf19e73950e6755edd98c65b25e4 | ['be33b5e929c949ff8cf0ab4abdfad643'] | Maybe is obvious for you, but in the documentation talk about escaped characters:
Set up your server to handle requests for URLs that contain
The crawler escapes certain characters in the fragment during the transformation. To retrieve the original fragment, make sure to unescape all %XX characters in the fragment. More specifically, %26 should become &, %20 should become a space, %23 should become #, and %25 should become %, and so on.
| e36b9df5f91b14968a9c2be4580cc6afed3380c84a6a834b22d83ccdc1b24ccb | ['be33b5e929c949ff8cf0ab4abdfad643'] | You're trying to download a pdf as a binary content type data.
Use the response of your getObject request to get the proper mime type:
$result = S3<IP_ADDRESS>getObject($Bucketname,$uri);
header('Content-Description: File Transfer');
header('Content-Type: ' . $result['ContentType']);
header('Content-Disposition: attachment; filename=test.pdf');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . strlen($result->body));
ob_clean();
flush();
readfile($result->body);
exit;
|
e1765c9fdf42a9bea5d1fde6103959051b19e28b0781417616c276368ccfedbc | ['be474841854c426c94607803303dafd0'] | I make a parser and upload the data to excel. The problem arose with uploading data to Excel. In the text itself there are emoticons that he turns into something strange. How to fix it? Or exсel does not support emoticons?
with open('data.csv', 'a', encoding='utf-8') as f:
writer = csv.writer(f, delimiter=';')
for off in data:
line = [off.title, off.text, off.image_link,
off.categ, off.city]
writer.writerow(line)
| 87b475034c0ef93e3ce951bc992b13c87ef670d1a211a75150385cb0eaf5348a | ['be474841854c426c94607803303dafd0'] | I'm trying to open localhost:8000 but it doesn't work.
When I type docker ps it says that's container is fine
Here's my
docker-compose.yml
version: '3.7'
services:
web:
build: .
command: gunicorn app:app
volumes:
- .:/usr/src/app/
ports:
- 8000:8000
Dockerfile
FROM python:3.8.3-alpine
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
COPY . /usr/src/app/
RUN chmod 755 entrypoint.sh
ENTRYPOINT ["sh", "/usr/src/app/entrypoint.sh"]
My python entrypoint file
def app(environ, start_response):
response_body = b'Hello, world'
status = '200 OK'
start_response(status, headers=[])
return iter([response_body])
And entrypoint.sh file
#!/bin/sh
gunicorn app:app
exec "$@"
Structure of the project:
/venv
app.py
docker-compose.yml
Dockerfile
entrypoint.sh
requirements.txt
|
0b6f8e358511cf1c58535db50dcc7e2f8a15b9132a6c3a4c93e675111eaff466 | ['be4e5b3d77c6463eab36a10f70b0adab'] | I have a csv file called data.csv and this is what it contains:
8.84,17.22,13.22,3.84
3.99,11.73,19.66,1.27
16.14,18.72,7.43,11.09
What I want to do is to load all of it into a single list that looks like this:
[8.84,17.22,13.22,3.84,3.99,11.73,19.66,1.27,16.14,18.72,7.43,11.09]
The script I wrote using numpy is
import numpy as np
data = np.loadtxt(data.csv,delimiter=',')
print(data)
But what this gives me is a 3 x 4 numpy array
[[ 8.84 17.22 13.22 3.84]
[ 3.99 11.73 19.66 1.27]
[ 16.14 18.72 7.43 11.09]]
| cbb4d37aa669801e9eafd28f21e8a063534e05382a3da37dff9cbb0cc70fa939 | ['be4e5b3d77c6463eab36a10f70b0adab'] | So i tested a script that can be found in the scipy cookbook. I simply copied everything from the link. https://scipy-cookbook.readthedocs.io/items/CoupledSpringMassSystem.html
When I ran the script it gave me:
t, x1, xy, x2, y2 = loadtxt('two_springs2.dat', unpack=True)
ValueError: not enough values to unpack (expected 5, got 0)
what's happening here?
|
8262d7cf6d8423d1786d829ae45dc8b8256f01750060033b90a372f89aa17819 | ['be68280a97f94b289ff5a96724645364'] | You can add a white div that sits beneath the navbar but above the content.
http://jsfiddle.net/naLz7/
HTML
<nav id="top">
<div style="margin: 12px;">foo</div>
</nav>
<div id="bottom"></div>
<div id="content"></div>
CSS
#top {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 60px;
color: white;
background: rgba(0, 0, 0, 0.7);
z-index: 1;
}
#bottom {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 60px;
background: #fff;
z-index: 0;
}
#content {
margin-top: 60px;
}
| 11a8e5271acb423af4dfe175caf97e4d40b055d55f8f017c4caab9abb72c74d0 | ['be68280a97f94b289ff5a96724645364'] | Running just "npm install" will look for dependencies listed in your package.json. The error you're getting says that you don't have a package.json file set up (or you're in the wrong directory).
If you're trying to install a specific package, you should use 'npm install {package name}'. See here for more info about the command.
Otherwise, you'll need to create a package.json file for your dependencies or go to the right directory and then run 'npm install'.
|
257aa1ff3f2e8f6ebcb6cb7e194f6a7c6998f73c804c65b0ec732c1ac309b7dc | ['be6f007b0df740a8b8309584d3d6928a'] | I took over a Qt project using cmake on Windows platform; every time I open this project in Qt Creator IDE (by open the top level CMakeLists.txt), Qt Creator always re-run cmake for this project. Then when I run this project, even without changing anything, cmake will re-build the complete project (because cmake is re-run).
How can I avoid such re-build? I use cmake 3.12 and Qt Creator 4.10
p/s: I noticed that there is a similar question [1], but the answer there doesn't help to avoid the re-run.
[1] Can I prevent auto-run of CMake at startup of Qt Creator 4?
| f631c37d1c7b6f73dad0fe62e7ef5f7997e53d42cd3c0a1e3af28d5a260b20fc | ['be6f007b0df740a8b8309584d3d6928a'] | I have installed ARM DS-5 on my PC (Windows 10 64-bi); When launching Eclipse I got an error message:
Could not read environment file C:...\ds5\win_64\r5p0-27rel0\sw\info\env.ini": Operation not permitted
I have Full Control of this env.ini file and can open it with notepad to read/write; So not really a file permission issue.
Any idea why Eclipse cannot start?
|
4ef19193c9f3a1f916d5d16b6aa98cdb100549c4170eef670bd4bcbc06a774d8 | ['be6fe10ed71b4765b64928bcbe7e868d'] | After some time of meditation, I managed to reach a solution with a TcpListener & TcpClient.
Here's the code, if someone comes in handy (checking for an open copy of the application, data transfer, etc. can be changed, such methods work for me).
Startup:
Process[] processes = Process.GetProcessesByName("ProcessName");
if (processes.Length > 1)
{
TcpClient client = new TcpClient();
client.Connect(new IPEndPoint(IPAddress.Parse("<IP_ADDRESS>"), 12000));
StreamWriter sw = new StreamWriter(client.GetStream());
sw.AutoFlush = true;
sw.WriteLine($"addsong:{path}");
client.Close();
Process.GetCurrentProcess().Kill();
}
else
{
var thread = new Thread(ListenerCallback);
thread.Start();
}
Tcp Listener thread:
private void ListenerCallback()
{
TcpListener listner = new TcpListener(new IPEndPoint(IPAddress.Parse("<IP_ADDRESS>"), 12000));
listner.Start();
while (true)
{
TcpClient client = listner.AcceptTcpClient();
StreamReader sr = new StreamReader(client.GetStream());
MessageBox.Show($"Recieved data: {sr.ReadLine()}");
client.Close();
Thread.Sleep(500);
}
}
| 8b13d684207e0360708bd6db58754d96e245f02bf16a1ed583af8d630b09f7fe | ['be6fe10ed71b4765b64928bcbe7e868d'] | I'm making an mp3 player in C# WPF and I'm having trouble opening several files through explorer. The fact is that when you open several files through the Explorer context menu, each song opens in a separate program, I want that if the player is already open, when you reopen the application, a new song is transferred to the open application, and not played in a new one, how can this be implemented?
(Sorry for my bad english)
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length != 0)
{
var path = e.Args[0];
Player.PlaySong(new Song(path));
// ...
}
}
|
de99920e2e4491e117b1ab2c9903732ec18a55580bfb26307a8c409ad919f687 | ['be7402513a9340a98256682e9d147bd4'] | I have an ad customizer feed setup in my account and I want to change the value of one Item in that feed. I tried doing that using the "SET" operation in the 'FeedItemService'
When I run it, I get the following error:
KeyError: 'feedAttributes'
I have gone through the documentation here: https://developers.google.com/adwords/api/docs/reference/v201809/FeedItemService.FeedItemAttributeValue
I also went through the 'ADD' new feedItem code example here:
https://developers.google.com/adwords/api/docs/guides/ad-customizers
However, that's only to ADD new items rather than modify (SET) them.
Here is the code snippet:
fi_service = adwords_client.GetService('FeedItemService', version = 'v201809')
fi_operator = {
'feedId': 1234,
'feedItemId': 3456,
'attributeValues': [
{
'feedAttributeId':111,
'stringValue': '1000'}
]
}
fi_creator_operation = {'operator': 'SET',
'operand': fi_operator}
fi_call_response = fi_service.mutate(feed_creator_operation)
Here is the traceback:
Traceback (most recent call last):
File "<ipython-input-57-892b092f7b88>", line 15, in <module>
fi_call_response = fi_service.mutate(feed_creator_operation)
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1381, in MakeSoapRequest
packed_args = self._PackArguments(method_name, args)
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1239, in _PackArguments
for ((_, param), param_data) in izip(op_params, args)]
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1284, in _PackArgumentsHelper
elem_type, type_override is not None, data_formatted, set_type_attrs)
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1351, in _CreateComplexTypeFromData
for k, v in data if k != 'xsi_type'}
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1351, in <dictcomp>
for k, v in data if k != 'xsi_type'}
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1284, in _PackArgumentsHelper
elem_type, type_override is not None, data_formatted, set_type_attrs)
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1351, in _CreateComplexTypeFromData
for k, v in data if k != 'xsi_type'}
File "C:\ProgramData\Anaconda2\lib\site-packages\googleads\common.py", line 1351, in <dictcomp>
for k, v in data if k != 'xsi_type'}
KeyError: 'feedAttributes'
I have tried experimenting with adding ('xsi_type': 'feedAttributes') in the various dictionaries (fi_operator, attributeValues, fi_creator_operation), just in case it worked, however, I still get the same response.
| af87e1c56735ced240fec4b7e971629bacc02161e59574d688f8984e29dd4424 | ['be7402513a9340a98256682e9d147bd4'] | I'm trying to generate combinations of elements from multiple lists where the order is very important.
For example:
list1_mand = ['x', 'y']
list2 = ['a', 'b', 'c']
list3 = ['1', '2', '3']
list4_mand = ['A', 'B', 'C']
list5 = ['X', 'Y', 'Z']
The code should be able to do the following:
Generate all possible combinations in very specific orders (1st element from list1_mand, next from list2 and so on...): The order cannot be 1st element from list2, next from list5 etc.
For Example:
'xa1AX' is a valid output whereas 'axXA1' is not
There should be not repetition of elements.
For specific lists (list1_mand, list4_mand), the elements from these lists have to be present in the combination, whereas elements from other lists can be skipped.
For Example:
'xAX' is a valid output, whereas, 'a1AX' is not (element from list1_mand is skipped).
Taking into consideration the above three constraints, how can I use the itertools package to generate the required output?
|
7a0b5e8e2866b1e29e8981f83604eee724ad37acccc6bdcf84fba7180e89d73c | ['be7bef58a336410bbf0336bcecbc5ddd'] | I have been having a problem with Visual Studio 2015 and C#. When adding reference to other projects in the same solution, Visual Studio is not finding all the classes. For example I created a unit testing project. I added the reference to the Communication project I created. There are 10 classes in the library but Visual Studio can only find 3 of them. I have built and rebuilt the solution, I have built and rebuilt the projects. I have removed and re-added the reference. I have no idea where to go from here. I can't find anything online about this problem. I am not very familiar with Visual Studio and C# so I may just be searching the wrong things, but it is driving me nuts.
Here is the unit testing class, you can see that it is only finding three classes.
Here is a screen shot of the solution explorer showing the 10 classes that should be there (I'm trying to reference the Communication project), it also shows the reference:
And here is a picture of one of the classes so you can see it has the correct namespace:
I am going nuts here. Any help would be greatly appreciated.
| 91e70750684f437dff7507c7e6b7a70626dbb0d01ceca8af662c1f2124ae3c5a | ['be7bef58a336410bbf0336bcecbc5ddd'] | Is it possible to configure tinyproxy to forward its traffic to another proxy so it looks like
broadcasted through wifi
/
*laptop* *laptop* / *smartphone*
/ |
Firefox traffic <-----> tinyproxy <----> smartphone proxy/other <---> internet
<IP_ADDRESS>:9020 / <IP_ADDRESS>:44355
/
/
buffer a high speed response
i have managed to set a listening port as 9020 in /etc/tinyproxy/tinyproxy.conf but its internet connection goes through my regular internet.
|
43a5b1b56b8135819579024acb3b28d991368784a8e5064a4d0d53f55130ce12 | ['be7df92da12a4bd687e14af2648dc471'] | I am trying to figure to figure out how and if you can send and recieve arrays over TCP socket. I am a bit of a newbie at objective C but I have been able to send and receive strings. I just want to get it to do arrays now.
(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent {
NSLog(@"stream event %i", streamEvent);
switch (streamEvent) {
case NSStreamEventOpenCompleted:
NSLog(@"Stream opened");
break;
case NSStreamEventHasBytesAvailable:
if (theStream == inputStream) {
uint8_t buffer[1024];
int len;
while ([inputStream hasBytesAvailable]) {
len = [inputStream read:buffer maxLength:sizeof(buffer)];
if (len > 0) {
output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding];
if (nil != output) {
chSent = [output substringWithRange: NSMakeRange (0, 6)];
dimensionString = [output substringWithRange: NSMakeRange (7, 3)];
colorString = [output substringWithRange: NSMakeRange (7, 3)];
if ([chSent isEqualToString:@"dimen:"])
{
dimensionInt = [dimensionString intValue];
}
if ([chSent isEqualToString:@"color:"]) {
// insert array named color in here some how
}
}
}
}
}
break;
case NSStreamEventErrorOccurred:
NSLog(@"Can not connect to the host!");
break;
case NSStreamEventEndEncountered:
[theStream close];
[theStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
// [theStream release];
theStream = nil;
break;
default:
NSLog(@"Unknown event");
}
}
Thats what I have.
where I have put // insert array is where I am trying to put it
Thanks in advance if you can help.
| 1c58ed1d9321eae1cc8a8af847496e0198b74c1819836c175db70c147ba91d95 | ['be7df92da12a4bd687e14af2648dc471'] | I can find any documentatin anywhere and would like to know what would be the best method of send multiple messages as fast as possible.
for example if I had 300 devices recieivng messages from one server would it be better to send out one big message and have the devices pick out the parts that they need or send 300 messages but at 1/300 of the size. They would only be small stings so the 300 devies would only be getting 6 bytes each
Does it make a difference?
Thanks in advanced.
|
bc8a35fb47598c836d7afcbe3dd87c29ab4763067f506b9c4eba5514dc272b5e | ['be938a726d5944a681ddd43abd4da6ac'] | I know that factorials are, by definition, positive integers which means you can not have n! where n is negative. My question is can you create a factorial specifically for negative integers? I thought of this idea as a sort of opposite factorial. I used an upside down exclamation mark to denote a negative factorial. It functions as such: A negative factorial can only be performed on negative integers. The negative factorial of an even number is positive and the negative factorial of an odd number is negative (assuming the number is negative to begin with). If you take a negative factorial of a positive number you get the same answer as a factorial of negative number.
n¡=+(0,2,4,6,8…) or –(1,3,5,7,9…)
│n│¡=error
I do not know of any useful applications for this or if this is even possible at all. That's why I want to know if it's possible to make up a function such as a negative factorial.
| 258ca0819f70311f37a31393612a444caaa8f5e3d903e7fa263de07bc2342b9c | ['be938a726d5944a681ddd43abd4da6ac'] | Sorry for this late answer.
With iptables I can actually get what vnstat (and, partially, ifconfig) does, monitoring the whole wireless traffic; if you can help me with the ipset configuration I'll be grateful, since I tried to find some howto's but unfortunally I never really understood how network and iptables exactly work. |
baf8e69ef9a9756b705e1f04bb705739286953c50ecd84e2d898fbc140d041f4 | ['be994ad8886448cd9ec3ae7f9d5f4600'] | I'm trying to read sqlite database from the JS side which is created/updated by Android Activity or Service.
But when I call window.openDatabase() method the message below is appear on the LogCat, and Query returns 'no such table' error.
physical .db file is there and seems to accessible from within the Java code, but cannot
access from the JavaScript code. Uninstall or Clear data and reinstall the app did no help with this.
I have no clue to solve this error please help & any suggestions are very appreciated.
phonegap sqlite error code=14
I/Database(2138): sqlite returned: error code = 14, msg = cannot open file at line 27205
| 4184f0d25a9a445e8fb38b2fab428a35da60ecd84ba097540e024befeb6b9f64 | ['be994ad8886448cd9ec3ae7f9d5f4600'] | I want to run following html/JS code in PhoneGap,
but the alert dialog is not shown up and the following line is in the LogCat window;
the following warning appeared and alert did not showed.
[ERROR]
W/InputManagerService(266): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient
I jus want to fetch selected value on the change of the value, what's the problem? please help
[CODE]
<html>
<head>
<script type="text/javascript" charset="utf-8">
$("#selectcount").change(function() {
alert('hello');
}).change();
</script>
</head>
<body>
<div id="dialog" data-role="page">
<label for="select-choice-0" class="select">Number:</label>
<select id="selectcount" name="select-choice-0" id="select-choice-0">
<option value="50">50</option>
<option value="100" selected="selected">100</option>
<option value="500">500</option>
<option value="1000">1000</option>
</select>
</div>
</body>
</html>
|
01f1974a0101449be62efec803c34c283851ecc346f425d6cd1d05551a0d90e6 | ['bead6496f487487793e0036fd354f941'] | I am working on some iterator type that needs to wrap another iterator. For some reason, the custom iterator is not well defined. For example, it does not compile when used with std<IP_ADDRESS>all_of, complaining about a mismatching function call to std<IP_ADDRESS>iterator_category:
/opt/.../stl_algo.h:108:32: error: no matching function for call to '__iterator_category(Iterator<__gnu_cxx<IP_ADDRESS>__normal_iterator<int*, std<IP_ADDRESS>vector<int> > >&)'
108 | std<IP_ADDRESS>__iterator_category(__first));
The custom iterator exposes a public iterator_category type, so I am not sure what the problem is here. To demonstrate the issue, the custom iterator simply wraps some other iterator type:
#include <functional>
#include <iterator>
#include <vector>
template<typename It>
struct Iterator
{
using difference_type = typename std<IP_ADDRESS>iterator_traits<It>::difference_type;
using value_type = typename std<IP_ADDRESS>iterator_traits<It>::value_type;
using pointer = value_type*;
using reference_type = value_type&;
using iterator_category = std<IP_ADDRESS>input_iterator_tag;
Iterator(It it) : it_{it} {}
friend bool operator==(const Iterator& x, const Iterator& y) { return x.it_ == y.it_; }
friend bool operator!=(const Iterator& x, const Iterator& y) { return !(x == y); }
Iterator& operator++()
{
++it_;
return *this;
}
Iterator operator++(int)
{
Iterator it{*this};
this->operator++();
return it;
}
reference_type operator*() { return *it_; }
private:
It it_;
};
int main()
{
std<IP_ADDRESS>vector<int> v{1, 2, 3};
auto first{Iterator{v.begin()}};
auto last{Iterator{v.end()}};
std<IP_ADDRESS>all_of(first, last, [](auto) { return true; });
}
The compiler errors are solved in case the iterator derives from std<IP_ADDRESS>iterator:
struct Iterator : public std<IP_ADDRESS>iterator<std<IP_ADDRESS>input_iterator_tag, typename It<IP_ADDRESS>value_type>
(see: https://godbolt.org/z/vMfj38)
So std<IP_ADDRESS><IP_ADDRESS>difference_type;
using value_type = typename std::iterator_traits<It><IP_ADDRESS>value_type;
using pointer = value_type*;
using reference_type = value_type&;
using iterator_category = std::input_iterator_tag;
Iterator(It it) : it_{it} {}
friend bool operator==(const Iterator& x, const Iterator& y) { return x.it_ == y.it_; }
friend bool operator!=(const Iterator& x, const Iterator& y) { return !(x == y); }
Iterator& operator++()
{
++it_;
return *this;
}
Iterator operator++(int)
{
Iterator it{*this};
this->operator++();
return it;
}
reference_type operator*() { return *it_; }
private:
It it_;
};
int main()
{
std::vector<int> v{1, 2, 3};
auto first{Iterator{v.begin()}};
auto last{Iterator{v.end()}};
std::all_of(first, last, [](auto) { return true; });
}
The compiler errors are solved in case the iterator derives from std::iterator:
struct Iterator : public std::iterator<std::input_iterator_tag, typename It::value_type>
(see: https://godbolt.org/z/vMfj38)
So std::iterator brings something to the table that is missing from the definition of Iterator above, but what?
| a839ecacaa800c28e6bb44fe511a638b3c54d6a40d382e4b40ab94102cfbb01e | ['bead6496f487487793e0036fd354f941'] | Since you asked to provide answer, I'll put some additional information here, although I am not sure it will completely answer your question.
Assuming the target platform is Linux, once ipstream is destroyed in the parent process, it effectively means that the file descriptor for the associated pipe between the parent and child process is closed in the parent process. Once the child process writes to the pipe after the parent process closed its read end of the pipe, SIGPIPE is generated for the child process, which will cause it to terminate in case no extra measures are taken.
To prevent this, one option is to ignore SIGPIPE in the child. This will now cause errors in the child process when writing to that pipe. It depends on the implementation of the child process what cause that will have. A solution in your case could be to ignore SIGPIPE, and take measures in the child process once it can no longer successfully write data, to prevent a lot of wasted CPU cycles.
To experiment with this on a lower level, you can use the following program. It will fork a child process that will keep on writing to some output as long as that succeeds. The parent process will close the corresponding pipe as soon as it has read some data from it.
The behavior of the program differs depending on how SIGPIPE is handled in the child process. In case it is ignored, the write() in the child process will fail, and the child process will exit with a non-zero exit code. In case the SIGPIPE is not ignored, the child process is terminated by the operating system. The parent process will tell you what happened in the child process.
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char** argv)
{
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
perror("pipe");
exit(1);
}
pid_t pid;
if ((pid = fork()) < 0) {
perror("fork");
exit(1);
}
if (pid == 0)
{
close(pipe_fds[0]); /* close read-end in the child */
/* Uncomment the following line, and the child will terminate as soon
as the parent closes the read end of the pipe...This is here merely
for illustrative purposes, production code should use either
sigaction() or pthreads related signal functionality in case of a
multi-threaded program. */
/* signal(SIGPIPE, SIG_IGN); */
/* Child process, start writing to the write-end of the pipe. */
const char message[] = "Hello world!\n";
while (write(pipe_fds[1], message, strlen(message)) >= 0);
exit(1);
}
close(pipe_fds[1]);
char buf[256];
ssize_t count;
while ((count = read(pipe_fds[0], buf, sizeof(buf) - 1)) == 0);
if (count < 0) {
perror("read");
exit(1);
}
buf[count] = '\0';
printf("%s", buf);
/* Close read-end in the parent, this will trigger SIGPIPE in the child
once the child writes to the pipe. */
close(pipe_fds[0]);
int stat;
if (waitpid(pid, &stat, 0) < 0) {
perror("waitpid");
exit(1);
}
if (WIFSIGNALED(stat) && WTERMSIG(stat) == SIGPIPE) {
printf("\nChild terminated by SIGPIPE\n");
}
if (WIFEXITED(stat)) {
printf("\nChild exited with exit code %d\n", WEXITSTATUS(stat));
}
exit(0);
}
|
754612d18df5d78cd6a995b8be64e036ca0f42b615398916249c4337b2cf8974 | ['bec3cae246204a57a446bb3a173432e1'] | As mentioned before, CancelInvoke and a boolean flag are options.
However, I prefer/ suggest a different approach.
Change your method into a couroutine.
public class colorchange : MonoBehaviour
{
public int color;
private SpriteRenderer _mySpriteRenderer;
private float _timeBetweenChanges = 1f;
private Coroutine _colorRoutine;
void Start()
{
_mySpriteRenderer = GetComponent<SpriteRenderer>();
_colorRoutine = StartCoroutine(ChangeColor());
}
IEnumerator ChangeColor()
{
while (true)
{
color = Random.Range(1, 5);
if (color == 2)
{
_mySpriteRenderer.color = Color.blue;
}
else if (color == 3)
{
_mySpriteRenderer.color = Color.red;
}
else if (color == 4)
{
_mySpriteRenderer.color = Color.yellow;
}
yield return new WaitForSeconds(_timeBetweenChanges);
}
}
private void OnMouseDown()
{
StopCoroutine(_colorRoutine );
}
}
I prefer this approach since you can keep a reference to the routine and you could even change the delay time without stopping/ starting.
Also, you are not dependent on a string matching the method name and can pass in additinoal parameters when using a Coroutine as opposed to an Invoke method.
| 37c0c6b522cef2a1a1ee61864abd900062ab24f1dfe75f6a596eb3b95e1dda34 | ['bec3cae246204a57a446bb3a173432e1'] | Color accepts floats ranging from 0 - 1 for it's constructors.
You are setting them to 1 (anything above 1 is set to 1). And 1,1,1 = white.
this.gameObject.GetComponent<Image>().color = new Color(0.415f, 0.682f, 0.09f);
This should give you the result you are looking for.
The numbers are generated by dividing your values by 255
Alternatively you could also parse your hexvalue:
if(Color.TryParseHtmlString("#75BF1A", out myColor))
{
this.gameObject.GetComponent<Image>().color = myColor;
}
|
c2f099eecb9ab6e361e82353187ab7f7443541e99d1906d090931e275d26abe7 | ['beccb03ca2874577888bfcef1c3c6628'] | public static void registerXmppProviders(){
ProviderManager providerManager = ProviderManager.getInstance();
providerManager.addIQProvider("query", "jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
ProviderManager.getInstance().addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
ProviderManager.getInstance().addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
ProviderManager.getInstance().addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Time
try {
providerManager.addIQProvider("query", "jabber:iq:time",
Class.forName("org.jivesoftware.smackx.packet.Time"));
} catch (ClassNotFoundException e) {
Log.w("TestClient",
"Can't load class for org.jivesoftware.smackx.packet.Time");
}
//Pings
providerManager.addIQProvider("ping","urn:xmpp:ping",new PingProvider());
// Roster Exchange
providerManager.addExtensionProvider("x", "jabber:x:roster", new RosterExchangeProvider());
providerManager.addIQProvider("vCard", "vcard-temp", new VCardProvider());
// Message Events
providerManager.addExtensionProvider("x", "jabber:x:event",
new MessageEventProvider());
// Chat State
providerManager.addExtensionProvider("active", "http://jabber.org/protocol/chatstates",
new ChatStateExtension.Provider());
providerManager.addExtensionProvider("composing", "http://jabber.org/protocol/chatstates",
new ChatStateExtension.Provider());
providerManager.addExtensionProvider("paused", "http://jabber.org/protocol/chatstates",
new ChatStateExtension.Provider());
providerManager.addExtensionProvider("inactive", "http://jabber.org/protocol/chatstates",
new ChatStateExtension.Provider());
providerManager.addExtensionProvider("gone", "http://jabber.org/protocol/chatstates",
new ChatStateExtension.Provider());
// XHTML
providerManager.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im",
new XHTMLExtensionProvider());
// Group Chat Invitations
providerManager.addExtensionProvider("x", "jabber:x:conference",
new GroupChatInvitation.Provider());
// Service Discovery # Items
providerManager.addIQProvider("query", "http://jabber.org/protocol/disco#items",
new DiscoverItemsProvider());
// Service Discovery # Info
providerManager.addIQProvider("query", "http://jabber.org/protocol/disco#info",
new DiscoverInfoProvider());
// Data Forms
providerManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
// MUC User
providerManager.addExtensionProvider("x", "http://jabber.org/protocol/muc#user",
new MUCUserProvider());
// MUC Admin
providerManager.addIQProvider("query", "http://jabber.org/protocol/muc#admin",
new MUCAdminProvider());
// MUC Owner
providerManager.addIQProvider("query", "http://jabber.org/protocol/muc#owner",
new MUCOwnerProvider());
// Delayed Delivery
providerManager.addExtensionProvider("x", "jabber:x:delay",
new DelayInformationProvider());
// Version
try {
providerManager.addIQProvider("query", "jabber:iq:version",
Class.forName("org.jivesoftware.smackx.packet.Version"));
} catch (ClassNotFoundException e) {
// Not sure what's happening here.
}
// VCard
providerManager.addIQProvider("vCard", "vcard-temp", new VCardProvider());
// Offline Message Requests
providerManager.addIQProvider("offline", "http://jabber.org/protocol/offline",
new OfflineMessageRequest.Provider());
// Offline Message Indicator
providerManager.addExtensionProvider("offline", "http://jabber.org/protocol/offline",
new OfflineMessageInfo.Provider());
// Last Activity
providerManager.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider());
// User Search
providerManager.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider());
// SharedGroupsInfo
providerManager.addIQProvider("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup",
new SharedGroupsInfo.Provider());
// JEP-33: Extended Stanza Addressing
providerManager.addExtensionProvider("addresses", "http://jabber.org/protocol/address",
new MultipleAddressesProvider());
// FileTransfer
providerManager.addIQProvider("si", "http://jabber.org/protocol/si",
new StreamInitiationProvider());
// Privacy
providerManager.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
providerManager.addIQProvider("command", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider());
providerManager.addExtensionProvider("malformed-action",
"http://jabber.org/protocol/commands",
new AdHocCommandDataProvider.MalformedActionError());
providerManager.addExtensionProvider("bad-locale",
"http://jabber.org/protocol/commands",
new AdHocCommandDataProvider.BadLocaleError());
providerManager.addExtensionProvider("bad-payload",
"http://jabber.org/protocol/commands",
new AdHocCommandDataProvider.BadPayloadError());
providerManager.addExtensionProvider("bad-sessionid",
"http://jabber.org/protocol/commands",
new AdHocCommandDataProvider.BadSessionIDError());
providerManager.addExtensionProvider("session-expired",
"http://jabber.org/protocol/commands",
new AdHocCommandDataProvider.SessionExpiredError());
providerManager.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
// Offline Message Indicator
providerManager.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
providerManager.addIQProvider("query", "http://jabber.org/protocol/disco#info",
new DiscoverInfoProvider());
providerManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
// pm.addExtensionProvider("status ","", new XMLPlayerList());
providerManager.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
providerManager.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
providerManager.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
}
| b681b16c17f80f2b40b8fd73c5244f30051c329976c0b84fcfeedd7ae13fecde | ['beccb03ca2874577888bfcef1c3c6628'] | For getting rosters just search for a plugin called registration properties or if it is pre installed search for it in the users section.
Then check the Enable automatically adding of new users to a group.
Also in the bottom create a new default group so that when a new user will be created it will be automatically added to this default group.
After that run the same code you will get all the users present on the xmpp protocol based server.
|
797113de9a32de10b369c42c0546ef41c784c03b49c50070b5b01c2def2dd29c | ['becd213848544d579697a84c41703404'] | I am trying to save to Chrome's synced storage, a dynamically generated JSON object.
Essentially, I am running a query to get all the open tabs:
function getTabs(){
var activeSession = [];
//Tab query with no parameters, returns all open tabs.
chrome.tabs.query({}, function(tabs){
//For each tab push to active session array
tabs.forEach(function(tab){
activeSession.push({'title': tab.title, 'url': tab.url});
});
});
return activeSession;
}
I then get a name for this group of tabs from user-input, build a JSON object and save this to Chrome's synced storage:
//Retrieve group name from input field
var group_name = document.getElementById('file_name').value;
//Call function to retrieve tabs and build JSON object.
var returned_tabs = getTabs();
var obj = {[group_name]: returned_tabs};
console.log(obj);
chrome.storage.sync.set(obj, function() {
chrome.storage.sync.get(function (data) {
console.log(data);
});
});
The obj variable is essentially the structure I am looking for, and works as expected, as indicated by the console.log(obj). Which outputs like this:
Desired Output
However, when I try to store this in Chrome - it simply saves as the group_name with an empty array. So, if I pull this info back out of storage and log it out, I get:
Actual Output
| 85c332adff4f4e7ae5a621ab3d7ec2db17db4a66cc7dfbaab433addb1b525967 | ['becd213848544d579697a84c41703404'] | Basically, I am trying to read a live feed from a webcam, split this feed into a grid of 10x10 (100 total) blocks and re-build the video frame in a random order. With this new order of blocks making up a frame I am trying to apply effects to each block depending on its position (for example: greyscale, gausian blur etc). The above is okay. The problem I am experiencing is coming from trying to rebuild the frame with blocks which are both RGB and greyscale being that one has three channels the other has one, giving the following error:
error: (-215) channels() == CV_MAT_CN(dtype) in function copyTo
I've encountered this situation before and in the past have resolved it by duplicating the single grey-scale channel three times and merging together. This time round however it doesn't seem to be solving the problem. I should also point out I am quite new to OpenCV so I could be confusing something trivial. I expect the problem is in the second case of the switch statement:
#include <imgproc_c.h>
#include <iostream>
using namespace cv;
int main( int argc, char** argv ) {
namedWindow( "Example2_10", WINDOW_AUTOSIZE );
VideoCapture cap;
if (argc==1) {
cap.open(-1); //0
} else {
cap.open(argv[1]);
}
if( !cap.isOpened() ) { // check if we succeeded
std<IP_ADDRESS>cerr << "Couldn't open capture." << std<IP_ADDRESS>endl;
return -1;
}
int frameWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH);
int frameHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
cv<IP_ADDRESS>Size sb_size(frameWidth/10, frameHeight/10);
Mat frame, img_gry, img_gry_color, img_cny_color, img_cny, img_join, img_flip, temp, img_effect;
vector<Mat> img_gry_vec;
vector<Mat> img_cny_vec;
int n_cols = 10;
int n_rows = 10;
//Create multidimensional array of key pair values for positional data
std<IP_ADDRESS>pair<int, int> posIndex[100];
//Populate positional array with positions of every possible frame block
int counter = 0;
for(int i = 0; i < frameWidth; i += sb_size.width){
for(int j = 0; j < frameHeight; j += sb_size.height){
posIndex[counter] = std<IP_ADDRESS>make_pair(i, j);
counter++;
}
}
//Random shuffle positional array so as to provide random structure for compilation
std<IP_ADDRESS>random_shuffle(&posIndex[0], &posIndex[100]);
for(;;) {
cap >> frame;
if( frame.empty() )
break;
//Create empty grid to be populated with blocks
Mat3b grid(n_rows * sb_size.height, n_cols * sb_size.width, Vec3b(0,0,0));
//Initialise row/column and effect counters.
int rowCounter = 0;
int colCounter = 0;
int blockIndex = 0;
int effectIndex = 0;
for(int i = 0; i < frameWidth; i += sb_size.width){//iterate columns
colCounter = 0; //Reset column number on new row
rowCounter++; //Count row number
effectIndex++; //reset effect counter to equal row number on new row.
if(effectIndex == 6){
effectIndex = 1;
}
for(int j = 0; j < frameHeight; j += sb_size.height){//iterate rows
colCounter++; //Count column number: 0 - 9
blockIndex++; //Count block index: 0 - 99
//Get block position from shuffled positional array to temporary storage.
temp = Mat(frame, Rect(posIndex[blockIndex].first, posIndex[blockIndex].second, sb_size.width, sb_size.height)).clone();
Rect roi(i, j, sb_size.width, sb_size.height);//Get region of interest
effectIndex++;
//if effect index reaches five, reset to one
if(effectIndex == 6){
effectIndex = 1;
}
//Determine which effect to apply based on effect index
switch(effectIndex){
case 1:
//Copy to grid at correct roi with no effect applied.
temp.copyTo(grid(roi));
break;
case 2:
cvtColor(temp, img_gry, COLOR_BGR2GRAY);
img_gry_vec.push_back(img_gry);
img_gry_vec.push_back(img_gry);
img_gry_vec.push_back(img_gry);
cv<IP_ADDRESS>merge(img_gry_vec, img_gry_color);
img_gry_color.copyTo(grid(roi));
break;
case 3:
temp.copyTo(grid(roi));
break;
case 4:
GaussianBlur( temp, img_effect, Size(5, 5), 3, 3 );
img_effect.copyTo(grid(roi));
break;
case 5:
temp.copyTo(grid(roi));
break;
}
}
}
imshow( "Example3", grid);
img_gry_vec.clear();
if( cv<IP_ADDRESS>waitKey(33) >= 0 )
break;
}
return 0;
}
The program runs as expected without the greyscale applied. Any help or pointers is much appreciated.
|
edec735f8b3b5410e633117ff15df9b3417f82286b5a0bfe3d928e1b7336027c | ['becf41bf8b514593b78affcebbd44d39'] | In the end, the way that I was able to solve my problem was by removing the onleave event altogether. It was what was causing most of the issues.
So, now on onenter, I'm simply checking whether the currentTarget is different than a previously visited currentTarget. If it is, disable the previously visited currentTarget's indicator, and activate the new currentTarget's indicator.
This actually worked better than I had expected, because the indicator stays even if you leave the card, but haven't entered a new card. That way you can always keep track of where you last entered.
| 8e518a1d8ea7a683a95877c58aa0441a51d72b3bcfb6eced99c70b9e6bd73ae0 | ['becf41bf8b514593b78affcebbd44d39'] | I have a table in which I want each of its td elements to have no space between each other. However, I still want borders between each td(so you can actually tell them apart). Unfortunately, when I try either or both of the following:
table {
border-collapse: collapse;
border-spacing: 0;
}
My borders disappear entirely. I tried giving the td elements outlines through css, but that didn't work either. I looked at several different threads about html table spacing, but none of them talk about retaining borders after removing the space.
The reason I need this feature is because I want a fluid hover effect between each td, and having that small gap ruins the effect.
Any help would be great.
|
c583786536dac7cf54e9aebffbff4c279e89a5d9bc91cfa324356de9b8b1c3d2 | ['beee552bd4774532962e127f861f972d'] | I have a grid that I have made in sprite kit for my game. The grid is made with SKSpritenodes that are images. I want to have levels of difficulty where the grid is 2x2, 3x3, 4x4, 5x5, and 6x6. Each image is approximately a static 100 in width and height. When my grid is 2x2 the grid looks good centered in the middle, However, it looks too small and does not take up a lot of screen space. When the grid is 3x3, it does not look good when centered and looks slightly too small. When the grid is 4x4, it looks good centered, however, also looks slightly too small for the screen. When the grid is 5x5, it looks off when centered, but looks good for the screen. When the grid is 6x6, it looks great and proportionate. My question is, how can I made all the grid sizes look when centered and take up the appropriate amount of screen space. Meaning, I want the 2x2 to have larger grid squares than the 3x3, and the 3x3 to have larger grid squares than the 4x4 and so on and so forth. I want to have a grid that dynamically resizes based on the given rows and columns.
| fc5c082b75dbba98bf8aa8cd1059e672cad88aab274d6bc1d1e23e46b4db5431 | ['beee552bd4774532962e127f861f972d'] | I would like to use a UISearchBar and put it towards the bottom of a screen in order to search for available names through an API call. I want to have this SearchBar as part of a sign up form. However, when I put the SearchBar on the screen where I would like through the Storyboard, it does not show up when I run the app on the simulator. When I looked up this issue, everyone is putting the searchbar in a tableview. Am I not using the correct UI element for my cause?
|
9b01bc878cd2e2a3c559ecf9ccca0a6f120857d812ec48ca6fa5654918cba5e1 | ['bf0653eb5e8a4a7ba48e520eaab6957c'] | Thank you for your response. I know this question is not very particular to Ethereum itself since it doesn't suffer from this issue but it was difficult to find many authoritative technical resources on this subject. I will award you the bounty for your effort but because the answer lacks technical detail on the attack, I can't accept it. I will write my own answer with the technical details | 15cce3e4f419c6df064289f4c86b42d121ded59a00afe21ca9403773860ee91a | ['bf0653eb5e8a4a7ba48e520eaab6957c'] | <PERSON>, I did modify that script to a cell size of 2 m and modified block stats to focal stats too, in addition I was able to reproduce the same results only using flow direction tool straight from toolbox, so the bug is in the tool itself. I send this issue to ESRI and they were also able to reproduce it with my sample data, but not with their own data. So apparently the bug is data related. Weird still. |
cf4f6a6dd35baae9e7ef4ff4d107ec53d2d8b7568207fd999f55020a4f084e04 | ['bf0874661f3c4bca859c3d1838cc5235'] | I want to grant a user read only db access to a postgres cloud sql db on GCP (google cloud). For example, I want user to able to view db tables from postico/pg admin but not be able to delete/update/insert records.
I granted the user the following roles
Cloud SQL Client (Connectivity Access to Cloud Sql Instances)
Cloud SQL Viewer (Read only access to Cloud SQL Resources)
I first tried only
Coud SQL Viewer but the user could not access the db from their local machine.
Cloud SQL Client (Connectivity Access to Cloud Sql Instances) - Does this give user ability to edit the db records ? If so, is there a way to have connectivity access without write permissions ?
| 4e39161b258c4db4b78f5c1c7a93425943cfddd045f4f9f8d8d30050c2779434 | ['bf0874661f3c4bca859c3d1838cc5235'] | I want to zoom out on an embedded google map in a chrome webpage using selenium. I have tried the following with different location and scaling tweaks but neither works for me. I am able to zoom-out on the page but not on the map so that it reloads with new markers covering the a new map area.
browser.send_cmd('Input.synthesizePinchGesture', {
'x': 500,
'y': 200,
'scaleFactor': 0.5,
'relativeSpeed': 800, # optional
'gestureSourceType': 'default' # optional
})
and
browser.execute_script("document.body.style.zoom='0.5'")
Is there another solution ?
|
c8fa5b84fcc97b32cc6f7b211738923b0daa8a4b3090d72227b5338a7a802591 | ['bf0903303c424175be2bf7e401fdfd64'] | It all depends on your dns settings and how easy they are to control. If you have a cPanel provided by your hosting company this is usually easy to do. The websites have to be on the same url usually but a sub domain can forward to an external website.
Contact your hosting company/domain provider about using sub domains.
| 6710e5488f5a3f82fda33c4bd3e879a7ef82b74f1512d7d396b824b3751274b9 | ['bf0903303c424175be2bf7e401fdfd64'] | First a few things. Assuming a url such as `test.php?n=4':
Fix the constant errors. This immediately threw an error when I implemented the script.
function handle_request() {
if(empty($_GET["n"]))
{
return 'EMPTY';
}
elseif(!isset($_GET["n"]))
{
return 'VAR_NOT_SET';
}
else
{
return $_GET["n"];
}
}
In your get_random_bytes function you have if(is_int($n) && $n > 0). Anything retrieved from the $_GET is handled as a string. I would suggest either casting $n to an int or using if(is_numeric($n) && $n > 0) which in turn works.
function get_random_bytes($n) {
if(is_numeric($n) && $n > 0) {
$bytes = openssl_random_pseudo_bytes($n, $cstrong);
$hex = bin2hex($bytes);
$hex_up = strtoupper($hex);
if($cstrong === TRUE) {
return $hex_up;
}
else {
return FALSE;
}
}
else {
return FALSE;
}
}
|
92483cfb2da1c444cd660917a682767edc3336a3793d1277fc97ad24f07f431a | ['bf13b0f8df564ecc85269a6b2ac0af2b'] | The CSS overflow-y style is what you need. if you set
overflow-y:scroll;
on the div that you wish to scroll, then it will scroll vertically. In your example, I think that's the "windowContents" div, so change it to be this:
<div class="windowContents" style="overflow-y:scroll;">
You have a lot of CSS styles in the example. You might want to simplify it for debugging this issue. Setting the style directly on the div tag in the HTML as I did above will override any other overflow-y style from the stylesheet and help you isolate the issue.
| 07c44bd2632de82d35c2bbb8554af9518ed0fef436e57c0a2bc5fcaacc570be3 | ['bf13b0f8df564ecc85269a6b2ac0af2b'] | If a NoSql document oriented DB works for you, it's pretty easy to get MongoDB running on AWS and accessing it through pymongo.
The AWS specific quickstart is here:
https://wiki.10gen.com/display/DOCS/Amazon+EC2+Quickstart
and a general Mongodb tutorial is here:
http://docs.mongodb.org/manual/tutorial/getting-started/
A PyMongo tutorial is:
http://api.mongodb.org/python/current/tutorial.html
|
680d9a043b00387af721b58ab5b0d26d5a625208ef440e9cd79fa5a00850e503 | ['bf18174011164b679ffdd0b7f0e63286'] | I'm trying to connect through a https proxy but an exception is always caught stating that "The ServicePointManager does not support proxies of https scheme".
The code I'm using to test the connection is the following one :
var handler = new HttpClientHandler
{
UseProxy = true,
Proxy = new WebProxy("https://xxx.xxx.xxx.xxx:443") {Credentials = new NetworkCredential(Username, Password)}
};
using (var client = new HttpClient(handler))
{
var x = await client.GetStringAsync("https://api.ipify.org/?format=text");
}
I also tested the proxy using curl and it worked perfectly (although I had to use --proxy-insecure for some reason). The command I used is :
curl --proxy-insecure -x https://username:<EMAIL_ADDRESS>:443 https://api.ipify.org/?format=text
When I tried using http:// for the proxy curl just gave me the error "(56) Proxy CONNECT aborted".
So, is it possible to use a https proxy with the .NET Framework ? (I'm currently using .NET 4.6.2)
| 03d1fff13bfa3071aea80a601fd615c8570f2fdc917697ce08d405c18163cf48 | ['bf18174011164b679ffdd0b7f0e63286'] | I've seen that a lot of people around here are trying to use approximation to make Sigmoid faster. However, it is important to know that Sigmoid can also be expressed using tanh, not only exp.
Calculating Sigmoid this way is around 5 times faster than with exponential, and by using this method you are not approximating anything, thus the original behaviour of Sigmoid is kept as-is.
public static double Sigmoid(double value)
{
return 0.5d + 0.5d * Math.Tanh(value/2);
}
Of course, parellization would be the next step to performance improvement, but as far as the raw calculation is concerned, using Math.Tanh is faster than Math.Exp.
|
e622201b273fe89b2403d100759020c1a3399223e8fe5baddda85261f62e4e03 | ['bf2df01690454e76b00ddbf6f925c7e7'] | I'm learning R and I have tracked down a problem in my code to an expectation of what looping over a vector would do. Here's what I'm confused by--say I've got a numeric vector with two nonconsecutive elements in it.
x <- c(1, 3)
If I loop through the vector to do something with the values it contains, I am not getting the values. This loop, for example,
for (i in x) {
print(x[i])
}
prints out
[1] 1
[1] NA
but I would expect it to print 1 and 3, rather than 1 and NA.
I know I am misunderstanding something, but I cannot see what. I would appreciate it if anyone can help me clear up my understanding.
| 64d4890b69ff7b62a5cf4b26b9d384d5cf209345cf603dda6fa9485ef5df28eb | ['bf2df01690454e76b00ddbf6f925c7e7'] | You JSON data and parameter looks correct. The only reason the documentation gives for returning a 403 is if permissions are insufficient. The permissions structure in D2L is so flexible that it's possible that an administrative level account doesn't have permission to update course info in the apitest tool.
One way to check this and practice with the API a bit would be to GET what permissions your account has.
|
5b7456848d838b70946f609800f7363a5b1d96c1edc56082083b6e5ebd3faa21 | ['bf392cc06cdc447f9335a7aad004bdc3'] | I'm just trying to use create_mute with Twython. But I keep getting this error and I'm not sure what I'm doing wrong. Python 2.7+ just running it locally out of my terminal to see if it works.
from twython import Twython, TwythonError
import sys
## data from account (these are filled in properly, in my file) ###
APP_KEY = 'XXXXXXXXXXXX'
APP_SECRET = 'XXXXXXXXXXXX'
OAUTH_TOKEN = 'XXXXXXXXXXXX'
OAUTH_TOKEN_SECRET = 'XXXXXXXXXXXX'
if len(sys.argv) >= 2:
target = sys.argv[1]
else:
target = raw_input("User to mute: ")
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
try:
twitter.create_mute(screen_name=target)
except TwythonError as e:
print(e)
| 4838f3ceb0af4432f8b63b741bb98d85c52c9caa65b4c7857d106246ffc6f7ae | ['bf392cc06cdc447f9335a7aad004bdc3'] | I have a question that I need some opinions on. I have a small JSON file, and I'm using as a datastore.
{"stress": [1, "good"], "physical": [6, "ok"], "mood": [8, "good"], "perception": "neutral", "spoons": 74}
Basically I have a webhook running in flask on a pi for an alexa service. And throughout the day this datastore is updated. ie: If you go through one intent then it updates stress to 4. This is NOT an application. This is a standalone installation piece that runs locally, in a room, and doesn't need to scale at all.
What's the best way to do this? Should I just store this JSON file in the root folder and import it then write out to it? Should I look at something like tinyDB instead? Should I toss into Flask's static folder?
Again, super tiny thing, doesn't need to scale. Doesn't have multiple users. I feel like something like postgres or a full db is overkill.
|
c591fcacf5596e088cbf1f3184950893f4391740dd9027d698097fdfc1468574 | ['bf5472cd4b7d4a6c90623e8eeb6ffedd'] | Thanks for answering. I have looked at the links you posted but they are all about Android tablets. I am referring to the page here
http://www.ubuntu.com/tablet/operators-and-oems
If it is ready for OEMs, why can't we download it for Windows PC tablets same as we can for server or desktop editions? Seems like a PC tablet should be the easiest target given that Ubuntu is originally for PCs.
Desktop Ubuntu is awful on a PC tablet so I have been waiting for a couple of years now for Ubuntu touch and Canonical says it is ready so where is it please? We're past 14.04.
<PERSON> | 0a5ead32ab2276ea14cb513dd401df9e7c038f93361dbdac391fb31853b5458d | ['bf5472cd4b7d4a6c90623e8eeb6ffedd'] | Thanks again <PERSON>. I thought it must be the case but the PR lies on the page I linked to made me think that the x86 version must be available somehow (not entirely unreasonable given that it actually says it is available for x86 on that page). Will wait for 14.10 I guess. Thanks for your patience and all your help. |
eb9a93b711411f540d414a15e9367cfa94ed05a3e61dafb60e59c59df7c82f02 | ['bf55bcfa34c4418ba561dd3599dd6a78'] | After studying documentation, I am familiar that redux creates a global store and for better SEO performance SSR (Server side rendering) is a good choice where I preload my data in first landing page and then I can dispatch it directly in my global store to render DOM in html page for SEO optimization.
Something like window.__PRELOAD_STATE__ is used.
However, I have a question in my mind. there is a scenario like in my first page, I have preloaded my data in json. Now after click the link somewhere I want to navigate to another page. How can I again preload the next page of data without refreshing page? I understood that I have to call the Server side data but how?
Is it possible?
HELP WOULD BE APPRECIATED!!!
| f93cb9af8f037192055353c9e0dbe16bba206a9c6765a596ece89207f15e8677 | ['bf55bcfa34c4418ba561dd3599dd6a78'] | I am using bootstrap to create cards using below example link:
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_temp_portfolio&stacked=h
I am using ajax to push cards data in a global array.
htmlCards = [];
$.ajax({
async: true,
url: 'xxx.com',
type: 'GET',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(data) {
for(var i=0; i<data.length; i++) {
htmlCards.push("<div class='col-sm-3'><img class='movie-selection' src="+eval(data[i].title.replace(/\s+/g, '').replace(':', '').toLowerCase())+" class='img-responsive' style='width:100%'><p class='movie-selection' >"+data[i].title+"</p></div>");
}
}
});
Now all cards are now pushed to my global array. I am using bootstrap to list all the cards. However i want to give a break of row in each 3 cards listing. Something like below:
<div id="listing-main">
<div class="row">
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="https://placehold.it/150x80?text=IMAGE" class="img-responsive" style="width:100%" alt="Image">
</div>
</div>
</div>
How can I do that using ajax?
HELP WOULD BE APPRECIATED!!
|
36b795b6b83175f9f6f5a11beb522642a29bb2e8d77562e7e287ac8b3869418b | ['bf572d92cc104ebc9d9a5363ba3394b1'] | Thanks for the useful comments.
Because both lists are already made before mapping I've done it this way:
Gets the list from the db:
List<Metadata> metadatas = _Metadataservice.GetList(_Collectionservice.Get("Koekelare").ID).ToList();
Create the mapper (thanks for pointing out my mistake):
Mapper.CreateMap<Metadata, MetadataInput>().ForMember(s => s.Property, t => t.Ignore());
Make a new list and map the new (single) values one by one:
List<MetadataInput> meta = new List<MetadataInput>();
for (int i = 0; i < e.Count; i++)
{
meta.Add(Mapper.Map<Metadata, MetadataInput>(metadatas[i], input.Metadatas[i]));
}
Could someone confirm this is a good way?
| 03beb1889110664f06fdf55eee2dcbe1c0e8f1123f2d1f2835025056d8543bb1 | ['bf572d92cc104ebc9d9a5363ba3394b1'] | I'm currently working on a ASP.NET MVC 4 project as a trainee and I'm trying to implement an admin panel. The goal is to show all the users on a grid (MVC.GRID) and edit them on the same page.
I've managed to show all the users on the grid and once a user is selected it shows the info below the grid and puts it in a form (via ajax/jquery).
The problem is: the form validation is being displayed on a new page and not on the page where the grid is at. And I've no idea why..
Below is my code.
This is where the form is placed:
<div id="order-content">
<p class="muted">
Select a user to see his or her information
</p>
</div>
The form itself (partial view "_UserInfo):
@using (Ajax.BeginForm("EditUser", "Admin", FormMethod.Post,
new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
UpdateTargetId = "order-content"
}))
{
@Html.Bootstrap().ValidationSummary()
@Html.Bootstrap().ControlGroup().TextBoxFor(x => x.Id)
@Html.Bootstrap().ControlGroup().TextBoxFor(x => x.Name)
@Html.Bootstrap().ControlGroup().TextBoxFor(x => x.Password)
@Html.Bootstrap().SubmitButton().Text("Opslaan").Style(ButtonStyle.Primary)
}
JQuery to show the user info once a row is selected:
$(function () {
pageGrids.usersGrid.onRowSelect(function (e) {
$.post("/Admin/GetUser?id=" + e.row.Id, function (data) {
if (data.Status <= 0) {
alert(data.Message);
return;
}
$("#order-content").html(data.Content);
});
});
});
My AdminController:
[HttpPost]
public JsonResult GetUser(int id)
{
var user = _UserService.Get(id);
var input = _EditInputMapper.MapToInput(user);
if (user == null)
return Json(new { Status = 0, Message = "Not found" });
return Json(new { Content = RenderPartialViewToString("_UserInfo", input) });
}
[HttpPost]
public ActionResult EditUser(AdminUserEditInput input)
{
if (ModelState.IsValid)
{
// todo: update the user
return View();
}
// This is where it probably goes wrong..
return PartialView("_UserInfo",input);
}
Can anyone see what is wrong with my code?
Thank you.
|
c11b80823a18cf930e10fd92cfdbf0cd94c60b7bdb2df83321409ebfabe9d84d | ['bf6733a3b7524842a7ee76ce84f0a7cf'] | I am using ui-component form edit and would like to add custom button "customButton" with all post data. However, it doesn't post any data except form key.
My code
$data = [
'label' => __('Print Address'),
'class' => 'save',
'data_attribute' => [
'url' => $this->urlBuilder->getUrl('*/*/printAddress', ['id' => $this->getRequest->getParam('id')]);
],
'sort_order' => 80,
];
| fce3b3fc833bccafb46b626dd160a69ee581061316a2a8387d0e605a2e8d9269 | ['bf6733a3b7524842a7ee76ce84f0a7cf'] | Cloning also have problems with who pays the charge: do you put the original in jail or the clone? how can you be sure that you arrested the right clone and he didn't ALSO made a clone to skip sentence? or worst, he lets himself be caught and then just rejoin the original and disappears from the cell. |
f04593559f90ecb8e332d4c2fbd8da1b1e95c7312c271fdaf0a0ff2f02d178ed | ['bf879848bada4456a954066d425d2c71'] | I have a very specific question regarding indentation of blocks on Visual Studio (I currently use its 2013 iteration). If I have something like this (code in C++):
if (a)
return d;
Visual Studio indents it correctly, i.e., by adding a tab in the following line to the if clause. Now — when presented with something like this:
if (a)
if (b) {
c = c + a;
return d;
}
Visual Studio instead indents it like:
if (a)
if (b) {
c = c + a;
return d;
}
This is not, indeed, something I'd like to see on my code. I know someone might come and say not having curly brackets around clauses can be considered as a bad programming habit, but that's my style of coding.
Does anyone know a way around that on Visual Studio? I believe I tried pretty much every option on the Text Editor preferences, without success.
Thank you!
| 382044d7c37a21a16624d3ac2490f66524f98c44e94d7eace1fb12a4980ccdbf | ['bf879848bada4456a954066d425d2c71'] | Say I have 1000 identical pods I'd like to be run eventually, but node resources only allow for 10 pods to be run in parallel.
Each pod eventually removes their RC if they exit cleanly, so given enough time, all pods should be run.
If I schedule all 1000 pods at the same time, though, 990 of them will be pending initially. The scheduler will keep all 990 pods on a busy loop trying to be scheduled, and the operation will only succeed (for a certain pod) after one of the 10 running pods is removed.
This busy loop is far from ideal in my situation, as it'll likely take all of the scheduler's available resources. Is there an alternative solution to this provided natively by kubernetes? It seems clear that this particular behaviour of scheduling way more pods than you're able to deal with isn't something that kubernetes optimises for.
|
2b98f56728b4b7201688f47ddab4861467e375f16bb564067f5f7add22d9e3d8 | ['bf918f680fef42e18ae3f29bc34fe71d'] | I have this type of data (all big letters are strings)
>A|B|C|D|E|F
test test test
test test
>A|B|C|D|E|F
test test test
test
and want to delete C, D, E:
>A|B|F
test test test
test test
>A|B|F
test test test
test
In "test" text, no | occurs. I have tried this with sed, but Im not able to replace the text which comes after two |
Thank you in advance.
| 2f266ad3ae2d9048796069461307c3d156a5e6174783869ad45131ab1e90b7b5 | ['bf918f680fef42e18ae3f29bc34fe71d'] | I have data in following format and I want to extract the first column and the column 6, if there is a column six:
ID1 Bacteria;Firmicutes;Clostridia;Clostridiales;
ID2 Bacteria;Firmicutes;Clostridia;Clostridiales;Eubacteriaceae;Eubacterium;Eubacterium hallii;
ID3 Bacteria;Firmicutes;
ID4 Bacteria;Firmicutes;
ID5 Bacteria;Firmicutes;Clostridia;
ID6 Bacteria;
ID7 Bacteria;Firmicutes;Clostridia;Clostridiales;Ruminococcaceae;Faecalibacterium;
ID8 Bacteria;Firmicutes;Clostridia;Clostridiales;Ruminococcaceae;Faecalibacterium;Faecalibacterium prausnitzii;
The output should be:
ID2 Eubacterium
ID7 Faecalibacterium
ID8 Faecalibacterium
I try to solve the problem by split by ";" and grep the 6th column cut -d ";" -f 6 but think you will have a better solution. Thank you in advance!
|
aa6726e00563aee191f25808146ea2c1b2b7ac458596869ffd5ab1bae36196be | ['bf9b6de0e9fa481e9f10ad1de9224306'] | I get the same error and I'm sure the path is right as well. In fact, it seems to find the file every other time it tries, with very similar code.
for r in range(0,5):
for c in range(1,4):
fn = file_name(c)
try:
photo = tk.PhotoImage(fn)
tk.Button(C, image = photo, width = "16", height = "16").grid(row = r,column = c)
except Exception as exception:
| e25b939b004b6c4cd87e204137cf28becaf64a89e4dc78d02c584eafe60c2e61 | ['bf9b6de0e9fa481e9f10ad1de9224306'] | <PERSON>, When you first plug in, Windows offers you some choices on how to deal with the new device; Open in File Explorer, etc...one of them is Windows Media Player. Choose that. I had similar problems and this solution worked for me and my galaxy S3...
<PERSON>, why does this work?
|
91655423b3164d252019d29d9958cd5a7e85b6b7f973ca6ed20ccc4b504d3efc | ['bf9fee64c6964fd880f44ef41a4e2fe4'] | I want to test againts multiple command line arguments in a loop
> python Read_xls_files.py group1 group2 group3
No this code tests only for the first one (group1).
hlo = []
for i in range(len(sh.col_values(8))):
if sh.cell(i, 1).value == sys.argv[1]:
hlo.append(sh.cell(i, 8).value)
How should I modify this that I can test against one, two or all of these arguments? So, if there is group1 in one sh.cell(i, 1), the list is appended and if there is group1, group2 etc., the hlo is appended.
| 211176ab0836de74d640f80037cdf22cd7e08555684ede5aaf901913e8572228 | ['bf9fee64c6964fd880f44ef41a4e2fe4'] | Thanks so much!! I'm getting really stressed out about my electricity bill. No matter what I do I cannot get to the same amounts they are, even if I do round up... I'm $6 off and I am pretty sure I am being overcharged :(. All of their rates include taxes so it's not that. I'm clueless. |
19c337dcb8194e8b9323dba239d3d9b9d3e3f4e67dd2204fdcc824c05b3f5a07 | ['bfa4b8a797754c3eb72f50a32b2d04da'] | SELECT Terminal.NodeID, Object.ObjectID, Object.TerminalID1, Object.TerminalID2
FROM Terminal
INNER JOIN Object
ON Terminal.TerminalID=Object.TerminalID2
This should get you what your looking for.
I'm not entirely sure of how it would react with duplicates so you might want to add a Distinct but i think it's a simple way to get it done
| 4ffd4fa07d8ce5322359c9fcfcceabaac2476e3ef4501ff6a11640955d936020 | ['bfa4b8a797754c3eb72f50a32b2d04da'] | I saw you already got the problem fixed but i don't have the reputation to comment yet and wanted to throw this bit of info your way
with your current firstFunction if the data is a - b. c
you'll end up with something like a--b--c
i would suggest you change it to
function firstFunction($string) {
$string = preg_replace("/[-\s.]+/", "-", $string);
return $string;
}
|
9407d7137c7c3c5e2087bf27c5ce2d3374fe1be04324a1321a0d8869637903b3 | ['bfbae04a1fdd4395b059fbacc3519f85'] | Dears, I'm working with GATE && JAPE rules to walk around in my ontology,
I run the following code:
OURI uri = ontology.createOURI(cURI);
OClass nClass = ontology.getOClass(uri);
byte closure = 0;
Set<OClass> superClass = nClass.getSuperClasses(closure);// direct_closure
for (OClass temp : superClass)
{
Set<OClass> disClass = temp.getDisjointClasses();
}
I get : Error: The method getDisjointClasses() is undefined for the type OClass.
would you help please to correct this, and get the disjoint class ?!
| 9898321b6ac7790bbb1e62c0c27615aa81426cc45a566335231931f1842c4616 | ['bfbae04a1fdd4395b059fbacc3519f85'] | Dears,
I use Gate Developer 8.5, and Ontology plugin, Ontology Editor :
I load my initial file "test.owl", its classes' names were written in Arabic Language, but when I try to update this file , like adding sub class and try to write its name in Arabic,
I get an error: invalid class name, so, how can I enable Arabic characters in Ontology Editor interfaces.
adding sub class with English name done successfully.
|
87c776d9a506eda4c8ff1d7dc177f4e0c544b67d70466da9be8c856da0461ee7 | ['bfc8118381f04a3997e9670394ada252'] | I'm trying to implement a comment section and after button-press I want to update the comment section with ajax so the page doesn't have to refresh...
In this comment section I have 1 textarea + 1 button + a couple of hidden fields for every comment so users can answer specific comments...
so if there are 50 comments there are also 50 answer-fields, 1 for each...
And every thing works except for 1 thing...
- either I name all id's of the buttons and fields the same name (ie. id="sendAnswer" and id="answer", id="userID", ...) and then only the first one works...
-or I dynamically name them all (ie. id="sendAnswer(echo $i) ) thereby naming them all id="sendAnswer0", "sendAnswer1", "sendAnswer2", ... and then I do that for the textarea and hidden fields too (ie. id="answer(echo $i), id="userID(echo $i), ...)
And that works great too... except for now I have to make a jQuery-script for each... and since they are dynamically created that's difficult - as how many there are changes as more comments comes in...
Code for approach 1: naming them all the same...
$(document).ready(function(){
"use strict";
$("#sendAnswer").click(function(){
var comment = $("#comment").val();
var userID = $("#userID").val();
var randomStringVideo = $("#randomStringVideo").val();
var commentID = $("#commentID").val();
$.ajax({
type: "POST",
url:'../scripts/comment.php',
data:"comment="+comment+"&userID="+userID+"&randomStringVideo="+randomStringVideo+"&commentID="+commentID,
success:function(){
$("#commentDiv").load(location.href + " #commentDiv>*", "");
$("#commentsDiv").load(location.href + " #commentsDiv>*", "");
$("#comment").val('');
}
});
});
});
And as I said... this works fine for the first one and the rest are duds...
Code for approach 2: I dynamically name all values...
$(document).ready(function(){
"use strict";
$("#sendAnswer"+$(this).val()).click(function(){ // this +$(this).val() doesn't work, only if I put #sendAnswer3 - then the 4th works and the rest are duds etc.
var comment = $("#comment"+$(this).val()).val(); // works perfectly no matter what #sendAnswer I use
var userID = $("#userID"+$(this).val()).val(); // works perfectly no matter what #sendAnswer I use
var randomStringVideo = $("#randomStringVideo"+$(this).val()).val(); // works perfectly no matter what #sendAnswer I use
var commentID = $("#commentID"+$(this).val()).val(); // works perfectly no matter what #sendAnswer I use
$.ajax({
type: "POST",
url:'../scripts/comment.php',
data:"comment="+comment+"&userID="+userID+"&randomStringVideo="+randomStringVideo+"&commentID="+commentID,
success:function(){
$("#commentDiv").load(location.href + " #commentDiv>*", "");
$("#commentsDiv").load(location.href + " #commentsDiv>*", "");
$("#comment"+$(this).val()).val(''); // this +$(this).val() doesn't work, only if I put #comment3 (matching the #sendAnswer)- then the 4th works and the rest are duds etc.
}
});
});
});
With this I would have to name every single possible #sendAnswer-number + #comment-number for it to work... and with an infinite set of numbers to choose from 0-(infinite) - that's not viable...
If of any interest...
Php that dynamically creates the buttons and fields in question
.
.
.
<?php if ($_SESSION[numberOfComments] != 0) {
for ($i=0; $i<$_SESSION[numberOfComments]; $i++) ?> // run through all comments that aren't answers to other comments
// show comment info
<div class="media">// answer comment box starts here
<img class="mr-3 rounded" src="<?php $file = USER . $_SESSION['randomString'] . THUMBNAIL; if ( file_exists ( $file ) ) {echo $file; } else { echo USER . "default" . THUMBNAIL; } ?>" width="50" height="50" data-toggle="tooltip" data-placement="left" title="<?php echo $_SESSION['username']; ?>">
<div class="media-body">
<textarea class="form-control" rows="2" type="text" name="comment<?php echo $i; ?>" id="comment<?php echo $i; ?>" value="" placeholder="Great video!"></textarea>
<input type="hidden" name="userID<?php echo $i; ?>" id="userID<?php echo $i; ?>" value="<?php if ( isset ( $_SESSION['id'] ) ) { echo $_SESSION['id']; } ?>">
<input type="hidden" name="randomStringVideo<?php echo $i; ?>" id="randomStringVideo<?php echo $i; ?>" value="<?php echo $_GET['v']; ?>">
<input type="hidden" name="commentID<?php echo $i; ?>" id="commentID<?php echo $i; ?>" value="<?php echo $_SESSION['commentID_getComment']; ?>">
<button type="button" class="btn btn-primary float-right margin-top-5" id="sendComment<?php echo $i; ?>" value="<?php echo $i; ?>">
Answer
</button>
</div>
</div> // answer comment box ends here
<?php if ($_SESSION[numberOfAnswers][$i] != 0) {
for ($j=0; $j<$_SESSION[numberOfAnswers][$i]; $j++) { ?> // run through all answer to this comment
// show answer info
<?php }
}
}
} ?>
.
.
.
| 4a1461384b068bd5c951a77d52bd299215329ab858e201ce9c0dddf3faeacd51 | ['bfc8118381f04a3997e9670394ada252'] | I want users on my page to be able to subscribe and unsubscribe to each other as many times as they want without having to refresh whole page between each click...
To that end I have a subscribe/unsubscribe button...
And it works fine... when user clicks it updates the database and switch to the oppsite (subscribe->unsubscribe, and vice/versa)...
The problem is that after button-click and subsequent button-change the new button is now inactive and user has to refresh whole page to make it active again...
How do I fix this?
Code for those who need it:
c.php (channel page) / v.php (video page) // the setup on both pages is the exact same for this button
<div class="row" id="subscribeAll">
<div class="col-xl-9 col-lg-8 col-md-7 col-sm-6 col-xs-12 col-12">
// some stuff (not relevant)
</div>
<div class="col-xl-3 col-lg-4 col-md-5 col-sm-6 col-xs-12 col-12" id="subscribe">
// if user logged in show content below
// if user viewing own channel/video
<button type="button" class="btn btn-lg btn-dark" disabled>
Subscribers // show number of subscribers
</button>
// else
<button type="button" class="btn btn-lg // if not subscribed btn-success // else btn-danger" id="// if not subscribed subscribeButton // else unsubscribeButton" value="// randomstring of user whose channel/video user is watching">
// if not subscribed Subscribe // else Unsubscribe // show number of subscribers
</button>
// else if user not logged in show content below
<button type="button" class="btn btn-lg btn-dark" disabled>
Subscribers // show number of subscribers
</button>
</div>
</div>
jQuery.js
// Subscribe
$(document).ready(function(){
"use strict";
$('button[id^="subscribeButton"]').on('click',function(){
var self = $(this);
var randomStringUser = self.val();
$.ajax({
type: "POST",
url:'subscribe.php',
data:"randomStringUser="+randomStringUser,
success:function(){
var subscribe = self.closest('#subscribeAll').find('[id^="subscribe"]');
subscribe.load(location.href + " #subscribe>*", "");
}
});
});
});
// Unsubscribe
$(document).ready(function(){
"use strict";
$('button[id^="unsubscribeButton"]').on('click',function(){
var self = $(this);
var randomStringUser = self.val();
$.ajax({
type: "POST",
url:'unsubscribe.php',
data:"randomStringUser="+randomStringUser,
success:function(){
var subscribe = self.closest('#subscribeAll').find('[id^="subscribe"]');
subscribe.load(location.href + " #subscribe>*", "");
}
});
});
});
Hope someone can help...
|
a18073287f7423f0496431c808267ced9fec04c2c4bd6c6f8c7ddabbf15da5f0 | ['bfd3d7fc9f1246269cc1c947aa8e0346'] | I need to send this table by email as an excel attachment using PhpExcel and PhpMailer. This table is a result of querying my oracle DB. I need to know how I can use PhpExcel to write this table to excel and then attach it to an email address with phpMailer and finally send it.
Thanks in advance.
<?php
$username = "xxx";
$passwd = "yyy";
$db="(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = <PHONE_NUMBER>)(PORT = 1234))
)
(CONNECT_DATA =
(SERVICE_NAME = xxx)
)
)";
$c = OCILogon($username,$passwd,$db);
if (!$c)
{
echo "Connection failed";
}
else
{
echo "We are connected to KYC.Querying DB now...Please wait... ";
}
$s = oci_parse($c, "
select MSISDN SUBSCRIBER_NUMBER, OUTLET_NUMBER,time_stamp, Company,NAMES SUBSCRIBER_NAME,GENDER, DOB DATE_OF_BIRTH,Dealer_name Dealer_name, Agent_name
from subscribers where time_stamp between trunc(sysdate)-1 And trunc(sysdate)-1/86400 order by time_stamp");
if (!$s) {
$e = oci_error($c);
trigger_error('Could not parse statement: '. $e['message'], E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$e = oci_error($s);
trigger_error('Could not execute statement: '. $e['message'], E_USER_ERROR);
}
$html .= '<table width="720" border="0" cellspacing="0" cellpadding="0">
<tr>
<th class="header" colspan="7"> KYC Details</th>
<tr>
<tr>
<th>SUBSCRIBER_NUMBER</th>
<th>OUTLET_NUMBER</th>
<th>TIME_STAMP</th>
<th>COMPANY</th>
<th>SUBSCRIBER_NAME</th>
<th>GENDER</th>
<th>DATE_OF_BIRTH</th>
<tr>';
while($rows=oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)){
$sub = $rows['SUBSCRIBER_NUMBER'];
$agt = $rows['OUTLET_NUMBER'];
$tim = $rows['TIME_STAMP'];
$com = $rows['COMPANY'];
$nam = $rows['SUBSCRIBER_NAME'];
$sex = $rows['GENDER'];
$dob = $rows['DATE_OF_BIRTH'];
$html .= '<tr>
<td>'.$sub.'</td>
<td>'.$agt.'</td>
<td>'.$tim.'</td>
<td>'.$com.'</td>
<td>'.$nam.'</td>
<td>'.$sex.'</td>
<td>'.$dob.'</td>';
$html .= '<tr>';
}
$html .='</table><hr>';
echo $html;
?>
| 3f3a94479e73bc8573a1eb481f5d8f7cbeeb91dd3558696e242832cfc9bdbb88 | ['bfd3d7fc9f1246269cc1c947aa8e0346'] | I am using Linux Suse 13.1. I have compiled the ibm_db2 extension for PHP successfully but when I run the connection test script it returns connection failed. I do not know where I am going wrong. Are there some other steps I need to do after installing the PHP extensions? Please note that I am using Data Client Server 9.7.
This is my script.
<?php
$database = 'Database_name';
$user = 'myusername';
$password = 'passwrd';
$hostname = 'xx.xx.xxx.xx';
$port = db_port;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
$conn = db2_connect($conn_string, '', '');
if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.";
}
|
ff540b7894d0144108c7601ffe1df9591ed85d6122ced0d9674b35887fd2f2e8 | ['bfe24cd7a71c4d59b2cba71726ba6365'] | I am using PDFBox in my project. I currently save the PDF that is created before sending it to client. Instead the requirement is to send the ByteArrayStream to client side without saving file. How to do this with PDFBox?
I know this possible with iText. But I am restricted to use iText in my current project.
Below is the code that is used.
PDDocument document = new PDDocument();
PDPage page = new PDPage();
PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.beginText();
contentStream.showText("PDF created");
contentStream.endText();
contentStream.close();
document.save(outputFilePath);// don't want to do this
document.close();
| 6a3b15dbe4ddc2cd5afa6944b6c54635e904ee02bddf3466c46b79d9cac0e851 | ['bfe24cd7a71c4d59b2cba71726ba6365'] | I am trying to filter the AuthenticationException that is thrown during a user Authentication in my application. I know these cannot be filtered with @ControllerAdvice and @ExceptionHandler. So trying to figure out any Handler would work for my problem.
Already tried different approaches like AuthenticationFailureHandler but they didn't fit my requirement as I am using ResourceServerConfigurerAdapter.
Please suggest.
|
41f5523964a71cc557886f8c3b8174b1cb8b35adffcc7332150b39a42f4575fb | ['c001a2bd8dcb40d4894ba5afb0457e3e'] | Are there any jQuery plugins available on web which displays table with re sizable columns and horizontal scrollbar. Plugin like colResizable provides resizing only in a fixed area. Also dataTables.net do not provide such table options.
i would like to have a similar kind of table as shown in this link.
Thank you.
| 7bf0fd9dbd80ddc020cd6a8f47e79399dbb277382d7a80740f5a5d96b88b52c3 | ['c001a2bd8dcb40d4894ba5afb0457e3e'] | Given a knockout foreach binding statement
<div data-bind="foreach: Tests">
<a><span data-bind="text: testName"></span></a>
<table>
<!--table contents -->
</table>
</div>
This generates multiple div elements - each containing its own tag and table. when I click on the hyperlink, its corresponding table's visibility must toggle. I could not manipulate the contents of Tests as its from the server. How can I get this effect?
Thanks in advance.
|
67e336d8ea5ad99cf3326a4674e9d0d2862610bdbeefe65d4aeff30ec9e0523c | ['c008b20f97d642c7a21bb6882d5bb0b1'] | I think a much simpler solution could take place.
According to your statement, you have 26 characters of space. However, to clarify what I understand to be character and what you understand to be character, let's do some digging.
The MD5 hash acc. to wikipedia produces 16 byte hashes.
The CRC32 algorithm prodces 4 byte hashes.
I understand "characters" (in the most simplest sense) to be ASCII characters. Each ascii character (eg. A = 65) is 8 bits long.
The MD5 aglorithm produces has 16 bytes * 8 bits per byte = 128 bits, CRC32 is 32 bits.
You must understand that hashes are not mathematically unique, but "likely to be unique."
So my solution, given your description, would be to then represent the bits of the hash as ascii characters.
If you only have the choice between MD5 and CRC32, the answer would be MD5. But you could also fit a SHA-1 160 bit hash < 26 character string (it would be 20 ascii characters long).
If you are concerned about the set of symbols that each hash uses, both hashes are in the set [A-Za-z0-9] (I believe).
Finally, when you convert what are essentially numbers from one base to another, the number doesn't change, therefore the strength of the algorithm doesn't change; it just changes the way the number is represented.
| c62e921681b53b810470beea4a5bbcc41a4f645305bea0e933092c725351a170 | ['c008b20f97d642c7a21bb6882d5bb0b1'] | In ftpsync, when I try to update my site example.com, I find ftpsync deletes everything in public_html (where example.com resides). My host specifies that other domains reside as subdirectories in public_html.
Even though I have tried telling ftpsync to ignore public_html/subdir-example1.com and the code shown below it gets removed every time I try an update.
{
"local":"public/",
"remote":"public_html/",
"host":"example.com",
"port":21,
"user":"secret",
"pass":"secret",
"connections":"1",
"ignore":[
".htaccess",
"subdir-example1.com/",
"subdir-example2.com/"
]
}
So how do I tell ftpsync to ignore a directory on the host?
|
acfa02ff16a74ec936af1cf14e8a773970c85b65dd0aaf701eedd5967225646a | ['c012f134a22e4b0097f45d35e8ba0301'] | You've forgotten to prefix the id attributes. Try to do it like this:
<?xml version="1.0" encoding= "utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/my_location"
android:icon="@drawable/my_location"
android:title="Current location" />
<item android:id="@+id/mapview_satellite"
android:icon="@drawable/satelliteview"
android:title="Satellite View" />
<item android:id="@+id/mapview_normal"
android:icon="@drawable/normalview"
android:title="Normal view" />
</menu>
| f38fc159d7acfacb4a7ac9a0902aa745a7389625dfd76ca2d9365585440ef79b | ['c012f134a22e4b0097f45d35e8ba0301'] | If you're planning to curl multiple times per pageload, I would highly recommend that you instead scrape them down on beforehand and store them locally. This would mean that you don't need to open (timeconsuming) connections to other hosts, and it benefits both you and the end-user.
Short answer: The most optimal approach would be to store them on beforehand, ie not using multiple curls per pageload.
|
d6a5773574dd46b6eb65630ef8e517542538fd516c7eeb3177669e030f5b24f2 | ['c0193602633947f4b83f3dae439b07fa'] | After days of searching, trying with errors using various sources with others' help, I managed to solve the problem using this solution:
Open directory
sudo nano /etc/apt/apt.conf
Enter proxy server url setting
Acquire<IP_ADDRESS>http<IP_ADDRESS>Proxy “http://username:password@proxy_url:port”;
Open directory
sudo nano /etc/environment
Type in proxies:
http_proxy=http://username:password@proxy_url:port/
httsp_proxy=https://username:password@proxy_url:port/
ftp_proxy=”http://username:password@proxy_url:port/”
After configuring the proxies setting, I manage to update php using normal command using ondrej.
Thank you to all of you for your suggestions and solutions.
| 2e4962963160341b6c6090674a0c77443e777610ec2c291c9be1f06abe9d7fbb | ['c0193602633947f4b83f3dae439b07fa'] | I want to use ondrej ppa to upgrade php version in ubuntu server. Do I need internet connection to run this command?
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.1
I had tried and produce error of ondrej/ubuntu/php, ondrej user or team does not exist.
Thank you
|
7e852fe0aaf1e8bb9a4c02645c6c2276e3133662cb0cebe8e443d91889f23c32 | ['c01f5332fe994550b012a11d6a6f5675'] | You can pass you information to the Activity that contains both the fragments like ((MainActivity)getActivity()).mapLocationUpdated(latlng) and create the mapLocationUpdated in your activity, then pass the information to the previous fragment by finding the fragment(with getSupportFragmentManager().findFragmentByTag(tag) and passing it the info.
You can also create an interface that the activity implements (like MapLocationInteractor that has the method mapLocationUpdated(latlng) and call your activity like this : ((MapLocationInteractor)getActivity()).mapLocationUpdated(latlng).
Don't forget to check for nulls in the getActivity and findFragment parts.
| cb3425f19ecc2f833f0e4e16b1fb32add4be587f7f6e2a83e2d691bd2d08839e | ['c01f5332fe994550b012a11d6a6f5675'] | Never put any android context inside a static field (which in Kotlin goes into the companion object), it is a bad practice since you can get a memory leak that way.
If you want to access the context in a class, either pass a context to it in it's constructor or if the class is like an activity, use getApplicationContext() to access the Context.
In your example, you don't need to store the context at all, since your activity is actually a Context itself (you can use this as context).
|
91e4b922562b61c876c7ca326443e63093766169b59640099bea6ca3a71be489 | ['c023760d476b40ac97f76e5b615bce9c'] | También puedes hacer esto que a mi me funciona.
Primero llamas al storyboard donde esta el viewController que quieres acceder:
let storyBoard = UIStoryboard(name: "Nombre del archivo storyBoard", bundle: Bundle.main)
Luego llamas al viewController del storyBoard casteandolo con la clase donde has definido vistas, variables, funciones, etc.:
let viewController = storyBoard.instantiateViewController(withIdentifier: "Lo que has puesto en Storyboard ID") as? ClaseViewController()
He ocultado los campos de la imagen por temas de trabajo (es una captura de mi trabajo y no puedo mostrar información)
Haciendo esto puedes hacer:
viewController.label
ó
viewController.miFuncion()
etc.
Si no casteas el viewController no podrás acceder a sus vistas, parámetros o métodos
| ccd89887ceb58eaf3bfa3e07bdc83fed20aab79798c8afde9505cefce35951c3 | ['c023760d476b40ac97f76e5b615bce9c'] | Can someone find out exactly what phone/phone number an email was sent from? Say <PERSON> used sallys phone to sign in and check his gmail account but never signed out then <PERSON> opened his gmail and sent an email using his account.. is there a way to find out that that email did infact come from sallys phone and not <PERSON>'s?
|
84055d59b360e22150103aed483a9d270a90dee4880de4d5b64da7e3b6b4de4c | ['c023cdfad34c462f846f6c02859886a2'] | So about a year back I dual booted my Aspire one with a Linix OS I Liked the OS but it was a little to advanced for my undoubtedly tiny graphics card. Looking at other options I found the OS that I have Currently which is Ubuntu 0.140.1 Recently my Computer told me that I needed to upgrade to 0.140.2. My issue is that when ever I go to do it that the system warns me that my tiny Graphics card cant support this new version. now to my questions: Is there an Ubuntu or Linix OS that I can get that will not have this issue at some point? What is it? How can I get it?
| a31f465023b48bec26d952eceb6c5b50a1ac5f95ccf3d3c832548c7ee9be85fd | ['c023cdfad34c462f846f6c02859886a2'] | This pertains to this RPG SE question. I have used a passage from the source book cited by another poster to answer the question in a different way, with a greater degree of concision. However, the original post has more upvotes.
Is it acceptable to select my own answer over the other, or is it poor form?
|
f82d560e6a0b9df039ea57bbba01f821eeede1582582fd6961e25f5ce53202f8 | ['c026955ef750482ab5e796d367ec4801'] | I am trying to get Qlik Sense to work using JWT auth, instead of our current header based auth. Has anyone been successful with this? Would anyone who's gotten this working be able to help me out? Even a sample working example is fine. I can try to follow through the process there to get it to work in mine.
Server Version: November 2017 release
Note: I am still pretty a newbie to Qlik, so hoping for considerate answers.
| d5e504c8c1452ea4f0b161f07eecb662e5ba83233ddd303c44cdab9cb364e890 | ['c026955ef750482ab5e796d367ec4801'] | I presume you are trying to execute your program through eclipse or some editor with its own console. The issue might not be with the program, but with the font (type and size) used in console.
Try running the program in DOS prompt, and you might be able to see your desired outcome.
public class PrintPyramidStar
{
public static void main(String args[])
{
int c = 1;
for (int i = 1; i <= 8; i++)
{
for (int j = i; j < 8; j++)
{
System.out.print(" ");
}
for (int k = 1; k <= c; k++)
{
if (k % 2 == 0)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println();
c += 2;
}
}
}
Above is a random star program I picked using search. Running the same via eclipse console gave me skewed triangle, wherein running the same via windows command prompt gave me a perfect triangle.
|
e5080a79c2dff567aba3d059556f6e0b732795843bf0b2effbd1d8aafc85a765 | ['c03bbeb79b21423ead4ca37d1a697640'] | My company is a B2B Software as a Service. We have a web with 2 main functions:
Log in for my current users (hundred of thousands)
a marketing web for my potential new customers, (portfolio, blog, contact us, etc.), about hundred leads.
It is recommended to put a first landing page to asking if who is in the browser is a current user or a lead, and depending on it, redirect to different webs?
I think it can improve the web optimization for each audience, and help keeping separated metrics (Analytics), but can be hard for who is browsing to give an additional click for accessing the page.
| 8074d84a227127a2a6002e7163b2f50e2255a15e9149c69348099f9574d8d9d7 | ['c03bbeb79b21423ead4ca37d1a697640'] | So played around this morning and seen where I went wrong.
I managed to do the above and its bascially what im looking for. Is there a way to add a link to the end of each record (in Timeline Query) so that I could click and show me the record in the original table? giving me all the details or even a pretty form display?
Many Thanks |
865c4fe8502236ae8a6d360eab14967468f2ae8a1fb1dae269f5c9ea59d8754e | ['c04f25ff8b8f47bea9dd359798f0fda0'] | I have a data.frame with 571 observations of 156 variables. I am interested in keeping all 156 variables; however, I only need complete observations for 7 of these variables.
By using:
> nrow(na.omit(subset(finaldata, select = c("h_egfr_cystc96", "child_age96", "smoke_inside2T", "SES_3cat2T", "X_ZBFA96", "log2Tblood", "sexo_h00"))))
I learn that there are 453 observations that have complete information for these 7 variables.
How can I create a new data.frame that will have 453 observations of 156 variables, with complete information for my 7 variables of interest?
I suspect that complete.cases will be useful, but I am not sure how to apply it here.
Any ideas? Thank you in advance for the help!
| 34e1b52838ed015506134c82a4b34bb05343afaa6a640471ea8dd95a300a5b39 | ['c04f25ff8b8f47bea9dd359798f0fda0'] | I have a data.frame with continuous and categorical variables. For a linear regression, I type something like:
lm(a ~ b + c + d, data = df)
Where a is a continuous outcome. If I want to assess an interaction between C and D, I type something like this
lm(a ~ b + c*d, data = df)
My question is -- what do I do if D is a binary variable encoded as 0=no and 1=yes?
Thank you in advance!
|
eef8a92ee1cee9feeb88ba2d1af67fffd06af4ac4f005822d447f1021d337824 | ['c05f2d9201f94a72980a25e538b8a0a2'] | Yes it’s speculation, that’s why I said “it’s likely...”, not “it definitely is...”. Other SE sites vary on standards because there is generally only one right answer to a question on maths.se or physics.se, but we are talking about fantastical and speculative fiction here and sometimes the answer is simply “that’s how it was written”, or “you need to suspend disbelief”. I’m not saying there isn’t a firmer answer than the ones given, but you need to accept there may not be. I haven’t found anything myself in English, perhaps someone might mind an interview or something in French. | 1b3286b4b57254a2eaa1b2421253e86d0b1a5cc00cfe4e66986badc7854109cc | ['c05f2d9201f94a72980a25e538b8a0a2'] | The following is what worked for me.
\usepackage{placeins}
...
\begin{figure}
...
\end{figure}
\FloatBarrier
The command Floatbarrier is to be included after end{figure} This forced every image to appear in the respective subsection. I know it is not in the spirit of LaTeX to use this. However it might be requirement sometimes...
|
52176733449fdead414e1926a3e50e7dc3252bfe91f433ae479dc15b1c6f084c | ['c067826bab3e4e66ba8dbe27cfd5e56e'] | However. note that in Slovakia (a situation quite similar to that of Norway vs. Swedish), if would be considered, well, not rude, but lame, to ask "Do you speak Czech?", and the best answer you would get would be something like "I don't, but I understand it/I speak Slovak", and then you'd be engaged in a conversation in Slovak anyway. | 6e006d980d7128aa36a79549dfb34667c51f25cb2846f50f27e0b69912bf292d | ['c067826bab3e4e66ba8dbe27cfd5e56e'] | At the time Sky Europe folded, people (in Europe) who bought their tickets via internet generally got their money back, even if they used debit cards (payment via a debit card can still be made in a credit card mode and then most credit card rules apply, and even if not, contacting the bank and asking would be wise). People who bought the tickets through tourist agencies or in cash were not so lucky (and it was much more common at that time). |
b3f258de72c12110b2f3ee5dd37d80b43f7350800221d67afe30597b2e5caf82 | ['c06d092a72974bce8f2ccbb99e370720'] | I have created a following helper (below codes are just to demonstrate what I am looking for)
@helper SayHello(string text)
{
@text
}
Now from an action i want to return this Helper's Text as Html (or string) as below
public ActionResult MyAction()
{
//something like this to return just html
return SayHello("Rusi");
}
| 7495375c5bd51ca5b627faed453ac5b7e22671dc1c143681cb4726556b7d3f68 | ['c06d092a72974bce8f2ccbb99e370720'] | In Asp.net MVC3 when you write below code , it generates wrapping html itself
@using (Html.BeginForm()) {
@Html.ValidationMessageFor(model => model.Text)
}
It generates codes in below format,
<form method="post" action="/Feeds">
<!-- Fields Here -->
</form>
My question in @using (Html.BeginForm()) automatically adds <form> tag at beginning and end, how can i create something like that of my own.
I am looking for some thing like below
@using (Html.BeginMYCUSTOMDIV())
{
I am text inside div
}
Expected Generated Output
<div class="customDivClass">
I am text inside div
</div>
|
d3bdfc95b4f149ab1e56fd5344fe506bcc8dff365e9a04be3ccdaa9e6be16f36 | ['c06d224ceafb4cf4b0a3ea2500b02894'] | Here's how I finally got this to work: I went into the GRUB boot menu, chose Advanced Options and booted in Recovery Mode. Then I could see the boot process (no black screen) and logged in, edited /etc/default/grub and added the nomodeset param, and ran sudo update-grub and rebooted. I have no idea why modifying the GRUB boot options with the nomodeset param didn't cure the black screen issue.
| 83771efb2892deb7e82e1e7e7910f3ef4b715ba82dca5d7d5a45b3885cdb83ac | ['c06d224ceafb4cf4b0a3ea2500b02894'] | Как я понял есть одинаковый формат дат и стоит найти одинаковое. Возможно просто загнать их в JSON и сравнить как строки. Например вот так
var dateFilter = JSON.stringify($('#date-filter').val());
$('.item').each(function() {
var tmp_formed = JSON.stringify($(this).attr('data-date'));
if (dateFilter.localeCompare(tmp_formed) !==0){какой-то код}
}
|
078a6f84a23fb2d4d339940a086abede73cf6d69db3deabf8574b753bc054563 | ['c06d3e614f0142e8b83211593eee1352'] | Well I'm learning lua and I got a question, I'm trying to create a reading function bool in lua.
I have a function that disables or enables as I score true or false.
This function is called just useappenabled that I am not able to apply it on the Moon, before I used in the form of libconfig and functioned normally before was written as follows.
The file is as follows:
Enableapp =
{
Useapp = true;
};
Now reading before shaped libconfig was the following, note that the useappenabled function is applied to the input value, i.e. true or false if I put on the Useapp.
if (config_lookup(&onf, "Enableapp"))
if (config_setting_lookup_bool(cf, "Useapp", &SelectValue))
useappenabled = SelectValue;
So I tried changing the code libconfig to lua, however I am not able to read the useappenabled function, the code is as follows in the lua.
lua_getglobal(L, "Enableapp");
lua_pushstring(L, "Useapp");
lua_tonumber(L, useappenabled);
I believe the problem is lua_tonumber, I need to do something more or less like this:
useappenabled = value_the_Useapp;
But I'm starting lua now, can anybody tell me how can I apply the function useappenabled to equal the Useapp value.
| c1d0a6289ba8e7fbf50fcdbed55ed75fea30fd578fe59df5166b2676d0ecf3d6 | ['c06d3e614f0142e8b83211593eee1352'] | I am having a problem when trying to return my struct in C ++ I am still new to that language.
I have the following code
Header File
class Rec : public Rect {
public:
Rec();
struct xRect
{
int x;
int y;
};
struct SRect
{
int position;
xRect *mtype;
int value;
bool enable;
};
struct xRect ReturnXRect();
};
Cpp file
struct xRect Rec<IP_ADDRESS>ReturnXRect() {
struct SRect *xrec = xRe<IP_ADDRESS>sRect();
if (xrec)
return xrec->mtype;
return nullptr;
}
I am getting error C2556 and C2371. someone what correct way to work struct in the class?
|
22dbc15aee9625d766dbc14ec9c45e488746aa2093aeef80f8a73cc1b3024aa8 | ['c075bf5fc91f42cd9e31323773e12339'] | Имеется сервис, который позволяет пользователю загружать файлы.
Для этого я использую AWS S3. Файлики каждого пользователя я кладу в отдельную "папку" (то-есть названия файлов одного пользователя имеют одинаковый префикс):
/user-id-1/file1.txt
/user-id-1/file2.txt
/user-id-2/file1.txt
Вопрос у меня следующий:
Как посчитать стоимость для каждого пользователя отдельно? То-есть мне нужно узнать сколько Gb в месяц лежит в "папке" /user-id-1
Что я пробовал:
посмотреть это через CloudWatch (не получилось, так как инфу по размеру можно получить только по бакету целиком)
получить список файлов и просуммировать размер (такой вариант мне не подходит, в случае если файлов много, допустим миллион, это будет очень медленно)
| 5e19b466b201107bb81c32431b25faaa4f769f1d2dd5348ff06c3bb61ffc4a96 | ['c075bf5fc91f42cd9e31323773e12339'] | The Problem
We want to know the amount of 8 digit passwords we can make using digits, uppercase, lowercase, and special characters. For this problem there are only 16 special characters. The rules are that the passwords must contain at least 1 uppercase, 1 digit, and 1 special character.
My Approach
After drawing a diagram Venn Diagram of 4 sets and assigning Uppercase to 'A', Digits to 'B', Special Characters to 'C', and Lowercase to 'D' I noticed that the total number we are interested in are the intersects of:
|A $\cap$ B $\cap$ C $\cap$ D| + |A $\cap$ B $\cap$ C|.
Based on the inclusion/exclusion principle the total number of combinations for 4 sets are:
$|A∪B∪C∪D|=$
$|A|+|B|+|C|+|D|$ all singletons
$-(|A∩B|+|A∩C|+|A∩D|+|B∩C|+|B∩D|+|C∩D|)$ all pairs
$+(|A∩B∩C|+|A∩B∩D|+|A∩C∩D|+|B∩C∩D|)$ all triples
$-|A∩B∩C∩D|$ all quadruples.
$(26+10+16+26)^8$(singles)$-[42^8+36^8+52^8+26^8+42^8+36^8]$(pairs)$+[52^8+68^8+62^8+52^8]$(tripled pairs)$-[26^8+16^8+10^8+26^8]$(quadrupled pairs)
=20734390444484096.
This is where I began getting confuzzled.
My intuition tells me to start subtracting amounts that we don't need from the total, which is everything but |A $\cap$ B $\cap$ C $\cap$ D| + |A $\cap$ B $\cap$ C| which feels the same as just substituting values $(26^8+16^8+10^8+26^8) + (52^8) =$ 53881777627904.
Is this the correct answer?
Is there a better way of going about this problem?
|
5f7591cb153a02d7610cb5c238755f91ea67f5869cd385722e1ecefc4e1d2669 | ['c0777075e1e145cab53ed31ccdcd92a1'] | You need any identifyer to do that. Maybe like your-domain/home or your-domain/about, etc.
You can use mod_rewrite tu make this to a good locking ID
.htaccess
RewriteEngine On
RewriteRule ^/?([a-zA-Z_-]+)$ index.php?p=$1 [L]
then you can use the switch function to different.
function getPage(){
if(isset($_GET['p'])){
switch(strtolower($_GET['p'])){
case 'index' : include(dirname(__FILE__) . '/../pages/index.php'); break;
case 'aboutme' : include(dirname(__FILE__) . '/pages/about.php'); break;
case 'legal' : include(dirname(__FILE__) . '/pages/legal.php'); break;
}
}
}
| 5c0119e31d67983cad0eacee668cf6ac0068e294cdd8c74a41826499136e55cb | ['c0777075e1e145cab53ed31ccdcd92a1'] | For a readable output use this
echo '<pre>' . print_r($_COOKIE, TRUE) . '</pre>';
then use this to add it to another Array
<?php
// for save coding
if(isset($_COOKIE) && !empty($_COOKIE)){
foreach($_COOKIE AS $keyName => $valueOfKey){
echo 'Debug Output: Key:' . $keyName . '|' . $valueOfKey . '<br>';
}
}else{
echo 'Error, $_COOKIE not set or empty';
}
?>
|
450e2b1cc0005ac0be6ee0081dd1522867aa12d66955d7e9326999e22ae7596d | ['c0780e64dbad4277a72046a893d4e54f'] | Consider the following table:
CREATE TABLE `FooAttachments` (
`AttachmentId` bigint(20) NOT NULL AUTO_INCREMENT,
`FooId` bigint(20) NOT NULL,
`AttachmentPath` varchar(100) NOT NULL,
PRIMARY KEY (`AttachmentId`),
KEY `IX_FooAttachment_FooBase` (`FooId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf16
If I insert a row into this table using the following statement, a row is created and the AI field has a value generated.
INSERT INTO FooAttachments (FooId, AttachmentPath) VALUES (1, 'test path');
However, when I try to use an INSERT INTO SELECT statement as follows, I get an error:
INSERT INTO FooAttachments
SELECT 1 AS FooId, 'test path' as AttachmentPath;
The error I get is: #1136 - Column count doesn't match value count at row 1
I understand that I'm not specifying the AttachmentId column, but I'm not doing so in the INSERT INTO ... VALUES statement either and that one works. More to the point, I don't want to specify a value for that column, it is supposed to be auto-generated.
How should I write this second query?
| 24188ef1c750aad98c165b5297440659683209938e5506a5a26fcf9dff2ce873 | ['c0780e64dbad4277a72046a893d4e54f'] | I'm using PHP to return a JSON encoded associative array to a client. The array is constructed by looping through the result set of a MySQL database query. For simplicity's sake, instead of showing all the code that returns the result set, let's say that one possible output to the query produces the following associative array in PHP:
$ResultRows = array(
"10 m" => 10,
"100 m" => 100,
"1000 m" => 1000
);
echo json_encode($ResultRows);
The JSON string produced by json_encode looks like this:
{"10 m":10,"100 m":100,"1000 m":1000}
As you can see, it gets encoded like an object with each key-value pair looking like a property name and value.
Now, the client running Java receives this JSON encoded string. I would like to create an instance of LinkedHashMap<String, Double> that is populated by these values. However, since it is not encoded like an array, I'm having a hard time seeing how to use GSON to decode this. Any ideas?
I could simply change the PHP and create a simple object that holds the Key/Value pairs and return a regular array of these objects, but I was hoping to leave the PHP scripts alone if possible because there are quite a few of them to change.
|
ab340f634a08e8e9946484d08d40fc3993f8900d4eaae86cd38f31309764e843 | ['c07cf78ff7154ce4bb46e8058014ca38'] | Sub duration()
Dim ws As ThisWorkbook
Set ws = ThisWorkbook
Dim wk As Workbook
lr = Sheets("COBACOBA").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lr
Cells(i, 29).Formula = Application.WorksheetFunction.NetworkDays_Intl(CDate(Cells(i, 16)), CDate(Cells(i, 28)), , Workbooks("Holidays.xlsx").Worksheets("Hol").Range("A2:A56"))
Next i
End Sub
| 8b209b4c826798537e838502a54e54b3cb3ef205dd089db753bbde2240250992 | ['c07cf78ff7154ce4bb46e8058014ca38'] | I have a workbook that contains about 30 worksheets.
I have to link text from one-sheets to other sheets
if I doing it manually it'll take to much time
so I want to use looping the hyperlink
Sub Macro4()
'
' Macro4 Macro
Dim i As Integer
Dim sht As Worksheet
i = 2
Set sht = Sheets("sheet" & i)
Range("D3").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"sheet2!A1", TextToDisplay:=Range("D3").Value
End Sub
how I can adjust this line
where can I input my I VARIABLE
SubAddress:= _
"sheet2!A1
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"sheet2!A1", TextToDisplay:=Range("D" & i).Value
|
4388f4ab227d80f2ca25aa7e00f81c1bc573a2a8c2ae65491893fc6874457a52 | ['c083cec05ffe47efb68ba9913e4de6d7'] | I cant understand what this happen but my datagridview each ro loop doesnt work for all my rows.
I have also a checkbox cell which i need to get its value when is selected
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
if (Convert.ToBoolean(row.Cells[0].Value) == true)
{
MessageBox.Show(row.Cells[1].Value.ToString());
dataGridView1.Rows.RemoveAt(row.Index);
}
}
It deletes some rows but not all selected
| 9af3a52cc8b6b07687cf84ac05d9921da94f69ec6b478013e1846756566502a0 | ['c083cec05ffe47efb68ba9913e4de6d7'] | I'm usign mobile for insert rows into a local sqlserver.
Some times the sql server doesnt responde and i'm forced to wait for getting exception.
I have set sqlConnetion time out to 3 seconds
SqlConnection con = new SqlConnection("Data Source = " + MyIp + "; Initial Catalog = database; user id = sa; password = 1234;Connection Timeout=3");
The problem is that sometimes i need to wait 30 seconds.
This time as i can understand is cmd execute timeout.
con.Open();
SqlCommand cmd = new SqlCommand("Insert into customers(Name) values(name123)",con);
cmd.ExecuteNonQuery();
con.Close();
So first question Sql connection time out doesnt include both of them?
Second question if sql doesnt responde then why dont i get first exception in 3 seconds?
And last question why sql server sometimes doesnt responde over network?
Can it be big network(traffic) delay , between mobile and server?
|
fd9920e41e5c6027fe1fa951368484f3dbd4f8bdc62d77b875bcb4aaaf6a9e2f | ['c09db9f13dce43d7a5a923ad8485af99'] | If I use Canvas instead of ScatterView and ScatterViewItem and the order ist like this
<s:ScatterView>
<Canvas Name="LineCanvas2" Width="500" Height="250" Background="Aquamarine">
<Canvas Background="Transparent" Name="LineCanvas"/>
<s:ScatterView Width="500" Height="250" Background="Transparent">
<s:ScatterViewItem ...
there is no problem with the positioning of the connection lines.
| ba18be2923444cb45017a8543d15980630a94e3bb96edc4baf61ea0425e2f3fc | ['c09db9f13dce43d7a5a923ad8485af99'] | After adding the Support-Library ADB won't rspond and I cannot run any emulator.
I already tried the restarting thing, also the kill-commands on the terminal. Even reinstalling Android SDK. Nothing worked.
Is there anyone with an idea what else I can try or what is going wrong?
|
91a930a7d109ee84c025216d92353d2dd74e5b5fcdfb46efc960654671639ceb | ['c0a81b2fc0fa43d6ab05de221c94b821'] | <PERSON> It works! If you want to answer the question with the solution I'll be glad to accept it, otherwise I can answer my own question (but it would not be fair, since you found the solution). I found the correct syntax for the `date` field on the biblatex manual, but I'm new to biblatex and I was unaware of the existance of that particular field, given the fact that there are `month` and `year` | e26b992fd6452e3cfaf2642fdabd93f173d5b9faee54377d05c7d64367f45973 | ['c0a81b2fc0fa43d6ab05de221c94b821'] | I'm using the BibLaTeX package with these options: backend=biber, citestyle=authoryear, maxcitenames=2, mincitenames=1, maxbibnames=99, language=italian.
If I have two documents from the same author and the same year, the command \cite{work1} and \cite{work2} will output Author A and Author B, XXXXa and Author A and Author B, XXXXb. I'd like to redefine the command \cite{} in order to output Author A and Author B (XXXXa) and Author A and Author B (XXXXb). I tried using the citeauthor and citeyear commands, but the citeyear does not take the letter into account (it just prints Author A and Author B (XXXX) if I do \renewcommand{cite}[1]{\citeauthor{#1} (\citeyear{#1})})
I know there is a way to do it, but I don't know how. Could you please help me?
Thanks in advance
|
45839355df79840cd09621e43ff9f498e5378d970bd3837c5a940ba82ab5df07 | ['c0b195ad31bd4a4aa863922e5ac3f631'] | I'll give it a try myself because I think I have a slightly more formal answer than the answers provided up to now (<PERSON> and <PERSON> are going into the same direction but the answers are a little bit vague in my opinion). I'll let the voters decide on the final accepted answer later.
My try:
"Code" is a noun ("here is my source code")
"to code" is the verb (I code, you code,...) and the present participle is "coding".
"Coding" is a <PERSON> (https://en.wikipedia.org/wiki/Gerund): a verb form that functions as a noun
The intention in the examples is to talk about the (code) object/thing and not about the (coding) action/process (<PERSON> and <PERSON> mentioned this as well and I think this is an important distinction). Therefore the noun should be used which is "code" and the examples would be correct if the word "Code" would have been used:
"Can I have your (source) code?"
"The (source) code is buggy"
"The (source) code (containing the invalid instructions) was done years ago"
"In this (source) code you can find xyz"
So why would someone use "coding" instead ? I assume this comes from the <PERSON> mentioned in 3) because the <PERSON> by definition is used like a noun. But the meaning of the Gerund is similar to the verb because it aims at the action/process and this is not what the examples try to express. Therefore the usage of "coding" in the examples is wrong.
| 778da55d9f3e613d2d5cc091ebfe9d439dc83174f0c54a15ee2c0821bdbb684c | ['c0b195ad31bd4a4aa863922e5ac3f631'] | Alright, so I'm having this very odd problem, I've tried everything I know and just can't seem to figure out whats causing it. I'm on Xubuntu 14.04.
Randomly my usb wifi dongle will, for lack of a better word, "hang". The flashing LED on it goes stable, network manager reports that I'm still connected to the internet, but I am unable to load webpages. Oddly however is that whenever this occurs, qbittorrent freezes as well and refuses to respond to any clicks or input.
As soon as I unplug my dongle, qbittorrent immediately unfreezes like there never was a problem. Upon replugging the dongle it connects flawlessly to my network.
I noticed this issue started just a little bit after i installed qbittorent, I'm using qbittorent 3.1.9.2 direct from the PPA, I tried downgrading to 3.1.8 from the official repo but to no avail.
iwonfig output
wlan0 IEEE 802.11bgn ESSID:"TP-LINK"
Mode:Managed Frequency:2.437 GHz Access Point: 00:1D:0F:F8:7B:12
Bit Rate=54 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=58/70 Signal level=-52 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:7 Invalid misc:132 Missed beacon:0
sudo lshw -C network output
*-network
description: Ethernet interface
product: 82579V Gigabit Network Connection
vendor: Intel Corporation
physical id: 19
bus info: pci@0000:00:19.0
logical name: eth0
version: 05
serial: 38:60:77:9c:e5:13
capacity: 1Gbit/s
width: 32 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=2.3.2-k firmware=0.13-4 latency=0 link=no multicast=yes port=twisted pair
resources: irq:42 memory:fe400000-fe41ffff memory:fe428000-fe428fff ioport:f080(size=32)
*-network
description: Wireless interface
physical id: 1
bus info: usb@1:1.2
logical name: wlan0
serial: f8:d1:11:09:d2:3b
capabilities: ethernet physical wireless
configuration: broadcast=yes driver=ath9k_htc driverversion=3.13.0-30-generic firmware=1.3 ip=<IP_ADDRESS><IP_ADDRESS> direct from the PPA, I tried downgrading to 3.1.8 from the official repo but to no avail.
iwonfig output
wlan0 IEEE 802.11bgn ESSID:"TP-LINK"
Mode:Managed Frequency:2.437 GHz Access Point: 00:1D:0F:F8:7B:12
Bit Rate=54 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=58/70 Signal level=-52 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:7 Invalid misc:132 Missed beacon:0
sudo lshw -C network output
*-network
description: Ethernet interface
product: 82579V Gigabit Network Connection
vendor: Intel Corporation
physical id: 19
bus info: pci@0000:00:19.0
logical name: eth0
version: 05
serial: 38:60:77:9c:e5:13
capacity: 1Gbit/s
width: 32 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=2.3.2-k firmware=0.13-4 latency=0 link=no multicast=yes port=twisted pair
resources: irq:42 memory:fe400000-fe41ffff memory:fe428000-fe428fff ioport:f080(size=32)
*-network
description: Wireless interface
physical id: 1
bus info: usb@1:1.2
logical name: wlan0
serial: f8:d1:11:09:d2:3b
capabilities: ethernet physical wireless
configuration: broadcast=yes driver=ath9k_htc driverversion=3.13.0-30-generic firmware=1.3 ip=<PHONE_NUMBER> link=yes multicast=yes wireless=IEEE 802.11bgn
lsusb
Bus 001 Device 006: ID 0cf3:7015 Atheros Communications, Inc. TP-Link TL-WN821N v3 802.11n [Atheros AR7010+AR9287]
Also when my dongle is in this hanged state, and attempt at ping or inputting command iwconfig will result in the output never coming, seemingly taking forever, as soon as the dongle is unplugged however, the output to these commands suddenly appears.
|
ea7b4a5430f8a67498edf47d3562a8d15db49edc366cbf6ac0660577e1e5e342 | ['c0b278ec6e0d4eecb17eb78714064565'] | I'm using hibernate 4.2.4 with JPA and layz loading in a ManyToMany association.
Object A is associated with @ManyToMany(targetEntity=B.class, fetch=FetchType.LAZY) and contrariwise. To get data from database I call the following (simplified) code:
try {
session = cutSessionFactory.openSession();
session.beginTransaction();
List<IBO> result = session.createQuery(query).list();
session.getTransaction().commit();
return result;
catch{...}
finally{
session.close;
}
Originally I used to let the connection open, cause if my application needs to do some lazy loading the session is still needed after the first call. But while this made my application freeze after some actions, I chanced to the previous strategy. Now everything works; no freezing, no problem with lazy loading.
But if I load an entity, which has some children (that requieres lazy loading) the log says:
WARN - AbstractPersistentCollection: Unable to close temporary session used to load lazy collection associated to no session
followed by
2013-09-25 09:35:30 - INFO - BasicResourcePool: A checked-out resource is overdue, and will be destroyed: com.mchange.v2.c3p0.impl.NewPooledConnection@15f52a7
2013-09-25 09:35:30 - INFO - BasicResourcePool: Logging the stack trace by which the overdue resource was checked-out
It makes sense that hibernate is not closing the session (actually I thought there is a new request for lazy loading that uses a new session) an the connection pool recognizes there is an unused session. But in the end hibernate is fixing my "bad session handling".
So does anyone know a better way to handle sessions used with lazy loading?
| 27c6273513d7eee3af27f8432fa723c17ad57c077dcf7f389221cd89d57fbd7d | ['c0b278ec6e0d4eecb17eb78714064565'] | I'm using hibernate 4.2.4 with c3p0 <IP_ADDRESS> in a JSF 2.0 application. Everything is working, but if 5 users at once doing some actions inside the application it freezes after a few minutes. Other applications (portlets) inside the same container can still be accessed, CPU and RAM usage is normal.
Perhaps all connections of the c3p0 connection pool are in use and aren't released after usage?! But how can I check, if this is the problem?
Some threads at stackoverflow.com tell to use unreturnedConnectionTimeout and debugUnreturnedConnectionStackTraces. Do I have to put it like the following into my hibernate.cfg.xml?
<property name="com.mchange.v2.c3p0.unreturnedConnectionTimeout">5</property>
<property name="com.mchange.v2.c3p0.debugUnreturnedConnectionStackTraces">true</property>
My hibernate.cfg.xml is:
<property name="current_session_context_class">thread</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
|
f1eb8d9fb74a8d6b8c6280734bed7590ac38b8235409552f4f1516dc9ee61eab | ['c0b55c020f464a2998cb3e654ef40484'] | I have a function -
def add(a, b):
return a+b
Now I want it to add 100 to the result using a decorator such that -
@decorator(100)
def add(a, b):
return (a+b)
class decorator():
def __init__(self, c):
self.c = c
def __call__(self, f):
def _wrapped_f(a, b):
return self.c + f(a, b)
return _wrapped_f
The problem is when I want to keep the extra argument variable and not fixed to 100.
Something like -
@decorator(c)
def add(a, b):
return (a+b)
Can I somehow assign the value of this variable during the function call. (when add function is called)
The reason I want to do this using a decorator is because I don't want to modify my function add.
I cannot afford an extra parameter in function something like -
def(a, b, c=0):
return (a+b+c)
Hence, the need of the decorator.
| 17b6139998717b9757513be528d4fcb57ecf89986a95616316945adf2f7eb00a | ['c0b55c020f464a2998cb3e654ef40484'] | I have to productionize a PyTorch BERT Question Answer model. The CPU inference is very slow for me as for every query the model needs to evaluate 30 samples. Out of the result of these 30 samples, I pick the answer with the maximum score. GPU would be too costly for me to use for inference.
Can I leverage multiprocessing / parallel CPU inference for this?
If Yes, what is the best practice to do so?
If No, is there a cloud option that bills me only for the GPU queries I make and not for continuously running the GPU instance?
|
a7155a46ae5af7003ba1f29204345de2be6b5f5c4673730a8cc2b2218aa957ef | ['c0b7c0c6c7234ec7b51e0d20c14d92c3'] | Есть TextView, нужно вывести отформатированный текст, как в примере, который я прикрепил ниже.
Первые строки делаю с помощью NSMutableAttributedString, NSMutableParagraphStyle, NSTextTab. Все работает, как надо.
Проблема заключается в последней строке "О направлении ...". Как сделать так чтобы с определенного расстояния строка обрезалась и вывод продолжался на новой строке, но при этом другая строка шла справой стороны?
| f9d9a376fcf2a84706119bca553e2fe5ba8b362ec1bf5afd79e9cadceb67e15c | ['c0b7c0c6c7234ec7b51e0d20c14d92c3'] | finally I managed to make GUI with this complete guide(Fix catalyst driver in Ubuntu 13.04 / 13.10), but now there's another problem:
When I try to enter my password and login to Unity (normal without ctrl+alt+f1), is triyng to enter the Unity user interface but with no result(black screen) and kicks me out again to login screen.
I said I fix the problem because I can connect in Unity only with ctrl + alt + f1 then sudo startx command.
|
7bbd6f63f0d0bc8a0312861d20e19f6964a60fc5988e2f18166960eead9dcaca | ['c0b85c6e91ba44afbc8df40fa7b789d5'] | please could anyone help with advice on how to do this using the API? I am looking to use some javascript to call our agent first on their SIP address and then start outbound calling the customer on their PSTN number from the agent.
The snippet below will achieve it, but in the wrong order as it sets up the customer call first, waits until they answer, and then calls the agent SIP client.
I want to call the agent first, wait until they answer, then call the customer.
This is a 121 call, not a conference so I don't think I can use that method because if the agent hangs up I want the call to end completely.
Many thanks!
client.calls
.create({
to: '+44xxCUSTOMERNUMBERxxxxx',
from: '+44xxxCALLERIDxxxx',
twiml: '<Response><Dial><Sip><EMAIL_ADDRESS>;region=ie1</Sip></Dial></Response>'
})
.then(call => console.log(call.sid));
| a47da6eb62182e4fc9a3283cd13842019f777bec1b041a89714a1efc3a984093 | ['c0b85c6e91ba44afbc8df40fa7b789d5'] | I'm using puppeteer to try and scrape an image off a live cctv stream at an address like: <IP_ADDRESS>/display_pic.cgi?cam=6&res=low
The issue is that the page is continuously loading as it is a live stream.
Puppeteer eventually errors as a timeout when you load the page. Is there a way to get round this, force a screenshot and then close the page?
An example stream is here http://<IP_ADDRESS>/display_pic.cgi?cam=1&res=low
Thanks in advance!
|
48456c10747c462ac68c2ea2e286eb8a8a0ab5169c3af7bfe91ec4088f3889cd | ['c0cdc21817c349f3a471a26c672df2aa'] | I'm currently looking for a way to open an external application that's located in the userprofile folder. This is my current codes:
Dim p As New ProcessStartInfo
'program function'
p.FileName = "%userprofile%/folder/app.exe"
Process.Start(p)
I got no luck so far. If anyone knows how to do this that would be nice
| d9e50a8f91a98587feeefbd0c4dfe73c0edaf30019b47a829103313a24a4b1a6 | ['c0cdc21817c349f3a471a26c672df2aa'] | I have figure out a way to keep the form on top of the taskbar. To do this, you must have the form set as top most:
me.topmost = true
Next, you want to create a timer and have the interval to be 1. The timer will constantly keep the start button focused:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Me.Focus()
End Sub
That's it, the form will stay on top of the taskbar even if the taskbar becomes focused.
|
3773d33d53694e362ca5342bc95b23bb43a7eb82af23142a70f2acb019dffc31 | ['c0d06f81d8fc47089d41b5c88023e536'] | If I want to deploy on Amazon IaaS, I could deploy directly with our containerized release IIS deploying its own K8s/docker environment. However, if we wanted to lay down ICP first on Amazon IaaS, and then install DataStage (ultimately IISEE next release) - is this supported? My customer is only interested in moving IISEE to Amazon IaaS - but most run in containers.
| b8080ba0d50d0cd86881f5901268b31373556b98616efc09e20f3d42b933911d | ['c0d06f81d8fc47089d41b5c88023e536'] | We have master reference data tables that I can -
Define the table to Information Analyzer
Profile the data in the table
Define values in this table as values for a reference data table
Use these values in the project to check other table column values
What I would like to know is -
where can you see a catalogue of these tables
administer and publish this content
where can I see it as an asset in business glossary
if I can see the reference table asset in BG can I browse the values of the table
As far as I can see the answer to all those points is you can’t is this correct ?
|
d9361839d33e8d3d36e4b735e0022753c45dc1bcf8551b0a8657e26a9b853e30 | ['c0d1a49efc4e4e888012938a4b2b43b9'] | Ok, here's the solution I came up with:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
namespace YourName {
// Represents a writer that makes it possible to pre-process
// XML character entity escapes without them being rewritten.
class XmlRawTextWriter : System.Xml.XmlTextWriter {
public XmlRawTextWriter(Stream w, Encoding encoding)
: base(w, encoding) {
}
public XmlRawTextWriter(String filename, Encoding encoding)
: base(filename, encoding) {
}
public override void WriteString(string text) {
base.WriteRaw(text);
}
}
}
then using that as you would XmlTextWriter:
XmlRawTextWriter rawWriter = new XmlRawTextWriter(thisFilespec, Encoding.UTF8);
rawWriter.Formatting = Formatting.Indented;
rawWriter.Indentation = 1;
rawWriter.IndentChar = '\t';
xmlDoc.Save(rawWriter);
This works without having to un-encode or hack around the encoding functionality.
| 06c09b858f892b654de13dfa4e0a3f586d1b2b9232be7fad41999ca9d5c5c0a3 | ['c0d1a49efc4e4e888012938a4b2b43b9'] | After putting this on the back-burner for a while, the answer became apparent:
Although you can't easily override the Read() method to change the read value, you can hook the property accessor to do the same thing:
using System;
using System.Collections.Generic;
using System.Xml;
namespace blah {
class XmlCustomTextReader : XmlTextReader {
private Func<string, List<KeyValuePair<string, string>>, string> _updateFunc;
public XmlCustomTextReader(string fileName, Func<string, List<KeyValuePair<string, string>>, string> updateFunc = null) : base(fileName) {
_updateFunc = updateFunc;
}
//
// intercept and override value access - 'un-mangle' strings that were rewritten by XMLTextReader
public override string Value {
get {
string currentvalue = base.Value;
// only text nodes
if (NodeType != XmlNodeType.Text)
return currentvalue;
string newValue = currentvalue;
// if a conversion function was provided, use it to update the string
if (_updateFunc != null)
newValue = _updateFunc(currentvalue, null);
return newValue;
}
}
}
}
Use this by:
Func<string, List<KeyValuePair<string, string>>, string> updateFunc = UpdateString;
XmlCustomTextReader reader = new XmlCustomTextReader(fileName, updateFunc);
reader.XmlResolver = new XmlCustomResolver(XmlCustomResolver.ResolverType.useResource);
XDocument targetDoc = XDocument.Load(reader);
I hope this helps someone in the future...
|
f19d70979e767f5454ab20d2d2d2da60ce0fe667de078f085b436f3da289df83 | ['c108fbec58864c4fbeae7ae9ebe2cc79'] | I am not sure if I know what I'm doing: I am trying to backup "Integration Services Catalogs", seen in the picture below.
But all the instructions I get is to backup the SSISDB database. All I am familiar with is the catalog, that's where I go to "execute" my packages.. I know executing is just running some commands/script to run SPs within SSISDB database, but 1) if I was to make a backup of SSISDB, would that also give me a full backup of the catalog too?? How so? So restoring the DB would give me back my catalog ???
If the answer is yes, why do I need to BACKUP MASTER KEY Transact-SQL statement as part of the backup procedure (according to my studies), wouldnt this just be a simple DB backup???
Thank you very much in advance
| 49743cdee3c4f032ba0952ccbadb9a022fcf01160ca4b5bf2b76f2befd3c7750 | ['c108fbec58864c4fbeae7ae9ebe2cc79'] | This whole "visual C#" has caused me much unnecessary grief (including one during an interview , given I had never heard of the term 'visual C#' and apparently the interviewer didn't even know what it was and was just trying to put checkmark beside qualifications). To sum, Visual C# doesn't exist. It's just C#, we should file a petition to remove that stupid qualifier.
|
7783bb6468308a8a1cd3015bff28dbc331e837db89c4e0c8692d084446e875ea | ['c11225fce3ad43d0a605401983c51dd0'] | Berlekamp-Massey is designed for the situation where you have observed $2n$ consecutive output bits from a $n$-bit LFSR. It doesn't work if the observed bits are scattered randomly, at random non-contiguous offsets in the stream.
Information-theoretically, a minimum of $2n$ bits of output are needed to reconstruct the LFSR. Intuitively, this is because there are $2n$ bits of unknowns: the unknown $n$-bit state of the LFSR, and the unknown $n$ bits on the taps (the feedback polynomial). Therefore, Berlekamp-Massey exactly meets the known lower bounds, in the case where you get to observe consecutive output bits.
Of course, you could also have used linear algebra to solve for these $2n$ unknowns, but Berlekamp-Massey is faster than solving a system of linear equations ($O(n^2)$ instead of $O(n^3)$, or something like that).
The number of observations you need depends only on the size of the LFSR, not on the output bits. If you do know the size of the LFSR, you don't need to see any output bits to predict how much output will be needed. If you don't know the size of the LFSR, seeing a few output bits doesn't help you predict the size of the LFSR and doesn't help you predict how much output will be needed.
One cool thing about Berlekamp-Massey, though, is that you don't need to know in advance what the size of the LFSR is (what $n$ is). You can just start running Berlekamp-Massey on the output stream, and it will generate candidates for the LFSR initial-state and feedback polynomial. After each bit of output, it will update its candidate. Once you've observed $2n$ bits of output, you are guaranteed that its candidate is correct. If you don't know what $n$ is, you can take each candidate and test it against the next few output bits; this will let you recognize when Berlekamp-Massey has finally found the right candidate, i.e., when you've observed enough output stream (it'll let you recognize when you've hit the $2n$ limit, even though you don't know $n$ a priori).
| 6fa75fac4870828d03c87cf83cb886817a72ea796f0295678b797161d89dbe79 | ['c11225fce3ad43d0a605401983c51dd0'] | The standard answer in the research literature is to use information-theoretically secure message authentication codes, typically universal hashing (aka Carter-Wegman authenticators). Of course, you could use computationally-secure message authentication codes, like CMAC or HMAC, if you wanted, though that would partly defeat one of the reasons for using QKD.
That said, in practice QKD is a bit silly. QKD solves a problem that most people don't have, so it is basically a fancy useless toy (albeit a very expensive one). If you're considering using QKD in some practical deployment, my advice is: skip the QKD, and just use a TLS or IPSec VPN. There, I saved you $50,000; don't spend it all in one place!
|
fea66232c88927919b0bf394223b562050b9929cd4c259cd8e70f6cbb51260ed | ['c1235726287c4025bea68637d0d4c719'] | I have a problem with this code, the mouseleave function is firing on IE without the mouse entering first in the div.
<script type="text/javascript">
$(document).ready(function() {
$('#<?php echo 'div_'.$reload_cont; ?>').mouseenter(function() {
var el = $(this);
var timeoutId = setTimeout(function() {
$('#<?php echo 'relo_'.$reload_cont; ?>').animate({opacity: 1}, 'slow');
}, 500);
el.mouseleave(function() {
clearTimeout(timeoutId);
$('#<?php echo 'relo_'.$reload_cont; ?>').animate({opacity: 0}, 'slow');
});
});
});
</script>
I've tryied a lot of ways and none seems to work.
Any help here
| 6fefd465374d91b8189c82cb0b0a4ebddd9e0e9e3f9d53e628ec8ef544ed8fab | ['c1235726287c4025bea68637d0d4c719'] | I have a dynamic table with some test just before it, I am having some problems printing this (on actual paper), sometimes the table starts in the new page, so my first page is just the header test and then the table on the second. I have tried with page-break-before: always; and several possible combinations of the page-break properties without luck.
Does anyone know how can I force the table to start printing right at where it is on the page?
Forgive the bad english :)
|
c879d30bd7b84966a46c7917ccbfd4894606481ed9fabbd61c960e1ad4f7e8b4 | ['c13e4123232442af98a0afda13763812'] | Try below script:
Assuming, you have count values in A1 in both sheets, if not then change your range accordingly in getRange(1,1)
function appendName() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
for (var i=0;i<sheets.length;i++){
var oldName = sheets[i].getName();
var getcountName = sheets[i].getRange(1,1).getValue();
var re = /\W\d+/ ;
var oldNameReset = oldName.replace(re , '') ;
var setNewName = sheets[i].setName(oldNameReset + "-" + getcountName);
}
}
Set trigger On Change
| 83fb7488d2594a4080758a40400f0a00a992974255a6c0123907dd47cf18bdfa | ['c13e4123232442af98a0afda13763812'] | I am trying to fetch this website (https://www.covidhotspots.in/?city=Mumbai&source=share) data using Importxml in Google Sheets but it gives me no data.
I am trying to apply below formula but it is giving me #NA
=IMPORTXML("https://www.covidhotspots.in/?city=Mumbai&source=share","//li/text()")
I want to fetch geocodes as mentioned in the below images
|
a37c43c5ba713166176183695974ce1f3f52b530b34e230b29e78073ad3d6891 | ['c14003f6bfb4442cb50ce73e16cf2e1e'] | right now i have a transparent bootstrap navbar with some content in it.
css
.navbar {
/*background-color: #0B76BC;*/
background: transparent;
background-image: none;
color: #F5F5EF;
border: 0;
z-index: -100;
}
even though my navbar is transparent the content inside is not. but now the items are no clickable. So my question is it possible to have items still functioning on a transparent bootstrap navbar?
| bb21ff151d1d923cf3a93373811b88b86170523fe767ac27aab6ad03d6183cef | ['c14003f6bfb4442cb50ce73e16cf2e1e'] | I am so new to NodeJS, but am trying to write a function that checks if a port to see if the port is live and running.
IF the port is running/live do nothing and check again in 3 mins.
ELSE reset the area that the NODEjs code is in.
thanks!!
|
29587d55be6f7262cb04ad874523303cf653278030878ec229c17f9a21773cd5 | ['c143161c93f94ac0885266bf68cfb985'] | In the chapter of Professional JavaScript for Web Developers on OOP, <PERSON> describes a JavaScript inheritance pattern which he refers to as combination inheritance. The basic idea is that methods are inherited via prototype chaining; whereas parent properties are passed on to descendants by calling the parent constructor within the child constructor.
A small example:
function Parent() {
this.parentProperty;
}
Parent.prototype.parentMethod = function() {
console.info(parentProperty);
}
function Child() {
Parent();
}
Child.prototype = new Parent();
He concludes his discussion by saying that "combination inheritance is the most frequently used inheritance pattern in JavaScript."
However, in his following discussion on the prototypal inheritance pattern, he mentions a shortcoming of combination inheritance, namely that the child type invokes the parent constructor twice: once when creating the prototype and then again in the constructor.
My question is why does the combination inheritance pattern suggest extending the prototype by having the child's prototype be an instance of the parent type, why shouldn't it just reference the parent's prototype directly? Using the previous example, why not just do the following:
Child.prototype = Parent.prototype;
| 437138752328f93e4967bd0c557af96cf049a771a874f6a798a148df4646297a | ['c143161c93f94ac0885266bf68cfb985'] | I once saw a paper written by <PERSON> and other than the fact that it was missing a bunch of modern math terms (obviously) you could almost be forgiven for thinking it was written yesterday, it was quite remarkable when you compare it with some other literature from similar times, some of which can be quite incomprehensible |
67dbaede6d1327acf9d5da154e62aa4e65b8de3ba633adb735ed4d82791f7c51 | ['c159b0c34836449390ff8bd9af4b278b'] | I tried Sketchup to sketch a home design but I find the controls a bit frustrating. I can sketch 10 times faster in The Sims 3, plus it is nicer to look at. Though the metric system may not be 1:1 ratio to reality but it's close, maybe 15%-20% off but this is a just a sketch, right?
Anyway, is there any software that does home design like The Sims 3? The same ease of use but at a more professional level and a real metric system?
| 5555b01726f5c10cd04d5ee78c57c26283ce46136ce85f7c4cc677a104da7a24 | ['c159b0c34836449390ff8bd9af4b278b'] | @unknowndomain: because of the number of functions in the `Preferences > Security` and `Preferences > Privacy` settings. These are functions that are usable by beginners and advanced users. To give you 2 (from my point of vue) winning settings :[return] `Privacy > ☐ Allow remote content in messages`, [return]` `Security > Junk > √ Enable adaptive junk filter logging`. |
31dd4a830d94b82d890e9d90ab6cb4cb4168334302a206f4c09f49607760f524 | ['c16a02048418469fa988a6ed110e583b'] | I have 3 vectors, A, B, C. They all have the same number of rows. What I am looking for is the all possible combination of summation of vectors. For this example, I want to have A+B, A+C, B+C, and A+B+C. Is there any command/package in R that can do that? In another words, I want all possible linear combinations of the 3 vectors with linear coefficients of 1. My real problem involves a lot of vectors, not just 3. I simplified it here.
Thanks
| 0818ba1ce1add55c91f92730bb8be9aa91d71a76c6d04ca1cc2e61bfb97c23a9 | ['c16a02048418469fa988a6ed110e583b'] | I am trying to write a file in a loop in R. I want to append the file as we go through the loop. I tried append=true but didn't work. I have explained the problem with details here. Any idea? thanks for your help:
#Initilaizing 2*2 array
Array1 <- array(0,c(2,2))
for(i in 1:5)
{
#Create 4 random numbers
Random1 <- runif(1, min=0, max=1)
Random2 <- runif(1, min=0, max=1)
Random3 <- runif(1, min=0, max=1)
Random4 <- runif(1, min=0, max=1)
#Assign Random numbers to the array
Array1[1,1] <- Random1
Array1[1,2] <- Random2
Array1[2,1] <- Random3
Array1[2,2] <- Random4
#*****This is the Question*******
# I want to keep the history for Array1 through the 5 loops by writing the array in a file.
# and appending the file as we go through the loop
# I tried write.csv with Append=true but didn't work
# How can I do this?
}
|
947e54c64430a78b463e5387cf2d5f1c62a6908a377edfe35fb28a943e863a58 | ['c16bdc4e05b24021a45781d7bb2e043b'] | I have built a Phonegap Build app and run into a bit of a bug. I've created all the appropriate images and referenced them in my config.xml file.
However for some reason they are not showing in iPhone 6, 6s or 6+. All other sizes seem to show the splashscreen without any issues. here's my code...
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.myapp.app.com.app.myapp"
versionCode = "10"
version = "1.0.8"
ios-CFBundleVersion="1.0.17" >
<!-- versionCode is optional and Android only -->
<name>My App</name>
<description>
My App
</description>
<author href="http://www.myemail.co.uk"" email="<EMAIL_ADDRESS>">
<PERSON>
</author>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="3000" />
<preference name="orientation" value="portrait" />
<preference name="DisallowOverscroll" value="true" />
<!-- iOS -->
<!-- iPhone / iPod Touch -->
<icon src="app/img/icons/apple-touch-icon-57x57.png" gap:platform="ios" width="57" height="57" />
<!-- iPhone 6 / 6+ -->
<icon src="app/img/icons/apple-touch-icon-180x180.png" platform="ios" width="180" height="180" />
<!-- iPhone / iPod Touch -->
<icon src="app/img/icons/apple-touch-icon-60x60.png" platform="ios" width="60" height="60" />
<icon src="app/img/icons/apple-touch-icon-120x120.png" platform="ios" width="120" height="120" />
<!-- iPad -->
<icon src="app/img/icons/apple-touch-icon-72x72.png" platform="ios" width="72" height="72" />
<icon src="app/img/icons/apple-touch-icon-76x76.png" platform="ios" width="76" height="76" />
<icon src="app/img/icons/apple-touch-icon-152x152.png" platform="ios" width="152" height="152" />
<icon src="app/img/icons/apple-touch-icon.png" />
<!-- -->
<platform name="ios">
<!-- iPhone and iPod touch -->
<splash src="app/img/splash/320x480.png" platform="ios" width="320" height="480" />
<splash src="app/img/splash/640x960.png" platform="ios" width="640" height="960" />
<!-- iPhone 5 / iPod Touch (5th Generation) -->
<splash src="app/img/splash/640x1136.png" platform="ios" width="640" height="1136" />
<!-- iPhone 6 -->
<splash src="app/img/splash/750x1334.png" platform="ios" width="750" height="1334" />
<splash src="app/img/splash/1242x2208.png" platform="ios" width="1242" height="2208" />
<splash src="app/img/splash/2208x1242.png" platform="ios" width="2208" height="1242" />
<!-- iPhone 6S -->
<splash src="app/img/splash/1080x1920.png" platform="ios" width="1080" height="1920" />
<!-- iPad -->
<splash src="app/img/splash/768x1024.png" platform="ios" width="768" height="1024" />
<splash src="app/img/splash/1024x768.png" platform="ios" width="1024" height="768" />
<!-- Retina iPad -->
<splash src="app/img/splash/1536x2048.png" platform="ios" width="1536" height="2048" />
<splash src="app/img/splash/2048x1536.png" platform="ios" width="2048" height="1536" />
</platform>
<platform name="android" />
<splash src="splash.png" />
<plugin name="cordova-plugin-whitelist" source="npm" />
<plugin name="cordova-plugin-splashscreen" source="npm" />
<plugin name="cordova-plugin-splashscreen" spec="3.2.2" />
<plugin name="cordova-plugin-whitelist" spec="1.2.2" />
| ba0fb509c218dba48c879fef2c6ff9cb3f35e1574abebb4ada2d0b95692e9795 | ['c16bdc4e05b24021a45781d7bb2e043b'] | I have a table items with columns item_id, lockup_id, date, archive. I need to be able to go through the lookup_id column and identify duplicates, changing the archive value to 1 on every duplicate EXCEPT the newest entry in the table.
item_id Lookup_id date archive
------------------------------------------------
1234 4 1-1-19 0
1235 4 1-1-19 0
1236 4 1-1-19 0
1237 2 1-1-19 0
1238 1 1-1-19 0
1239 1 1-1-19 0
I've so far managed to find the duplicates using the following statement, but I'm at a bit of a loss where to go with this to achieve my desired result.
'SELECT `item_id` , `lookup_id`, `date`, `archive`
FROM items
WHERE `item_id`
IN (
`SELECT `item_id`
FROM items
GROUP BY `item_id`
HAVING COUNT( `item_id` ) >1
)
ORDER BY `item_id`;
|
f85f807a5707bbdab9dad0b4050deec80a5d7430b84b7a6a2b54013b2b9fedf0 | ['c188976ed3f14097bff1ef3b7a731e26'] | I just don't come up with an idea how to do the following:
In my html-document i have two elements of the class "modal" (the bootstrap modal class).
The one modal must have a z-index of -5 and the other 10.
How could I achieve this?I suppose that I could use IDs,but I have no idea how exactly to write the code...
Thank you !
| 0de488df2c00c8d139e3c95cba257a319f63d082192eafc5407451f1d1994dfa | ['c188976ed3f14097bff1ef3b7a731e26'] | I am new to GUI programming with java and some questions occured in my head. I am learning now the MVC-pattern and I was wondering how the implementation of a JFrame with a button to create squares on click would look like .
What I want to do is : I have a Frame and a button, the button is pressed and a new square is randomly positioned on the screen, then i can drag it around in the frame and change its position and the console has an output : Square1 was moved to X Y (coordinates);
Then ,if the button is pressed again, a new square is created (Square2). When I drag it, the console says : Square2 was moved to X Y .
Any suggestions what I should do in order to make that possible ?
I know that my model is actually the square and its properties.My view is actually the JFrame with the button. But I do not know how to implement the controller, so that I can get the console outputs for the different objects..
Thank you !
|
7d4aab70ad3cfcc64fa1f9242133a9f2c33296e493790aa5e67901c02300685a | ['c189b44bd1c54124a8783cd086c575a7'] | The following text is written in my textbook and I don't really understand it:
If $A = (a_{ij}) \in$ Mat$(m x N, F)$ is a matrix in reduced row echelon form with $r$ nonzero rows and pivots in the columns numbered $j_1 < ... < j_r$, then the kernel ker$(A)$ is generated by the $n-r$ elements $ w_k = e_k - \sum\limits_{1 \le i \le r, j_i \le k} a_{ik}e_{j_i}$ for $k \in {1, \cdots , n} \ {j_1, \cdots, j_r}$, where $e_1, \cdots, e_n$ are the standard generators of $F^n$.
There are no computational examples and the notation is a bit overwhelming so I don't know how I can use it. Can somebody give an example of this in practice?
| 26572c72f7640535d74c19ca6c5cc6471d6d46530e8f2718441d695d50787823 | ['c189b44bd1c54124a8783cd086c575a7'] | You can use one of those three commands. Read the man or info pages for more information.
uptime - Tell how long the system has been running.
w - Show who is logged on and what they are doing.
top - display Linux processes
All three commands show you the load average information. top is probably the best choice as it displays information about CPU usage, memory usage, priority, etc.
I cite from a reference of a course:
Load average is the average of the load number for a given period of
time. It takes into account processes that are:
Actively running on a CPU.
Considered runnable, but waiting for a CPU to become available.
Sleeping: i.e., waiting for some kind of resource (typically, I/O) to become available.
I cite further about interpreting load average:
The load average is displayed using three different sets of numbers,
as shown in the following example:
The last piece of information is the average load of the system.
Assuming our system is a single-CPU system, the 0.25 means that for
the past minute, on average, the system has been 25% utilized. 0.12 in
the next position means that over the past 5 minutes, on average, the
system has been 12% utilized; and 0.15 in the final position means
that over the past 15 minutes, on average, the system has been 15%
utilized. If we saw a value of 1.00 in the second position, that would
imply that the single-CPU system was 100% utilized, on average, over
the past 5 minutes; this is good if we want to fully use a system. A
value over 1.00 for a single-CPU system implies that the system was
over-utilized: there were more processes needing CPU than CPU was
available.
If we had more than one CPU, say a quad-CPU system, we would divide
the load average numbers by the number of CPUs. In this case, for
example, seeing a 1 minute load average of 4.00 implies that the
system as a whole was 100% (4.00/4) utilized during the last minute.
Short term increases are usually not a problem. A high peak you see is
likely a burst of activity, not a new level. For example, at start up,
many processes start and then activity settles down. If a high peak is
seen in the 5 and 15 minute load averages, it would may be cause for
concern.
|
5b368a563f7b941042b5c4584ab2da9d4135b412f2c732da27d15e95bfcc3967 | ['c1a9d7e347f542f08a39db6fee8a2ca9'] | I have setup Bamboo to run JBehave tests on a remote agent (with JBehave-web plugin launching test using webdriver), and everything runs fine. Only problem is after the execution is finished Bamboo shows no test executed. I can see the option in Bamboo to select the output of the test results, but it has to be a JUnit xml, and Jbehave reports are only generated in plain text or html.
Any idea how to solve this?
Thanks
| 9a800660d75c3692e069aded999cc75036dadbef0e8b629eef29b45a5d7e33ed | ['c1a9d7e347f542f08a39db6fee8a2ca9'] | The way you did it is correct, because it assumes that project B will be using the dependency of project A that will be in the artifactory, so you can develop both independently.
And anyway, for the project A, if you are using maven, don't you use maven clean install for compiling and deploying? That way you are sure you always have the latest version
The other option is, in case both of the are more dependent of each other, you should consider make one of them as a module of the other, or maybe make a project C that contains both modules, but that would mean both of them are part of the same project (like an ear containing two jars), depends on the situation
|
9d0999045f3bb4142b2c5a6ba85f7003ff72c015a10d1806aa7c0ac502b0d0fc | ['c1b7e76f7b904117a2641d37154ac23f'] | I am trying to get the current index of the letter that typed in during OnKeyDown event.
For example, if I have a text in RichEdit Control as "MOVS,21"
I would like know the index of "(" when I change the string to "MOV(S,21" in the event "OnKeyDown".
Is there any way I can get this index? Appreciate your help.
regards,
<PERSON>
| 44ef0fdcf0cb6eb60be3b1e0e5a7dfdf45caf268ef97802be1c475c3272643b4 | ['c1b7e76f7b904117a2641d37154ac23f'] | I have a generic list of integer and it contains random numbers. How would I select the last n elements from the list using LINQ?
I know can use myList.GetRange(index, count) to get the last n elements from the list. Is there a way to do it in LINQ?
THanks
regards,
<PERSON>
|
e50038613db07877017cb0b78410d39d7e3f3d3b09a6a24847ca03274dac984b | ['c1c05346fecc4412b6a57a31bb93213d'] | Hi Am trying to keep a image and text in a div side by side with background color green am able to keep but the image is not at the right place so when am trying to match it with the text am unable to do it
Here is the code u can run code and see
<div style="background-color:#4CAF50;display:inline-table;height:20px;margin-top:60px;padding:5px;border-radius:100px;margin-right:10px;">
<a href="www.google.com" style="text-decoration:none;color:white;"><img src="https://i.imgsafe.org/12c0e780d9.png" style="width:20px;height:20px;" alt="tag"><span style="margin-left:8px;font-weight:bold">Get The Code</span></a>
</div>
The jsfiddle link is here
https://jsfiddle.net/cmbaf2p3/
| b5a09e2a6057573dc9ce7b780b6b09196e5eb713b6a433834154a99313e9bd58 | ['c1c05346fecc4412b6a57a31bb93213d'] | Hi am using visual code to run project here are my codes
external.js
export let keyValue=1000;
script.js
import {keyValue} from './external.js';
console.log(keyValue);
Then I have command to run file as node script
Then its showing the below error when I run node script in visual code
F:\es6-examples\modules-classes\script.js:1
(function (exports, require, module, __filename, __dirname) { import
{keyValue} from './external.js';
^
SyntaxError: Unexpected token {
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:236:19)
Here is screenshot
|
b3872b76213a614be06ce9a129c1f30f6a62eb3e5b1e99f2be49b257f7df3c1c | ['c1c25398199d48778ed0afcc05e46969'] | thanks so much <PERSON>. one thing to add-- i was getting a weird error at the commandline:
ERROR: transport error 202: connect
failed: Connection refused ERROR: JDWP
Transport dt_socket failed to
initialize, TRANSPORT_INIT(510) JDWP
exit error
AGENT_ERROR_TRANSPORT_INIT(197): No
transports initialized
[../../../src/share/back/debugInit.c:708]
FATAL ERROR in native method: JDWP No
transports initialized,
jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Aborted!
this can be avoided by just taking out the agentlib argument:
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:56431
| e775f57ffc3312d2268676ae0bb0126716541e1c65095cdde529ecb854cb60c6 | ['c1c25398199d48778ed0afcc05e46969'] | The lists print out backwards because as you are packing the OUTER elements into the new list FIRST. As you continue to unwrap A, you add a wrapping to C.
The cleanest way to duplicate these lists might be to do a deepcopy of A and B (we'll call them C and D), and then set the deepest element in C (found by traversing until C.next==None) to reference D.
|
031906ae1100185a655e38c0310be20726581eed66f44cd7df00d40d98623475 | ['c1c6afc97c5a44c9a8cd420438813318'] | First of all, all your types must implement a common interface that define properties like Active, Value ...
Also, for what I can tell, there must be a repository interface for all repositories independently of the MyType so that you can use a generic method like this. The GetAll() method should be defined in the IRepository.
public interface IRepository<T> where T : IMyType
{
IList<T> GetAll();
}
public class RepositoryFactory
{
public static IRepository<T> createRepository<T>(ISessionBuilder sb) where T : IMyType
{
// create repository
}
}
public interface IMyType
{
bool Active { get; }
string Value { get; }
}
private static IList<T> GetList(RequestForm form) where T : IMyType
{
// get base list
IRepository<T> repository = RepositoryFactory.createRepository<T>(new HybridSessionBuilder());
IList<T> myTypes = repository.GetAll();
// create results list
IList<T> result = new List<T>();
// iterate for active + used list items
foreach (T myType in myTypes)
{
if (myType.Active || form.SolutionType.Contains(myType.Value))
{
result.Add(myType);
}
}
// return sorted results
return result.OrderBy(o => o.DisplayOrder).ToList();
}
| bbf5ae2ea87a1b6a71a28c88ce5f9b7e4b5757357e5fe17450a2aa2c01a3b73f | ['c1c6afc97c5a44c9a8cd420438813318'] | Here's my implementation:
public static int commonChars(String s1, String s2) {
if (s1 == null || s1.isEmpty())
throw new IllegalArgumentException("Empty s1");
if (s2 == null || s2.isEmpty())
throw new IllegalArgumentException("Empty s2");
char[] a1 = s1.toCharArray();
char[] a2 = s2.toCharArray();
Arrays.sort(a1);
a1 = removeDups(a1);
Arrays.sort(a2);
a2 = removeDups(a2);
int count = 0;
for (int i = 0, j = 0; i < a1.length && j < a2.length;) {
if (a1[i] == a2[j]) {
i++;
j++;
count++;
}
else if (a1[i] > a2[j])
j++;
else
i++;
}
return count;
}
public static char[] removeDups(char[] array) {
char[] aux = new char[array.length];
int c = 1;
aux[0] = array[0];
for (int i = 1 ; i < array.length; i++) {
if (array[i] != array[i-1])
aux[c++] = array[i];
}
return Arrays.copyOf(aux, c);
}
|
45cfb5ff96c33eef42ddc5d4e019b3c342eac4fd9692d8afb9163d96a965f823 | ['c1d05afabb8e4c78868421e12c7b58cf'] | The first script below calculates the total based on the ACF pricing field in the WordPress dashboard and the percentage input by the user:
$(function(){
$('#percdown').on('input', function() {
calculate();
});
function calculate(){
var parcPrice = <?php the_field('parcel_price'); ?>;
var downPerc = parseInt($('#percdown').val());
var perc="";
if(isNaN(parcPrice) || isNaN(downPerc)){
perc=" ";
} else{
perc = ((parcPrice*(downPerc/100)).toFixed(2));
}
$('#AMT').val(perc);
}
});
This second script disables the submit button unless the percentage is between 10 and 100, and doesn't display the alert until someone has moved the cursor to the next field (tab or click outside):
$('#percdown').change(function() { // When value of total one is changed
if ($('#percdown').val() > 10 && $('#percdown').val() < 100 ) {
$("#SubmitBtn").removeAttr("disabled");
}
else {
$("#SubmitBtn").attr("disabled", "disabled");
alert("Please enter a value above 10");
}
}
);
| 3ab9017979ac268bbd26a92737c5384c12e82129b055ac6834494e321495125f | ['c1d05afabb8e4c78868421e12c7b58cf'] | So the problem I was facing wasn't an error with the code, but it was two of the 50 post didn't have an assigned featured image, which caused the grid alignment to break.
Thank you for bearing with a Stack Overflow newbie here and I will keep your community guidelines in mind for future posts.
|
5b06ae61a8239ed853bcbf55d5c8ee56ba35f17d143190093c580bfb8f5f6fae | ['c1e1a59007ec4ec5a2aa638eecf1ec93'] | I have a dynamical system in three dimensions given by:
$\dot x = (1-x^2-y^2-z^2)x+xz-y$
$\dot y = (1-x^2-y^2-z^2)y+yz+x$
$\dot z = (1-x^2-y^2-z^2)z-x^2-y^2$
I analyzed the system by first finding the fixed points which are at (0,0,0) , (0,0,1) and (0,0,-1).
Next, I found the Jacobian of the system and for each fixed point, I computed the eigenvalues of the Jacobian matrix.
For the fixed point (0,0,0), $\lambda = 1, 1+i, 1-i$
For the fixed point (0,0,1), $\lambda = -2, 1+i, 1-i$
For the fixed point (0,0,-1), $\lambda = -2, -1+i, -1-i$
Hence, (0,0,0) is unstable since the eigenvalues are positive. (0,0,1) is unstable since the real part of the complex eigenvalue is positive. (0,0,-1) is negative since the eigenvalues are negative.(i.e. real part of complex eigenvalues are negative).
Is there anything else I can say about the long term behavior of this system?
| 3bc892eb3e7e706c89263745bdcced981d658bdf6ff8b29b25f7883a6738128d | ['c1e1a59007ec4ec5a2aa638eecf1ec93'] |
There is no universal, or widely approved naming convention
Since there are 3 application layers where the abstraction of Person is present, you may simply distinguish them by namespaces, although this appoach may lead to confusion
In my opinion the most verbose approach would be the following:
Person - for domain/business logic layer
PersonEntity - for data access / entity framework layer
PersonViewModel - for presentation layer
|
50ce6ddf642394c463bda2d42cd90f20f2a1ccc84500a2d4143f61c8d905412b | ['c1e42e5ea9e345128c4cbd244ba71f7e'] | What is store in your code. After fixing this bug, it works
#!usr/bin/env/python3.6
# imports
import numpy as np
import random
# Generated random matrix of 25 spaces,
# where placed ramdom number between 0 to 255,
# and store in a variable.
matrix = np.random.randint(33,255, size=(5, 5))
# This shows the matrix of integer numbers.
print(matrix) # Good!!!
# This translate matrix of number to ASCII table symbols:
for col in range(5):
for row in range(5):
print(chr(matrix[row][col]), end=' ')
print('\n') # Solved, my honey.
The output is-
[[ 86 159 40 221 211]
[166 224 213 252 160]
[155 160 111 109 164]
[ 98 190 34 250 40]
[115 228 59 139 221]]
V ¦ b s
à ¾ ä
( Õ o " ;
Ý ü m ú
Ó ¤ ( Ý
| 06799a7e95b647525e5a994d6bf31c71949033f558a50b2114c6070c01badba5 | ['c1e42e5ea9e345128c4cbd244ba71f7e'] | string a= "Stack Overflow";
char b[]= "Stack Overflow";
cout<<sizeof(a)<<","<<sizeof(b)<<endl;
Output of above code is 4,15
Since 'a' points to the string, it has size 4 that of a string on my machine.
'b' is also pointer to string, but why it has size of 15 (i.e. of sizeof("Stack Overflow")) ?
|
14213a5509bc178e35658684eb5446999d7ed5f7a7b2f954fb05c973deede711 | ['c1ee9c84f29d44e0ba1e1d5a7e66feb8'] | This this :
library(dplyr)
library(nycflights13)
data(flights)
flights %>%
filter(carrier =="UA")
# A tibble: 58,665 x 19
# year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum
# <int> <int> <int> <int> <int> <dbl> <int> <int> <dbl> <chr> <int> <chr>
# 1 2013 1 1 517 515 2 830 819 11 UA 1545 N14228
# 2 2013 1 1 533 529 4 850 830 20 UA 1714 N24211
# 3 2013 1 1 554 558 -4 740 728 12 UA <PHONE_NUMBER> N39463
# 4 2013 1 1 558 600 -2 924 917 7 UA 194 N29129
# 5 2013 1 1 558 600 -2 923 937 -14 UA 1124 N53441
# 6 2013 1 1 559 600 -1 854 902 -8 UA 1187 N76515
# 7 2013 1 1 607 607 0 858 915 -17 UA 1077 N53442
# 8 2013 1 1 611 600 11 945 931 14 UA 303 N532UA
[…]
| c25d5251a4c14ac89257fda77f9818063c1eb558cb291c4976bbefd5c6d4f0c4 | ['c1ee9c84f29d44e0ba1e1d5a7e66feb8'] | I need more elements to perform perfect code but try a code like this :
data4<- na.omit(data3)
ui <- fluidPage(
sidebarLayout(
# Input(s)
sidebarPanel(
# Select variable for x-axis
selectInput(inputId = "x",
label = "Variable 1",
choices = c("Col1", "Col2", "Col3"), # You have to define colnames
selected = "Col1"),
# Select variable for y-axis
selectInput(inputId = "y",
label = "Variable 2",
choices = c("Col4", "Col5", "Col6"), # Same things
selected = "Col4"),
mainPanel(plotOutput(outputId = "scatterplot"),
tableOutput("table")
)
)
)
server<- function(input, output){
output$scatterplot <- renderPlot({
projects_selected_date <- data4 %>%filter(Deployment.Month >= input$date[1] & Deployment.Month <=input$date[2])
ggplot(projects_selected_date,aes_string(x = input$x ,y = input$y,colour='red')) + geom_point()
})
### I don't know if this piece of code works !
output$table <- renderTable({
projects_selected_date <- data4 %>% filter(Deployment.Month >= input$date[1] & Deployment.Month <= input$date[2])
table(projects_selected_date)
)}
# Create a Shiny app object
shinyApp(ui = ui, server = server)
|
42ec96d3f532724ee0a060d8e0386157619effad1e031713b5236c1d19d71c01 | ['c1fca215893a4506835a47b5ab7b533a'] | We're covering spectral analysis for discrete time stationary processes in lectures, and I can't really get my head around something which seemingly should be easy.
"Because time is discrete, we only need to consider frequencies in $[\frac{-1}{2},\frac{1}{2}]$"
I have absolutely no understanding of why this is so. From my understanding of frequency, it's the number of observations (i.e. measurements making your time series) per pre-defined time interval. So, for example, if the interval is a day and we take a measurement per hour, frequency would be 24. This seems to agree.
I don't know where my misunderstanding lies.
| 23fdd5c1d508b53a35c58cb8959f60ef2ecf1775f6276854dc09733b934ff1c1 | ['c1fca215893a4506835a47b5ab7b533a'] | I've got discrete data (highest education level achieved to be exact, where each level has an associated integer, from 1 to 7, with a higher number corresponding to a higher education level). The two peaks I'm expecting (for my population) is at A-levels and having completed a degree. Between them is having started but not having finished a degree, which I'm not expecting a huge deal of my population to put as their highest level.
I'm after a discrete distribution, finite support (1,2,3,4,5,6,7,8), who's pmf follows the rough shape of a bimodal distribution. Does this exist? Can I just make one up?
I've never worked with real data before. When you're looking to assign a distribution to some data such as this (real life, messy, probably not entirely representative data) how do you go about fitting a distribution? Could anyone suggest reading material for this?
|
8a75077ae80df0c1468d89fb5c1f8eb251e4970afa5845709ab41b6ece19af1c | ['c2009eb663fb446ab010665cc87441af'] | 802.11b - 11 Mbps (2.4GHz)
802.11a - 54 Mbps (5 GHz)
802.11g - 54 Mbps (2.4GHz)
802.11n - 600 Mbps (2.4GHz and 5 GHz) - 150Mbps typical for network adapters, 300Mbps, 450Mbps, and 600Mbps speeds when bonding channels with some routers
802.11ac - 1300+Mbps (5 GHz) - newer standard that uses wider channels, QAM and spatial streams for higher throughput
Actual wireless speeds vary significantly from the above theoretical maximum speeds due to:
distance - distance from the access point, as well as any physical obstructions, such as walls, signal-blocking or reflecting materials affect signal propagation and reduce speed
interference - other wireless networks and devices in the same frequency in the same area affect performance
shared bandwidth - available bandwidth is shared between all users on the same wireless network.
| 0b94eb54c6570e70bea1c32cc153340924579897afca5d8c269f6636b0b0e15f | ['c2009eb663fb446ab010665cc87441af'] | First of all, make shure you have iOS 13.1 installed (available yesterday 24th sept 2019). iOS 13.0 was full of very annoying bugs...
After that, since most of your purchases were made from your wife's account, verify she's the Family Organiser and that Purchases Sharing is ON on every family user's account.
|
4f277ca6e9b3143fb3161681d9eb595bc6d3ad20b97d4126e2a34e2538901453 | ['c20fa190063b4c05bcd4eccfcfc281e2'] | I have an object that has an end date which is created using the callback after_create.
I'm wondering where the best place is to include the logic which would trigger an action when the object expires. (Time.now.in_time_zone > Object.end_date)
I'd like to create a method that checks whether an object has the attribute repeat as true or false. If it's true and the current date is passed the end date of the object, it should add 7 days to the end date of the object.
I have a method which checks whether the object is still valid but it's a boolean and I use it multiple times in the view so if I include it there, it gets executed multiple times before the view is even updated and I end up adding too many days to the end date.
Is it possible to have an action in your view file which is called automatically when the page loads if it falls under a certain condition? I'm guessing this is bad practice because I've read a few articles about avoiding too much logic in your view files.
I'm sure there are many ways of doing this so could you please let me know what methods you've used to overcome this?
Let me know if you need any more information.
| 26d8a3384e4d7e6e5684ee391c1cb690b548fbcc273450ccb82e3fb259f1c2dd | ['c20fa190063b4c05bcd4eccfcfc281e2'] | I have a User table with a column total_user_xp with a has_many :goals association.
The Goal table has a column total_goal_xp which is calculated in the model with the following method:
# goal.rb
belongs_to :user
has_many :goal_activities
has_many :activities, through: :goal_activities
def total_goal_xp
self.total_goal_xp = self.goal_activities.sum(:total_xp)
end
For some reason, in my controller and model file for User, I can't calculate the sum for total_goal_xp where the user_id matches the current_user. It always returns the value 0 as if the total_goal_xp wasn't being stored in the table.
I'm fairly new to rails but I have a feeling my total_goal_xp method isn't saving the value to the db. It seems to recalculate the sum every time that method is called. That said, in the rails console, running Goal.all gives me a table which does have the correct values so I don't understand why the following methods return the value 0.
user_controller.rb
def show
@user_goals = current_user.goals.all
@user_xp = @user_goals.sum(:total_goal_xp)
end
user.rb
has_many :goals
def set_total_user_xp
goal = self.goals.all
self.total_user_xp = goal.sum(:total_goal_xp)
end
In the server log, I get the following SQL - SELECT SUM("goals"."total_goal_xp") FROM "goals" WHERE "goals"."user_id" = ? [["user_id", 1]] for both methods.
I know I shouldn't be doing the calculations in the controller but at the moment, I just want to get the calculation to work so I know the associations are working.
Would appreciate any advice on the best practice for saving the total_goal_xp and the doing the same for the total_user_xp.
Let me know if you'd like to see any other files.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.