Rectangle 27 5

I just done this in my project for two tables namely users and admin but you can do the same for more than two table. Let's have a look

AuthServiceProvider

I have two table admin and users

first of create basic login/register route, view and controller for user table by using Laravel 5.2 artisan command.

php artisan make:auth

Lets make a admin table as users table.

app/Http/Controllers/AdminAuth/PasswordController
app/Http/Controllers/Auth/AuthController
config/auth.php
//Authenticating guards
'guards' => [
    'user' =>[
        'driver' => 'session',
        'provider' => 'user',
    ],
    'admin' => [
        'driver' => 'session',
        'provider' => 'admin',
    ],
],  

//User Providers
'providers' => [
    'user' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
    'admin' => [
        'driver' => 'eloquent',
        'model' => App\Admin::class,
    ]
],  

//Resetting Password  
'passwords' => [
    'clients' => [
        'provider' => 'client',
        'email' => 'auth.emails.password',
        'table' => 'password_resets',
        'expire' => 60,
    ],
    'admins' => [
        'provider' => 'admin',
        'email' => 'auth.emails.password',
        'table' => 'password_resets',
        'expire' => 60,
    ],
],
route.php
Route::group(['middleware' => ['web']], function () {
    //Login Routes...
    Route::get('/admin/login','AdminAuth\AuthController@loginPage');
    Route::post('/admin/login','AdminAuth\AuthController@login');
    Route::get('/admin/logout','AdminAuth\AuthController@logout');

    // Registration Routes...
    Route::get('admin/register', 'AdminAuth\AuthController@registrationPage');
    Route::post('admin/register', 'AdminAuth\AuthController@register');

    Route::get('/admin', 'AdminController@index');

});
AdminAuth/AuthController.php

Add two methods and specify $redirectTo and $guard

protected $redirectTo = '/admin';
protected $guard = 'admin';
public function loginPage()
{
    if (view()->exists('auth.authenticate')) {
        return view('auth.authenticate');
    }

    return view('admin.auth.login');
}
public function registrationPage()
{
    return view('admin.auth.register');
}

creating a middleware for admin

