text:
title: Setting up multiple virtual hosts
date: 2010-08-29 06:03:00 +0000
categories:
- miscellaneous
tags:
- apache
- server
author: Smit Shah
layout: post
---

Few days ago I had face a problem,"How to use different domains on localhost?"so at that time i doesn't know how to use different/multiple domain on localhost so i just put project on Development server and then i check the functionality.

Today I got some time to find out "How to make multiple domain on localhost"
so i got solution as always :)

The multiple hostnames such as projecta, projectb, projectc and projectc-beta2 can be set in either of these hosts configuration files (also referred to as hosts files) depending on your operating system:

`Windows: C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS (assuming your Windows installation is in C:\WINDOWS).
For Linux: /etc/hosts
If you were to open these files in a text editor, you'll see content similar to the following:
127.0.0.1        localhost
192.168.1.18     testhost.testdomain.com testhost`

All hosts files will have the localhost entry which resolves to 127.0.0.1, also known as the loopback address. Basically, what the first line in the host file illustrated above tells us is to route all network packets addressed to localhost to the computer you're using.
So to get our fake hostnames working, they each should have an entry resolving to 127.0.0.1 in your hosts file. Example as follows:

`127.0.0.1        localhost
127.0.0.1        projecta
127.0.0.1        projectb
127.0.0.1        projectc
127.0.0.1        projectc-beta2
192.168.1.18     testhost.testdomain.com testhost`

##### Test the Configuration
To test the configuration, you should ping the fake hosts and if you had followed the steps above correctly, you should get a response from 127.0.0.1 for the projecta, projectb, projectcand projectc-beta2 hosts. This concludes the host resolving section of this tutorial.
Configuring Apache

The next step involves configuring Apache to handle requests to the hosts defined above. To do this, you'll need to edit your Apache installation's configuration file; httpd.conf. On a default Apache for Windows installation, this file will be in C:\Program Files\Apache Group\Apache\conf. For Linux, the location of the httpd.conf file usually depends on the distribution. On Slackware Linux, it's in /etc/apache/.

Open the httpd.conf file in your favourite text editor and look for a line that starts with DocumentRoot. This line sets the location for the files that will be served as your default web site.

On Linux, it will look something like the following (Note that the actual location may differ on your setup):
DocumentRoot "/var/www/htdocs"
Whereas on Windows, it will be similar to (Note that the actual location may differ on your setup):
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
Also note that for Windows, Apache can also use a normal slash (/) instead of the typical backslash () in the directory path. You should also enclose directory paths in quotes. From now on, we'll refer to these directories as DocumentRoot.

If the directories where you want to serve content for the hosts created earlier reside within the DocumentRoot directory, you merely need to define a VirtualHost declaration for each of them. Let's assume that the files for http://projecta will be in the directory named projecta under the DocumentRoot directory (which will be /var/www/htdocs/projecta/for Linux or C:\Program Files\Apache Group\Apache2\htdocs\projecta\ for Windows).
Therefore, at the end of your httpd.conf file, append the following lines to create the projecta virtual host:

For Linux:

`DocumentRoot /var/www/htdocs/projecta
ServerName slackbox`

For Windows:

`DocumentRoot "C:/Program Files/Apache Group/Apache/htdocs/projecta"
ServerName slackbox`

If the files are served from a directory outside of the DocumentRoot, you need to create a Directory declaration for each of the directories in addition to the VirtualHost declaration.

For example, let's assume that files from projectb will be served from /web/projectb (for Linux) or C:\web\projectb (for Windows). Therefore, the following lines should be appended to your httpd.conf file:

For Linux:

`Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
DocumentRoot /web/projectb
ServerName projectb`

For Windows:

`Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
DocumentRoot "C:\web\projectb"
ServerName projectb`

