How to apply a function to each entry of a matrix in R

Uncategorized
Question: I have to store the log likelihood of some densities in a matrix, as follows:Matrix.logLik [,1] [,2] [,3] [,4] [,5] [1,] 0.00000 0.0000 0.0000 0.0000 0 [2,] -34.41018 0.0000 0.0000 0.0000 0 [3,] -2275.14867 -765.8642 0.0000 0.0000 0 [4,] 64.96982 264.7709 -256.1461 0.0000 0 [5,] 358.17822 260.1582 427.3490 363.2247 0 I would like to apply AIC function. AIC.log
Read More

How to hide element on small screens with Bootstrap 4 Beta

Uncategorized
Question: I just moved from bootstrap 4 alpha to beta, but I can't figure out how to hide an element on a small screen now. In the alpha this was "hidden-md-up" and "hidden-sm-down" which worked beautifully. "hidden-md-up" is now "d-md-none", but the other one I can't get to work Show on large screen only - NOT working for me Show on small screen only Any ideas? Answer: A short break, cup of coffee later I figured it out: Adding the class "d-none d-md-block" will do the trick Show on large screen only works now Show on small screen only Don't we all hate people that answer their own questions? ;-) Read more
Read More

Laravel route is redirecting too many times

Uncategorized
Question: I am using Laravel 5.4 for a project and scenario is if user does not have any clubs created then on login redirect user to clubs/create page. Below is my route page coding directory structure is routes/backend/access.php Route::group([ 'prefix' => 'access', 'as' => 'access.', 'namespace' => 'Access', ], function () { Route::group([ 'middleware' => ['access.routeNeedsRole:3', 'first.run'] ], function () { /* * Clubs Management */ Route::group(['namespace' => 'Clubs'], function () { Route::get('create', 'ClubsController@showCreateOrganiser')->name('clubs.showCreateOrganiser'); /* * Specific Club */ Route::group(['prefix' => 'clubs/{club}'], function () { // Access Route::get('login-as', 'ClubsController@loginAs')->name('clubs.login-as'); }); //For when admin is logged in as user from backend Route::get('logout-as', 'ClubsController@logoutAs')->name('clubs.logout-as'); /*Clubs CRUD*/ Route::resource('clubs', 'ClubsController'); //For DataTables Route::post('clubs/get', 'ClubsTableController')->name('clubs.get'); }); }); }); Below is my FirstRunMiddleware.php code Class FirstRunMiddleware { public function handle($request, Closure $next) { if (Clubs::scope()->count() ===…
Read More

Pyomo DAE toolbox cannot discretize the domain appropriately

python
Question: I'm using Pyomo DAE toolbox to solve a partial differential equation and the domain length of one independent variable (say m.x) is very small (like 1e-6). It seems to me that the DAE toolbox cannot discretize the domain appropriately because the discretized m.x only had 2 points (I used ContinuousSet.get_finite_elements() method to check that) even I specified 10 finite element points in the option (see code below). m.x = ContinuousSet(bounds=(0, 1e-6)) disc=TransformationFactory('dae.finite_difference') disc.apply_to(m, nfe=10, wrt=m.x, scheme='BACKWARD') I increased the upper bound of m.x as m.x = ContinuousSet(bounds=(0, 1e-5)) and tried to discretize it again. This time I got 10 points in the x domain. However, when I increased the number of finite element points as m.x = ContinuousSet(bounds=(0, 1e-5)) disc.apply_to(m, nfe=100, wrt=m.x, scheme='BACKWARD') the returned discretized domain x still…
Read More

Azure Data Lake Large Lookup

Uncategorized
Question: this is more of a design query, so please move if required.. we have a very high volume of logistics supply chain data being stored and analysed within Azure Data Lake service... it's then written out to Azure Data Warehouse once ready to 'serve it up'. we have a couple of situations where we need to 'lookup' the history of some items in this supply chain and see what has happened to them at some unknown, prior time in the past.. the lookup table has the propensity to get very very large. a question might be.. given that this item x is being packed into item y, has item y ever previously been marked as defective? We don't know at which point in time it could have been defective..…
Read More

Handling unknown characters in Blob.setDataFromString with encoding

Uncategorized
Question: I have a Google Add-On which will export sheet data in a defined encoding. The most common encoding used is ISO-8859-1. The script creates an internal String, then runs:Utilities.newBlob("", null, filename).setDataFromString(propClob, defEncoding); If the original data contains a character which cannot be represented in 'defEncoding', the resulting Blob will contain a '?'. I'd like to replace the character with its Unicode expression instead, eg. u0105. How can I check a string for characters not present in a given encoding? How can I find the Unicode expression for a given UTF-8 character? Thanks, Simon Answer: Read more
Read More

Implementing Expandable ListView in fragment in Android Studio

Uncategorized
Question: I am trying to put expandable listview inside fragment, so each item of the list can drop down and show more text below it. I tried multiple way but didn't succeed. No error or warnings, but when I click on the fragment the Mobile App just quit. The fragment is called projects. I want it contains a list of titles of the projects, then each of them can drop down to show the details. Code are here: fragment_project.java import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ExpandableListAdapter; import android.widget.ExpandableListView; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class fragment_project extends Fragment { ExpandableListView expandableListView; ExpandableListAdapter expandableListAdapter; List titles; Map texts; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for…
Read More

GlobalVariables for my webform app

Uncategorized
Question: I have a problem with creating GlobalVariables for my webform app. I am creating a webform app with Visual Studio 2015, VB.net, ASP.net I followed the instruction that I found on this and other sites but with no successs. I did the folowwing: 1 Create the module file: Module1.vb With this scripts: Public Module GlobalVariables2 Public ModuleEMAIL As String = "ModuleEMAIL@zzzzzzzz" End Module Public Class GlobalVariables Public Shared Property clasEMAIL As String = "clasEMAIL@zzzzzzzz" End Class But when ever I try to call the variables a compiler error occur. Function fnBtnText() Button1.Text = GlobalVariables.clasEMAIL ' generate: Compiler Error Message: BC30451: 'GlobalVariables' is not declared. It may be inaccessible due to its protection level. Button2.Text = ModuleEMAIL 'generate: Compiler Error Message: BC30451: 'ModuleEMAIL' is not declared. It may be inaccessible…
Read More

How to make white transparent

Uncategorized
Question: I am playing with OGL's blending. I have a white background. I draw quad on this background. The quad is binded with white and black texture. Colors array is filled with color and alpha values: for (i = 0; i < IMAGE_WIDTH; i++) { for (j = 0; j < MAGE_HEIGHT; j++) { c = ((((i&0x8)==0)^((j&0x8))==0))*255; Image[i][j][0] = (GLubyte) c; Image[i][j][1] = (GLubyte) c; Image[i][j][2] = (GLubyte) c; Image[i][j][3] = (GLubyte) 255; }; Display textured quad:glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE); glDisable (GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texCheck); glLoadIdentity(); glTranslatef (0.0f, 0.0f, -9.0f); glBegin (GL_QUADS); glColor3f (1.0f, 1.0f, 1.0f); glTexCoord2f(0.0, 0.0); glVertex3f(-5.0f, -5.0f, 0.0f); glTexCoord2f(0.0, 1.0); glVertex3f( 5.0f, -5.0f, 0.0f); glTexCoord2f(1.0, 1.0); glVertex3f( 5.0f, 5.0f, 0.0f); glTexCoord2f(1.0, 0.0); glVertex3f(-5.0f, 5.0f, 0.0f); glEnd(); glDisable(GL_TEXTURE_2D); glEnable (GL_DEPTH_TEST); glDisable (GL_BLEND); Black color of the binded texture…
Read More

xcopy misspelled or not found

Uncategorized
Question: I've got a batch script which copy a file into another. The problem is that the line with the xcopy command gives me an error. XCOPY /c /y /e ".localBuildproductDbUpConfiguration.xml" ".productSlnDatabaseUpdateDatabaseUpdatebinDebug" The paths are both correct. Do I need to install something for XCOPY or something else? Answer: Thanks to @Compo to give the solution to my problem. Here you see how it worked: Before:XCOPY /c /y /e ".localBuildproductDbUpConfiguration.xml" ".productSlnDatabaseUpdateDatabaseUpdatebinDebug" After:Copy /Y "localBuildproductDbUpConfiguration.xml" "productSlnDatabaseUpdateDatabaseUpdatebinDebug" Read more
Read More