class RedirectIfNotAdmin
{
/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @param  string|null  $guard
 * @return mixed
 */
public function handle($request, Closure $next, $guard = 'admin')
{
    if (!Auth::guard($guard)->check()) {
        return redirect('/');
    }

    return $next($request);
}

register middleware in kernel.php

protected $routeMiddleware = [
    'admin' => \App\Http\Middleware\RedirectIfNotAdmin::class,
];

use this middleware in AdminController e.g.,

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

class AdminController extends Controller
{
    public function __construct(){
        $this->middleware('admin');
   }
public function index(){
        return view('admin.dashboard');
    }
}

Authentication We can access authenticated user directly usingAuth::user() but if you have two authentication table then you have to use

Auth::guard('guard_name')->user()
Auth::guard('admin')->user()

php - Authenticate users from more than two tables in laravel 5 - Stac...

php laravel authentication laravel-5.2
Rectangle 27 5

I like Ian Dickinson's answer, and if I only needed to do this once, I'd use Jena's rdfcat. You mention that you need to do this in Java though, so perhaps a command line tool isn't appropriate. This is still pretty easy to do with the Jena API. If you have just two models, you can create a UnionModel from the two, or if you have more (perhaps the two in the question are just a reduced case, and you actually need to handle more), you can just create a new model to hold all the triples, and add the triples from the two models to the new one. Here's code that shows each approach:

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;

public class ManualRDFCat {
    public static void main(String[] args) throws FileNotFoundException, IOException {
        final Model dcterms = ModelFactory.createDefaultModel().read( "http://dublincore.org/2012/06/14/dcterms.rdf" );
        final Model foafIndex = ModelFactory.createDefaultModel().read( "http://xmlns.com/foaf/spec/index.rdf" );

        // If you only have two models, you can use Union model.
        final Model union = ModelFactory.createUnion( dcterms, foafIndex );
        try ( final OutputStream out1 = new FileOutputStream( new File( "/tmp/purl_foaf1.rdf" )) ) {
            union.write( out1, "Turtle", null );
        }

        // In general, though, it's probably better to just create a new model to 
        // hold all the triples, and to add the triples to that model.
        final Model blob = ModelFactory.createDefaultModel();
        for ( final Model part : new Model[] { dcterms, foafIndex } ) {
            blob.add( part );
        }
        try ( final OutputStream out2 = new FileOutputStream( new File( "/tmp/purl_foaf2.rdf" )) ) {
            blob.write( out2, "RDF/XML-ABBREV", null );
        }
    }
}

java - Merging multiple RDF documents into one - Stack Overflow

java rdf jena
Rectangle 27 2

First thing that jumps out to me is the "ChefPositionSkillController" should be pluralized to follow Rails conventions so should be "ChefPositionSkillsController". Also, if you're just planning on relating a many-to-many with ChefPositions and Skills you're fine naming the join table ChefPositionSkill (Just remember you can change this but the join table must be the combined names of the two tables in lexical order which is what you have here). Most people however, now use a "has_many through" relationship in that you can add additional details to your join table and not be limited to just the id columns. This would benefit you if you ever decide that a chef, with a certain skillset, should also have a rank or priority etc.

thank you, this is very helpful.. Any feedback on the controller... Should the index method be used to return all the skills per position?

Yes that would make sense.

ruby - Rails 5, How to name two models with an associated table? - Sta...

ruby-on-rails ruby activerecord ruby-on-rails-5
Rectangle 27 9

When using Java reflection, the JVM has two methods of accessing the information on the class being reflected. It can use a JNI accessor, or a Java bytecode accessor. If it uses a Java bytecode accessor, then it needs to have its own Java class and classloader (sun/reflect/GeneratedMethodAccessor class and sun/reflect/DelegatingClassLoader). Theses classes and classloaders use native memory. The accessor bytecode can also get JIT compiled, which will increase the native memory use even more. If Java reflection is used frequently, this can add up to a significant amount of native memory use. The JVM will use the JNI accessor first, then after some number of accesses on the same class, will change to use the Java bytecode accessor. This is called inflation, when the JVM changes from the JNI accessor to the bytecode accessor. Fortunately, we can control this with a Java property. The sun.reflect.inflationThreshold property tells the JVM what number of times to use the JNI accessor. If it is set to 0, then the JNI accessors are always used. Since the bytecode accessors use more native memory than the JNI ones, if we are seeing a lot of Java reflection, we will want to use the JNI accessors. To do this, we just need to set the inflationThreshold property to zero.

sun.reflect.inflationThreshold
-Dsun.reflect.inflationThreshold=0

java.lang.OutOfMemoryError: PermGen space: java reflection - Stack Ove...

java reflection
Rectangle 27 1

Bar plots can only take one colour per series, so we just need to put your data into two series not one! Each series is a matrix row, and each column of the matrix is a different colour, so if we add some 0s (so padding doesn't show as actual bars with any height) you can achieve what you want.

This actually solves problem 1, makes the legend work properly, and makes problem 2 easier!

'stacked'
TEV_Idz = 0.0018; TEV_TF = 0.012;
% Each row in a bar plot is its own series, so put the data on two rows.
% This can be created using TEV_data = diag([TEV_Idz, TEV_TF]); 
TEV_data = [TEV_Idz, 0; 
            0,       TEV_TF]; 
% Each column will be a different colour, plot them stacked to be central
TEV_plot = bar(TEV_data, 0.6, 'stacked');
grid on; ylim([0, max(TEV_data(:) + 0.002)]);
set(gca, 'yTickLabel',num2str(100.*get(gca,'yTick')','%g%%'));

% Insert legend, one element for each series
legend({'L','B'}, 'location', 'northoutside', 'orientation', 'horizontal')
% A better option might be to just label on the x axes and not have a legend:
% set(gca, 'xticklabels', {'L','B'})

% Plotting the value of each scalar on the top of the every bar graph.
% The diagonal entries of TEV_data is where the actual data is stored. 
% Use num of diagonal entries, and index (k,k) for diagonal.
for k = 1:numel(diag(TEV_data))
    text(k, TEV_data(k,k), num2str(100.*TEV_data(k,k),'%g%%'), ...
        'HorizontalAlignment', 'center', ...
        'verticalalignment', 'bottom')
end

Different colors and data value on bars: Bar Chart Matlab - Stack Over...

matlab bar-chart
Rectangle 27 1

There are two ways to solve your problem! If you just want to to add files into your jar, you can use the resources tags to add them

<build>
    <resources>
        <resource>
            <filtering>false</filtering>
            <directory>lib</directory>
            <includes>
                <include>*.jar</include>
            </includes>
        </resource>
    </resources>
</build>

This now puts all jar files from you lib folder into the main jar. The root folder is the folder from which you invoked the corresponding pom.xml. With this you can add arbitrary files to you jar. For a complete syntax reference take a look here.

The other way and maybe the most convenient way is to use the maven-shade-plugin this allows you to copy almost everything into you final jar.

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-shade-plugin</artifactId>
   <version>2.4.3</version>
   <executions>
      <execution>
         <phase>package</phase>
         <goals>
            <goal>shade</goal>
         </goals>
         <configuration>
            <artifactSet>
               <includes>
                  <include>groupid:artifactid_a</include>
                  <include>groupid:artifactid_b</include>
               </includes>
            </artifactSet>
            <filters>
               <filter>
                  <artifact>*:*</artifact>
                  <includes>
                     <include>resources/*.png</include>
                  </includes>
               </filter>
            </filters>
         </configuration>
      </execution>
   </executions>
</plugin>

The artifactSet parts allow you to reference jar from within you local repro to be included just by mentioning their groupid and artifactid

This will include the content like class files, manifest etc. and also the folder structure) of the mentioned artifact (from you local repro) into you jar.

If you want to include other arbitrary files into you jar you can use the filter tag of the plugin which allows you to specify files and file-patterns directly. For a complete syntax reference take a look here.

P.S.: If you want to exclude certain files you can replace the include tag by an exclude tag ;-)

How to create a .jar out of multiple jars using Maven Plugin - Stack O...

maven jar maven-plugin maven-shade-plugin
Rectangle 27 1

There are two ways to solve your problem! If you just want to to add files into your jar, you can use the resources tags to add them

<build>
    <resources>
        <resource>
            <filtering>false</filtering>
            <directory>lib</directory>
            <includes>
                <include>*.jar</include>
            </includes>
        </resource>
    </resources>
</build>

This now puts all jar files from you lib folder into the main jar. The root folder is the folder from which you invoked the corresponding pom.xml. With this you can add arbitrary files to you jar. For a complete syntax reference take a look here.

The other way and maybe the most convenient way is to use the maven-shade-plugin this allows you to copy almost everything into you final jar.

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-shade-plugin</artifactId>
   <version>2.4.3</version>
   <executions>
      <execution>
         <phase>package</phase>
         <goals>
            <goal>shade</goal>
         </goals>
         <configuration>
            <artifactSet>
               <includes>
                  <include>groupid:artifactid_a</include>
                  <include>groupid:artifactid_b</include>
               </includes>
            </artifactSet>
            <filters>
               <filter>
                  <artifact>*:*</artifact>
                  <includes>
                     <include>resources/*.png</include>
                  </includes>
               </filter>
            </filters>
         </configuration>
      </execution>
   </executions>
</plugin>

The artifactSet parts allow you to reference jar from within you local repro to be included just by mentioning their groupid and artifactid

This will include the content like class files, manifest etc. and also the folder structure) of the mentioned artifact (from you local repro) into you jar.

If you want to include other arbitrary files into you jar you can use the filter tag of the plugin which allows you to specify files and file-patterns directly. For a complete syntax reference take a look here.

P.S.: If you want to exclude certain files you can replace the include tag by an exclude tag ;-)

How to create a .jar out of multiple jars using Maven Plugin - Stack O...

maven jar maven-plugin maven-shade-plugin
Rectangle 27 2

It sounds as though you've only add the header search paths for these dependencies under your projects "Build Settings" -> "Search Paths" -> "User Header Search Paths" field. This will enable xcode to know that these classes exist while you are developing, but wont enable your project to build. You should also make sure that your project knows where to find the libraries where the openCV and fast9 symbols you're using are defined (i.e. where the .so files are for these two dependencies). You can do this by adding the appropriate linker flags under "Build Settings" -> "Linking" -> "Other Linker Flags". ALSO make sure that these fields are set for the TARGET you are trying to compile, not just the PROJECT.

If you arent sure what the linker flags are, here is a brief example. I want to link the following library:

/path/to/some/project/lib/libfoo.so

I would add the following to the "Other Linker Flags" field:

-L/path/to/some/project/lib -lfoo

Basically -L precedes the directory and -l precedes the name of the library without the 'lib' and '.so'.

Note: Whenever I include external dependencies in my xcode projects I also set "Build Settings" -> "Search Paths" -> "Always Search User Paths" to "Yes" just in case any of the dependencies include headers with angle brackets like #include <header.h>.

EDIT: Ok I added the Linker flags from an opencv tutorial and now I only get the errors with the fast Methods. I checked if "Always Search User Paths" is ob Yes. The Fast methods and Header are included in my Project Folder. I will add the .h File into my Question probably there is sth. wrong?

In the compile sources there are the .c files from fast.

Nevermind I know where the Mistake was!

c++ - XCode Build Failed "undefined Symbols for architecture x86_64" -...

c++ xcode opencv build
Rectangle 27 1

You just want to know, how much noise is in the environment and you have two signals, the original one and the recorded one? Then your solution is perfectly fine. You need to synchronize the signals and find some number, which gives you similarity. You can even avoid fft and use the original signal (in a proper presentation).

Autocorellation is a nice way to synchronice your signals. Autocorellation-index is a number which gives you the similarity.

Of course, if the volume is lower, the noise is (relative to the music) louder and has higher influence. Since you should be able to detect the volume, you should be able to add some correction-factors. But since this is a "natural" problem, I guess every algorithm will have this problem.

Another solution would be to subtract the original signal from the recorded signal and then you should get the noise as the difference of both signals. Then you also have the power of the noise...

ios - Detecting noise via mic while playing a song on iPhone - Stack O...

ios iphone audio fft noise
Rectangle 27 1

There are two things that NSOperationQueue can do that GCD doesn't do: The minor one is dependencies (add an operation to a queue but tell it to only execute when certain other operations are finished), and the big one is that NSOperation gives you an object which can receive messages while the task is executing, unlike GCD which has blocks that cannot receive messages except in a very limited way. You either need these two features, or you don't. If you don't, using GCD is just an awful lot easier to use.

That's why useful examples of NSOperation are always quite complex. If they were easy, you would use GCD instead. You usually create a subclass of NSOperation, which will be some significant amount of work, or use one that someone else has created.

objective c - Why should I choose GCD over NSOperation and blocks for ...

objective-c ios concurrency objective-c-blocks grand-central-dispatch
Rectangle 27 1

There are two things that NSOperationQueue can do that GCD doesn't do: The minor one is dependencies (add an operation to a queue but tell it to only execute when certain other operations are finished), and the big one is that NSOperation gives you an object which can receive messages while the task is executing, unlike GCD which has blocks that cannot receive messages except in a very limited way. You either need these two features, or you don't. If you don't, using GCD is just an awful lot easier to use.

That's why useful examples of NSOperation are always quite complex. If they were easy, you would use GCD instead. You usually create a subclass of NSOperation, which will be some significant amount of work, or use one that someone else has created.

objective c - Why should I choose GCD over NSOperation and blocks for ...

objective-c ios concurrency objective-c-blocks grand-central-dispatch
Rectangle 27 1

When dynamically adding controls you need to re-add them everytime your page loads. I've had to tackle similar difficulties and I do this in two ways. Where dynamic fields are added o the fly I will actually add a hidden control to the page before the user clicks to fill it in or add it themselves. By creating this sort of placeholder the system has tim eto start handling viewstate correctly and this preserves the users changes. The second issue that I hear you mentioning is that there might be issues with chich update panel updates. It's fine to have them set to conditional bu tin your code-behind you can also trigger the updates in teh othe rpanels if you need to from code. It's just updatepanel#.update()

alternatively you can also wrap all the update panels in another panel but I advise against this as it wastes resources.

asp.net - Multiple UpdatePanels and state - Stack Overflow

asp.net ajax asp.net-ajax updatepanel user-controls
Rectangle 27 1

Once you have the menu bar focused, you can generally hit the first letter of a menu to open it (V for View in this case), then the first letter of any submenus or options you wish to open or select, respectively. In previous versions of Windows (I haven't used Win10 yet) there was an option, usually set by default, to underline the "hotkey" of the menu item, which is especially useful if you have two menu items that begin with the same letter. If nothing is underlined, I would assume you can just start spelling out the menu item, so if you have View and Verify on the same submenu, you'd just type vi for the first and ve for the second one.

So, for your particular setup, just hit Alt to focus the menu bar, then V, R, 8 for View -> Ruler -> 80, respectively.

As a freebie, I'll give you not one but two keyboard shortcuts as well:

{ 
    "keys": ["ctrl+shift+8"], 
    "command": "set_setting", 
    "args": 
    {
        "setting": "rulers", 
        "value": [80]
    } 
},
{ 
    "keys": ["ctrl+shift+0"], 
    "command": "set_setting", 
    "args": 
    {
        "setting": "rulers", 
        "value": []
    } 
}

Add these to your user keymap, and CtrlShift8 will set the rulers to 80, while CtrlShift0 will set them back to none. Remember that this is for the current view only, not all open files, and any newly-opened files or views will default back to the value in either your project, user settings, or default settings (in that order).

sublimetext - How can I set the ruler in sublime from the command pale...

sublimetext
Rectangle 27 2

It's nice to actually provide a 3 layer object because you can colour the back-layer how you like. The front layer is the same shape as your back layer but it has an opacity of zero so that you can see the text on the middle layer. I also don't like to use node for handling events but the natively available Raphael event handling mechanism. The below example is taken from one of the examples on my website, I have cut it down even further so it's more readily understood. Also note it is a button made up of a front and back layer circle with a text sandwiched between the two layers. They could just as easily be rectangles/rounded rectangles. The functionality includes the colours inverting on mouseover/mouseout...

button = function (paper, xpos, ypos, r, labeltext) 
{

this.backLayer = paper.circle(xpos, ypos, r).attr({ fill: "#FFFF00", 'fill-opacity': 0  , stroke: "#FF0000",'stroke-width':5, 'stroke-opacity':0});

/*The text automatically centres itself as this is the default text positioning for Raphael text*/
this.label = paper.text(xpos, ypos, labeltext).attr({fill:'#ff0000', 'font-size':18});

/*Now we make a copy for the front layer and we also make the back layer opaque. So that you can see it's yellow fill*/
this.frontLayer = this.backLayer.clone();
this.backLayer.attr({'fill-opacity': 1, 'stroke-opacity':1});

/*Now make the back layer and the text referencable for the mouseover, mouseout and click event of the front layer*/ 
this.frontLayer.backLayer= this.backLayer;
this.frontLayer.label = this.label;

/*Add a preferred cursor by referencing the underlying DOM object of the frontLayer*/
this.frontLayer.node.style.cursor = 'pointer';

/*Now you can interact with the lower layers behind the invisible covering layer ( frontLayer ) in it's event methods*/
this.frontLayer.mouseover(
function (e) {
    this.backLayer.animate({ fill: "#FF0000", stroke: "#FFFF00" }, 1000);
    this.label.animate({ fill: "#FFFF00" }, 1000);
    }
);  
this.frontLayer.mouseout(
function (e) {
    this.backLayer.animate({ fill: "#FFFF00", stroke: "#FF0000" }, 1000);
    this.label.animate({ fill: "#FF0000" }, 1000);
    }
);
this.frontLayer.click(      
function (e) {
        alert("Creating loads of custom buttons is easy\n\nYou made this one with the following specification:\n"+
        "Button Text      : "+this.label.attr("text")+"\n"+
        "Button Centre @ X: "+this.backLayer.attr("cx")+"\n"+
        "Button Centre @ Y: "+this.backLayer.attr("cy")+"\n"+
        "Button Radius    : "+this.backLayer.attr("r"));
    }

);  
}
/*Create the button*/
rappyButton = new button(paper, 250, 200, 75, "Raphael");

I have updatd the question with the results of this solution. No use:(

javascript - Onclick event for rect using Raphaeljs - Stack Overflow

javascript jquery raphael
Rectangle 27 4

I've just found out what's happening. The difference between the simple example and the real thing is the fact that there is an AddIn involved. It's quite a log story, but this is it. As you can see from the code sample, I load the ConfClasses dll via reflection in order to avoid to add a reference to it. This is fine at runtime, but the designer complains saying that it's not able to cast IConf to IConf. This happens because CoreClasses.dll is loaded from AppData\Local\Microsoft\VisualStudio\10.0\ProjectAssemblies when the designer starts, but ConfClasses.dll is loaded from my bin folder and so are its references, so there are two versions of CoreClasses.dll and different versions of IConf. To bypass the problem I developed an AddIn that, when an assembly is loaded with Assembly.Load at design time, adds a reference to that assembly, and then cleans the references when the last designer window is closed. Everything was OK with VS2005, but using ProcMon.exe I found out that VS2010 added a new folder where the addins look for assemblies: Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\CommonExtensions\DataDesign I copied my assembly there and everything works again. Now it's only a matter of finding a way to add things there manually.

c# - Where does Visual Studio look for assemblies? - Stack Overflow

c# visual-studio-2010 windows-forms-designer
Rectangle 27 24

/**
       * An object of type RomanNumeral is an integer between 1 and 3999.  It can
       * be constructed either from an integer or from a string that represents
       * a Roman numeral in this range.  The function toString() will return a
       * standardized Roman numeral representation of the number.  The function
       * toInt() will return the number as a value of type int.
       */
      public class RomanNumeral {

         private final int num;   // The number represented by this Roman numeral.

         /* The following arrays are used by the toString() function to construct
            the standard Roman numeral representation of the number.  For each i,
            the number numbers[i] is represented by the corresponding string, letters[i].
         */

         private static int[]    numbers = { 1000,  900,  500,  400,  100,   90,  
                                               50,   40,   10,    9,    5,    4,    1 };

         private static String[] letters = { "M",  "CM",  "D",  "CD", "C",  "XC",
                                             "L",  "XL",  "X",  "IX", "V",  "IV", "I" };

         /**
          * Constructor.  Creates the Roman number with the int value specified
          * by the parameter.  Throws a NumberFormatException if arabic is
          * not in the range 1 to 3999 inclusive.
          */
         public RomanNumeral(int arabic) {
            if (arabic < 1)
               throw new NumberFormatException("Value of RomanNumeral must be positive.");
            if (arabic > 3999)
               throw new NumberFormatException("Value of RomanNumeral must be 3999 or less.");
            num = arabic;
         }


         /*
          * Constructor.  Creates the Roman number with the given representation.
          * For example, RomanNumeral("xvii") is 17.  If the parameter is not a
          * legal Roman numeral, a NumberFormatException is thrown.  Both upper and
          * lower case letters are allowed.
          */
         public RomanNumeral(String roman) {

            if (roman.length() == 0)
               throw new NumberFormatException("An empty string does not define a Roman numeral.");

            roman = roman.toUpperCase();  // Convert to upper case letters.

            int i = 0;       // A position in the string, roman;
            int arabic = 0;  // Arabic numeral equivalent of the part of the string that has
                             //    been converted so far.

            while (i < roman.length()) {

               char letter = roman.charAt(i);        // Letter at current position in string.
               int number = letterToNumber(letter);  // Numerical equivalent of letter.

               i++;  // Move on to next position in the string

               if (i == roman.length()) {
                     // There is no letter in the string following the one we have just processed.
                     // So just add the number corresponding to the single letter to arabic.
                  arabic += number;
               }
               else {
                     // Look at the next letter in the string.  If it has a larger Roman numeral
                     // equivalent than number, then the two letters are counted together as
                     // a Roman numeral with value (nextNumber - number).
                  int nextNumber = letterToNumber(roman.charAt(i));
                  if (nextNumber > number) {
                       // Combine the two letters to get one value, and move on to next position in string.
                     arabic += (nextNumber - number);
                     i++;
                  }
                  else {
                       // Don't combine the letters.  Just add the value of the one letter onto the number.
                     arabic += number;
                  }
               }

            }  // end while

            if (arabic > 3999)
               throw new NumberFormatException("Roman numeral must have value 3999 or less.");

            num = arabic;

         } // end constructor


         /**
          * Find the integer value of letter considered as a Roman numeral.  Throws
          * NumberFormatException if letter is not a legal Roman numeral.  The letter 
          * must be upper case.
          */
         private int letterToNumber(char letter) {
            switch (letter) {
               case 'I':  return 1;
               case 'V':  return 5;
               case 'X':  return 10;
               case 'L':  return 50;
               case 'C':  return 100;
               case 'D':  return 500;
               case 'M':  return 1000;
               default:   throw new NumberFormatException(
                            "Illegal character \"" + letter + "\" in Roman numeral");
            }
         }


         /**
          * Return the standard representation of this Roman numeral.
          */
         public String toString() {
            String roman = "";  // The roman numeral.
            int N = num;        // N represents the part of num that still has
                                //   to be converted to Roman numeral representation.
            for (int i = 0; i < numbers.length; i++) {
               while (N >= numbers[i]) {
                  roman += letters[i];
                  N -= numbers[i];
               }
            }
            return roman;
         }


         /**
          * Return the value of this Roman numeral as an int.
          */
         public int toInt() {
            return num;
         }


      }
i++;

methods - Converting Integers to Roman Numerals - Java - Stack Overflo...

java methods roman-numerals
Rectangle 27 6

I just solved my code signing problem. What a nightmare! Over 8 hours of frustration over two days. I tried new apps, new app names, new certificates, deleting provisioning profiles etc. Basically I had two "iPhone Distribution" certificates in my keychain causing all code signing to fail. But one was hidden! The visible cert was in my Login keychain. The invisible cert was in my System keychain. Be warned, add your certificate to either keychain but not both! I deleted the certificate from the System keychain and it became a ghost certificate. It no longer appears in the System keychain "Keychain Access" tool but it did exist in the actual System keychain file, so effectively it had not been removed. I grepped the keychain file for the word Distribution and there it was! My solution was to remove that line containing iPhone Distribution from the keychain file which fixed the code signing. The result is I have a broken System keychain. But I can sign apps again \m/

ios - Xcode: iPhone app codesign error - Stack Overflow

iphone ios xcode code-signing xcrun
Rectangle 27 6

I just solved my code signing problem. What a nightmare! Over 8 hours of frustration over two days. I tried new apps, new app names, new certificates, deleting provisioning profiles etc. Basically I had two "iPhone Distribution" certificates in my keychain causing all code signing to fail. But one was hidden! The visible cert was in my Login keychain. The invisible cert was in my System keychain. Be warned, add your certificate to either keychain but not both! I deleted the certificate from the System keychain and it became a ghost certificate. It no longer appears in the System keychain "Keychain Access" tool but it did exist in the actual System keychain file, so effectively it had not been removed. I grepped the keychain file for the word Distribution and there it was! My solution was to remove that line containing iPhone Distribution from the keychain file which fixed the code signing. The result is I have a broken System keychain. But I can sign apps again \m/

ios - Xcode: iPhone app codesign error - Stack Overflow

iphone ios xcode code-signing xcrun
Rectangle 27 1

Not sure if this question will be downvoted as too opinionated, but here's my two cents. Don't use HTTP response codes unless you are very certain you know what you're doing and want this method. Use JSON every time, instead of HTML or HTML and JSON. It's much more flexible and extendable than returning HTML and doing a simple DOM update. As you mentioned, there's no good way to indicate an error or success condition when you're just returning HTML. Using JSON you can return an array of errors to be applied, add in a status flag, and any other features you may need. You can then write more Javascript to handle successes and errors.

javascript - Best practice for handling server side validation in moda...

javascript jquery html ajax forms
Rectangle 27 3

One of the goals of the JSF framework is to support "MVC" architecture, that's why, it provides so many fonctionalities and technologies to elaborate the MVC principles. That's why it's not strongly recommanded to mix the view with the controller tiers, so you should separate between these two tiers, because each tier has its ows special role. First, you shouldn't add/modify any other xml files if you're using JSF 2.X version. To illustrate the registration process in your example, you can for example show the registration filled informations in a second simple page named result.xhtml. First replace the method getResponse() by just response() with the content:

public String response(){
    return "result?faces-redirect=true";
}

The outcome string provided through the method above can be written simply return "result"; then, the URI adress in the browser bar will not be changed while forwarding to the destination page. Else, if the string (page's name) is followed by faces-redirect=true like the example, then the URI adress will be changed, and the destination's name will be displayed as well in the browser adress bar.

Then, in index.xhtml, you made the <h:commandButton /> without action necessary attribute in your example, so you should replace the last part there by:

<h:commandButton value="Register" style="color:red" action="#{Registration.response()}" />

And of course, you should also omit the last <h:outputText /> tag in the index.xhtml.

Finally, create the new page result.xhtml to show registration informations:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">
<head>
    <title>Registration informations</title>
</head>
<body>

    <h2>Your registration informations :</h2>

    <h:outputText value="Last name : #{Registration.lastName }" /><br />
    <h:outputText value="First name : #{Registration.firstName }" /><br />
    <h:outputText value="MI : #{Registration.mi}" /><br />
    ...

</body>
</html>

For learning purposes, I would post two implementations of the response method: one that simply returns "result" and another that returns "result?faces-redirect=true" and explain the differences between both or point to a link where this is covered and explained. Apart of that, good answer.

xml - JSF Stack exception or managed bean trouble - Stack Overflow

xml jsf managed-bean