##### Testing the Setup
Once all of the above is done, you can now test your configuration. However, you need to restart the Apache service in order to apply the changes made above. Here's how to do it if you've installed Apache as a service (9 times out of time, this is how it's normally installed):

For Linux (distros using BSD-style init like Slackware):
`/etc/rc.d/rc.httpd restart`

For Linux (distros using sysv-style init like Red Hat):
`service httpd restart`

For Windows:

Run: services.msc
Look for Apache in the services list and select it
Click the Restart Service button

If you've followed through this guide closely, you should now have a working Apache installation with multiple named local sites.


text:
package lithium.community.android.sdk.auth;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

/**
 * Created by saiteja.tokala on 12/5/16.
 */
@RunWith(PowerMockRunner.class)
@PrepareForTest({LiSSOAuthResponse.class})
public class LiSSOAuthResponseTest {

    public static final String TEST_JSON_STRING = "testJsonString";
    public static final String TEST_USER_ID = "testUserId";
    public static final String TEST_STATE = "testState";
    public static final String TEST_API_PROXY_HOST = "testApiProxyHost";
    public static final String TEST_AUTH_CODE = "testAuthCode";
    public static final String TEST_TENANT_ID = "testTenantId";
    private LiSSOAuthResponse liSsoAuthResponse;

    @Before
    public void setupRequest() throws Exception {
        // Mockito has a very convenient way to inject mocks by using the @Mock annotation. To
        // inject the mocks in the test the initMocks method needs to be called.
        MockitoAnnotations.initMocks(this);
        //systemClock= Mockito.mock(LiSystemClock.class);
    }

    @Test
    public void getJsonStringTest() {
        liSsoAuthResponse = new LiSSOAuthResponse();
        liSsoAuthResponse.setJsonString(TEST_JSON_STRING);
        assertNotEquals(null, liSsoAuthResponse.getJsonString());
        assertEquals(TEST_JSON_STRING, liSsoAuthResponse.getJsonString());
    }

    @Test
    public void getUserIdTest() {
        liSsoAuthResponse = new LiSSOAuthResponse();
        liSsoAuthResponse.setUserId(TEST_USER_ID);
        assertNotEquals(null, liSsoAuthResponse.getUserId());
        assertEquals(TEST_USER_ID, liSsoAuthResponse.getUserId());
    }

    @Test
    public void getStateTest() {
        liSsoAuthResponse = new LiSSOAuthResponse();
        liSsoAuthResponse.setState(TEST_STATE);
        assertNotEquals(null, liSsoAuthResponse.getState());
        assertEquals(TEST_STATE, liSsoAuthResponse.getState());
    }

    @Test
    public void getApiProxyHostTest() {
        liSsoAuthResponse = new LiSSOAuthResponse();
        liSsoAuthResponse.setApiProxyHost(TEST_API_PROXY_HOST);
        assertNotEquals(null, liSsoAuthResponse.getApiProxyHost());
        assertEquals(TEST_API_PROXY_HOST, liSsoAuthResponse.getApiProxyHost());
    }

    @Test
    public void getAuthCodeTest() {
        liSsoAuthResponse = new LiSSOAuthResponse();
        liSsoAuthResponse.setAuthCode(TEST_AUTH_CODE);
        assertNotEquals(null, liSsoAuthResponse.getAuthCode());
        assertEquals(TEST_AUTH_CODE, liSsoAuthResponse.getAuthCode());
    }

    @Test
    public void getTenantIdTest() {
        liSsoAuthResponse = new LiSSOAuthResponse();
        liSsoAuthResponse.setTenantId(TEST_TENANT_ID);
        assertNotEquals(null, liSsoAuthResponse.getTenantId());
        assertEquals(TEST_TENANT_ID, liSsoAuthResponse.getTenantId());
    }

}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Uses of Interface javax.security.sasl.SaslServer (Java Platform SE 8 )</title>
<meta name="date" content="2014-12-17">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Java™ Platform
Standard Ed. 8

Prev

Next

Frames

No Frames

All Classes

Uses of Interface
javax.security.sasl.SaslServer

Packages that use SaslServer

Package
Description

javax.security.sasl

Contains class and interfaces for supporting SASL.

Uses of SaslServer in javax.security.sasl

Methods in javax.security.sasl that return SaslServer

Modifier and Type
Method and Description

static SaslServer
Sasl.createSaslServer(String mechanism,
                String protocol,
                String serverName,
                Map<String,?> props,
                CallbackHandler cbh)

Creates a SaslServer for the specified mechanism.

SaslServer
SaslServerFactory.createSaslServer(String mechanism,
                String protocol,
                String serverName,
                Map<String,?> props,
                CallbackHandler cbh)

Creates a SaslServer using the parameters supplied.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Java™ Platform
Standard Ed. 8

Prev

Next

Frames

No Frames

All Classes

 Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2015, Oracle and/or its affiliates.  All rights reserved.


text:
title: http4k Contract Module
description: Feature overview of the http4k-contract module

### Installation (Gradle)

```groovy
implementation group: "org.http4k", name: "http4k-contract", version: "4.34.1.0"
implementation group: "org.http4k", name: "http4k-format-<insert json lib>", version: "4.34.1.0"
```

### About
The `http4k-contract` module adds a much more sophisticated routing mechanism to that available in `http4k-core`. It adds the facility
to declare server-side `Routes` in a completely typesafe way, leveraging the Lens functionality from the core. These `Routes` are combined into `Contracts`, which have the following features:

- **Auto-validating** - the `Route` contract is automatically validated on each call for required-fields and type conversions, removing the requirement  for any validation code to be written by the API user. Invalid calls result in a `HTTP 400 (BAD_REQUEST)` response.
- **Self-describing:** - a generated endpoint is provided which describes all of the `Routes` in that module. Implementations include [OpenApi v2 & v3/Swagger](http://swagger.io/) documentation, including generation of [JSON schema](http://json-schema.org/). These documents can then be used to generate HTTP client and server code in various languages using the [OpenAPI generator](https://openapi-generator.tech/).
 models for messages.
- **Security:** to secure the `Routes` against unauthorised access. Current implementations include `ApiKey`, `BasicAuth`, `BearerAuth` and `OAuth`.

#### Code [<img class="octocat"/>](https://github.com/http4k/http4k/blob/master/src/docs/guide/reference/contracts/example.kt)

<script src="https://gist-it.appspot.com/https://github.com/http4k/http4k/blob/master/src/docs/guide/reference/contracts/example.kt"></script>

When launched, OpenApi/Swagger format documentation (including JSON schema models) can be found at the route of the module.

For a more extended example, see the following example apps:

- [TDD'd example application](https://github.com/http4k/http4k-by-example)
- [Todo backend (typesafe contract version)](https://github.com/http4k/http4k-contract-todo-backend)

### Naming of JSON Schema models
There are currently 2 options for JSON schema generation.

1. *OpenApi v2 & v3:* The standard mechanism can be used with any of the supported http4k JSON modules. It generates
anonymous JSON schema definition names that are then listed in the `schema` section of the OpenApi docs.
```kotlin
    OpenApi3(ApiInfo("title", "1.2", "module description"), Argo)
```
... generates definitions like the following in the schema definitions:
```json
{
  "components": {
    "schemas": {
      "object1283926341": {
        "type": "object",
        "properties": {
          "aString": {
            "type": "string"
          }
        }
      }
    }
  }
}
```

2. *OpenApi v3 only:* By including a supported Auto-JSON marshalling module on the classpath (currently only `http4k-format-jackson`),
the names of the definitions are generated based on the Kotlin class instances provided to the Contract Route DSL. Note that
an overloaded OpenApi function automatically provides the default Jackson instance, so we can remove it from the renderer creation:
```kotlin
    OpenApi3(ApiInfo("title", "1.2", "module description"), Jackson)
```
... generates definitions like the following in the schema definitions:
```json
{
   "components":{
      "schemas":{
          "ArbObject": {
            "properties": {
              "uri": {
                "example": "http://foowang",
                "type": "string"
              }
            },
            "example": {
              "uri": "http://foowang"
            },
            "type": "object",
            "required": [
              "uri"
            ]
          }
      }
   }
}
```


text:
import numpy as np
from scipy.optimize import minimize

def direction(theta, phi):
    '''Return the direction vector of a cylinder defined
    by the spherical coordinates theta and phi.
    '''
    return np.array([np.cos(phi) * np.sin(theta), np.sin(phi) * np.sin(theta),
                     np.cos(theta)])

def projection_matrix(w):
    '''Return the projection matrix  of a direction w.'''
    return np.identity(3) - np.dot(np.reshape(w, (3,1)), np.reshape(w, (1, 3)))

def skew_matrix(w):
    '''Return the skew matrix of a direction w.'''
    return np.array([[0, -w[2], w[1]],
                     [w[2], 0, -w[0]],
                     [-w[1], w[0], 0]])

def calc_A(Ys):
    '''Return the matrix A from a list of Y vectors.'''
    return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3)))
            for Y in Ys)

