Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

The web enabled extensions and command line enabled extensions can differ. Run php -m in your terminal and check to see if mcrypt is listed. If it's not then check where the command line is loading your php.ini file from by running php --ini from your terminal.

In this php.ini file you can enable the extension.
3 years ago
In Laravel 5.3 (and still true as of 7.x) you can use more granular wheres passed as an array:
***
$query->where([
['column_1', '=', 'value_1'],
['column_2', '<>', 'value_2'],
[COLUMN, OPERATOR, VALUE],
...
])

***
you can pass an array to where

As long as you want all the wheres use and operator, you can group them this way:
***
$matchThese = ['field' => 'value', 'another_field' => 'another_value', ...];
***
// if you need another group of wheres as an alternative:
***
$orThose = ['yet_another_field' => 'yet_another_value', ...];
***
Then:
***
$results = User::where($matchThese)->get();

// with another group
$results = User::where($matchThese)
->orWhere($orThose)
->get();
***
The above will result in such query:
***
SELECT * FROM users
WHERE (field = value AND another_field = another_value AND ...)
OR (yet_another_field = yet_another_value AND ...)
***
3 years ago
Normally composer remove used like this is enough:

composer remove vendor/package
But if a Composer package is removed and the "config" cache is not cleaned you cannot clean it. When you try like so
***
php artisan config:clear
***
you can get an error In ProviderRepository.php line 208:
***
Class 'Laracasts\Flash\FlashServiceProvider' not found
***
This is a dead end, unless you go deleting files:
***
rm bootstrap/cache/config.php
***
And this is Laravel 5.6 I'm talking about, not some kind of very old stuff.

It happens usually on automated deployment, when you copy files of a new release on top of old cache. Even if you cleared the cache before copying. You end up with an old cache and a new composer.json file.
3 years ago
Create a helpers.php file in your app folder and load it up with composer:
***
"autoload": {
"classmap": [
...
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helpers.php" // <---- ADD THIS
]
},
***
After adding that to your composer.json file, run the following command:
3 years ago
I've used both, they both seem to work ok. My nod is for Selenium as it seemed to have better Ajax support. I believe WaTiN has matured though since last I used it so it should have the same thing.

The biggest thing would be which development environment do you like to be in? Selenium and Watin have recorders but Selenium is in the browser and watin is in visual studio. + and -'s to both of those
3 years ago
Users can still browse your website because cookies are not cleared when you call FormsAuthentication.SignOut() and they are authenticated on every new request. In MS documentation is says that cookie will be cleared but they don't, bug? Its exactly the same with Session.Abandon(), cookie is still there.

You should change your code to this:
***
FormsAuthentication.SignOut();
Session.Abandon();

// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);

// clear session cookie (not necessary for your current problem but i would recommend you do it anyway)
SessionStateSection sessionStateSection = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
HttpCookie cookie2 = new HttpCookie(sessionStateSection.CookieName, "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);

FormsAuthentication.RedirectToLoginPage();
***
3 years ago
There is another, more insidious reason, why this may occur even when the Session object has been initialized as demonstrated by Cladudio.

In the Web.config, if there is an entry that is set to requireSSL="true" but you are not actually using HTTPS: for a specific request, then the session cookie is not sent (or maybe not returned, I'm not sure which) which means that you end up with a brand new session for each request
3 years ago
***
1. Click 'Show All Files' in Solution Explorer
2. Right-click over 'wwwroot' select 'Exclude From Project'
3. Right-click over 'wwwroot' select 'Include in Project'
***
3 years ago
Make second argument of Response false as shown below.
***
Response.Redirect(url,false);
***
3 years ago
Dedicated functions (nafill and setnafill) for that purpose are available in data.table package (version >= 1.12.4):

It process columns in parallel so well address previously posted benchmarks, below its timings vs fastest approach till now, and also scaled up, using 40 cores machine.
***
library(data.table)
create_dt <- function(nrow=5, ncol=5, propNA = 0.5){
v <- runif(nrow * ncol)
v[sample(seq_len(nrow*ncol), propNA * nrow*ncol)] <- NA
data.table(matrix(v, ncol=ncol))
}
f_dowle3 = function(DT) {
for (j in seq_len(ncol(DT)))
set(DT,which(is.na(DT[[j]])),j,0)
}

set.seed(1)
dt1 = create_dt(2e5, 200, 0.1)
dim(dt1)
#[1] 200000 200
dt2 = copy(dt1)
system.time(f_dowle3(dt1))
# user system elapsed
# 0.193 0.062 0.254
system.time(setnafill(dt2, fill=0))
# user system elapsed
# 0.633 0.000 0.020 ## setDTthreads(1) elapsed: 0.149
all.equal(dt1, dt2)
#[1] TRUE

set.seed(1)
dt1 = create_dt(2e7, 200, 0.1)
dim(dt1)
#[1] 20000000 200
dt2 = copy(dt1)
system.time(f_dowle3(dt1))
# user system elapsed
# 22.997 18.179 41.496
system.time(setnafill(dt2, fill=0))
# user system elapsed
# 39.604 36.805 3.798
all.equal(dt1, dt2)
#[1] TRUE
***
3 years ago
If you have multiple factors (= a multi-dimensional data frame), you can use the dplyr package to count unique values in each combination of factors:
***
library("dplyr")
data %>% group_by(factor1, factor2) %>% summarize(count=n())
***
It uses the pipe operator %>% to chain method calls on the data frame data.
3 years ago
If you are using Windows, you might want to use the installr package:
***
install.packages("installr")
require(installr)
updateR()
***
The best way of doing this is from the RGui system. All your packages will be transferred to the new folder and the old ones will be deleted or saved (you can pick either). Then once you open RStudio again, it immediately recognizes that you are using an updated version. For me this worked like a charm.
3 years ago