def calc_A_hat(A, S):
    '''Return the A_hat matrix of A given the skew matrix S'''
    return np.dot(S, np.dot(A, np.transpose(S)))

def preprocess_data(Xs_raw):
    '''Translate the center of mass (COM) of the data to the origin.
    Return the prossed data and the shift of the COM'''
    n = len(Xs_raw)
    Xs_raw_mean = sum(X for X in Xs_raw) / n

    return [X - Xs_raw_mean for X in Xs_raw], Xs_raw_mean

def G(w, Xs):
    '''Calculate the G function given a cylinder direction w and a
    list of data points Xs to be fitted.'''
    n = len(Xs)
    P = projection_matrix(w)
    Ys = [np.dot(P, X) for X in Xs]
    A = calc_A(Ys)
    A_hat = calc_A_hat(A, skew_matrix(w))

    u = sum(np.dot(Y, Y) for Y in Ys) / n
    v = np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys)) / np.trace(np.dot(A_hat, A))

    return sum((np.dot(Y, Y) - u - 2 * np.dot(Y, v)) ** 2 for Y in Ys)

def C(w, Xs):
    '''Calculate the cylinder center given the cylinder direction and
    a list of data points.
    '''
    n = len(Xs)
    P = projection_matrix(w)
    Ys = [np.dot(P, X) for X in Xs]
    A = calc_A(Ys)
    A_hat = calc_A_hat(A, skew_matrix(w))

    return np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys)) / np.trace(np.dot(A_hat, A))

def r(w, Xs):
    '''Calculate the radius given the cylinder direction and a list
    of data points.
    '''
    n = len(Xs)
    P = projection_matrix(w)
    c = C(w, Xs)

    return np.sqrt(sum(np.dot(c - X, np.dot(P, c - X)) for X in Xs) / n)

def fit(data, guess_angles=None):
    '''Fit a list of data points to a cylinder surface. The algorithm implemented
    here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from
    https://www.geometrictools.com/Documentation/CylinderFitting.pdf

    Arguments:
        data - A list of 3D data points to be fitted.
        guess_angles[0] - Guess of the theta angle of the axis direction
        guess_angles[1] - Guess of the phi angle of the axis direction

    Return:
        Direction of the cylinder axis
        A point on the cylinder axis
        Radius of the cylinder
        Fitting error (G function)
    '''
    Xs, t = preprocess_data(data)

    # Set the start points

    start_points = [(0, 0), (np.pi / 2, 0), (np.pi / 2, np.pi / 2)]
    if guess_angles:
        start_points = guess_angles

    # Fit the cylinder from different start points

    best_fit = None
    best_score = float('inf')

    for sp in start_points:
        fitted = minimize(lambda x : G(direction(x[0], x[1]), Xs),
                    sp, method='Powell', tol=1e-6)

        if fitted.fun < best_score:
            best_score = fitted.fun
            best_fit = fitted

    w = direction(best_fit.x[0], best_fit.x[1])

    return w, C(w, Xs) + t, r(w, Xs), best_fit.fun


text:
layout: page
permalink: /sessions/
title: Sessions
---

* [Upcoming Sessions](#upcoming-sessions)
* [TinkerEves](#tinkereves)
* [TinkerNights](#tinkernights)
* [Tech-Quizzes](#tech-quizzes)

## Upcoming Sessions

Coming soon!

## TinkerEves

| TinkerEve[10] | [Intro to Communication Protocols - 2](http://electroholics.iiitd.edu.in/2016/01/30/communication-protocols.html) |
|  TinkerEve[9] | [Intro to Quadcopters](https://github.com/Electroholics/Docs/blob/master/Session%20Slides%20and%20docs/Introduction%20To%20Quadcopters%2016th%20March%2C%202016.pdf) |
|  TinkerEve[8] | [Intro to Communication Protocols](http://electroholics.iiitd.edu.in/2016/01/30/communication-protocols.html) |
|  TinkerEve[7] | [Basics of RLC Circuits](https://github.com/Electroholics/Docs/blob/master/Session%20Slides%20and%20docs/Basics-of-RLC-circuits/Basics%20of%20R%2C%20L%2C%20C%20circuits.pdf) |
|  TinkerEve[6] | System-level PCB Designing |
|  TinkerEve[5] | [Intro to FPGAs](https://github.com/Electroholics/Docs/blob/master/Slides/Introduction%20to%20FPGA.pdf) |
|  TinkerEve[4] | Discussion about Projects |
|  TinkerEve[3] | [PCB Designing](https://github.com/Electroholics/Docs/blob/master/Slides/Session-3%20%5B16-09-2015%5D.pdf) |
|  TinkerEve[2] | 3D Printing |
|  TinkerEve[1] | [Power Supply Design](https://github.com/Electroholics/Docs/blob/master/Slides/Session-1%20%5B01-09-15%5D.pdf) |
|  TinkerEve[0] | [Introduction](https://github.com/Electroholics/Docs/blob/master/Slides/Session-0%20%5BIntro%5D%5B25-08-2015%5D.pdf) |

## TinkerNights

|  TinkerNight[2] | [Basics of ADCs and Timers](https://github.com/Electroholics/Docs/tree/master/Slides/Tinker%20NIght%20%5BIntro%20to%20Embedded%20Systems%5D) |
|  TinkerNight[1] | [Basics of Embedded Programming](https://github.com/Electroholics/Docs/blob/master/Slides/Tinker%20NIght%20%5BIntro%20to%20Embedded%20Systems%5D/Intro%20to%20ES%20and%20GPIO.pdf) |

## Tech-Quizzes

|  TechQuiz[1] | [Signal Processing, Analog Electronics, Embedded Systems, Robotics](https://github.com/Electroholics/Docs/blob/master/Slides/Tech-Quiz%20%20%5B27-10-15%5D.pdf) |


text:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/report_activity_bg"
    tools:context=".MainActivity" >

    <com.example.ulucu.chart.PieChart
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dip"

        >

        <com.example.ulucu.chart.PieView
            android:id="@+id/lotteryView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"

            android:tag="pieView" />

        <com.example.ulucu.chart.MyButton
            android:id="@+id/MyBt"
            android:layout_width="30dip"
            android:layout_height="30dip"
            android:layout_gravity="top|right"
            android:tag="pieButton" />

        <TextView
            android:id="@+id/MyTV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal|top"
            android:layout_marginBottom="16dip"
            android:gravity="center"
            android:tag="pieText"
            android:textColor="#FFF"
            android:textSize="15sp" />

    </com.example.ulucu.chart.PieChart>

</RelativeLayout><!-- From: file:/D:/Andriod%20Project/MyApplication2/chart/src/main/res/layout/activity_main.xml -->