text:
Q: How to Configure SSL over Database in Spring? I want to add SSL security in the Database layer. I am using Struts2.1.6, Spring 2.5, JBOSS 5.0 and Informix 11.5. Any idea how to do this?
I have researched through a lot on the internet but could not find any solution.
Please suggest!
Here is my datasource and entity manager beans which is working perfect without SSL:

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="database" value="INFORMIX" />
            <property name="showSql" value="true" />

        </bean>
    </property>
</bean>

<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.informix.jdbc.IfxDriver" />
    <property name="url"
        value="jdbc:informix-sqli://SERVER_NAME:9088/DB_NAME:INFORMIXSERVER=SERVER_NAME;DELIMIDENT=y;" />
    <property name="username" value="username" />
    <property name="password" value="password" />
    <property name="minIdle" value="2" />
</bean>

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" lazy-init="false">
    <property name="targetObject" ref="dataSource" />
    <property name="targetMethod" value="addConnectionProperty" />
    <property name="arguments">
    <list>
    <value>characterEncoding</value>
    <value>UTF-8</value>
    </list>
    </property>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" scope="prototype">
    <property name="dataSource" ref="dataSource" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />

Thankyou very much for your suggestion. So basically I need to set something like this in my applicationContext.xml, Please correct me if I am wrong:
<property name="username" value="username" />
<property name="password" value="password" />
**<property name="sslConnection" value="true" />**
<property name="minIdle" value="2" />

But how do I set the SSL certificate in java runtime. The link which you have provided is good but for some reason I am not able to follow. Please put your suggestion.

A: Using SSL for the communication between an application and a database is something that has to be supported by the database server (and the JDBC driver).
According to the documentation, this is supported by Informix Dynamic Server (IDS) since version 11.50.

You can use SSL support in your Java applications if you use IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2® for z/OS®  Version 9 or later, to DB2 Database for Linux®, UNIX®, and Windows® Version 9.1, Fix Pack 2 or later, or to IBM Informix® Dynamic Server (IDS) Version 11.50 or later.
(...)
To use SSL connections, you need to:

*

*Configure connections to the data source to use SSL. (link)

*Configure your Java Runtime Environment to use SSL. (link)

The documentation should help.
If you're using a version of IDS prior to 11.50, then I'm afraid you'll have to use SSH tunneling.


text:
Q: How to call or inject a card.component.html into map.component.ts I would to know how to call or inject a HTML file from one component, to a ts file to another component. Example:
I had been working with mapbox-js, and, I have a component called popup.component.html, and I have another called, mini-map.component.ts. I'm making a process with a forEach, which is assign a popup to each marker that will be put on the map.
mini-map.component.ts
setMarkerForBounding(shipmentsDataPosition){

    shipmentsDataPosition.forEach((shipmentPosition) => {
      const popup = new mapboxgl.Popup({ offset: 25 }).setHTML(
        `${popup.component.html}`
      );
      const customMarker = this.createMarker();
      new mapboxgl.Marker({element: customMarker})
        .setLngLat(shipmentPosition)
        .setPopup(popup)
        .addTo(this.mapa);
    });

    this.getBoundingArea(shipmentsDataPosition);

  }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Python: iterate through dictionary and create list with results I would like to iterate through a dictionary in Python in the form of:
dictionary = {
    'company': {
         0: 'apple',
         1: 'berry',
         2: 'pear'
     },
     'country': {
         0:'GB',
         1:'US',
         2:'US'
     }
}

To grab for example:
every [company, country] if country is "US"
So I get a list in the form:
[["berry", "US"], ["pear", "US"]]

A: I suppose your keys are strings as well and the output is a list of lists, where the elements are strings, too. Then this problem can be solved via list comprehension.
The idea is to use list comprehension to fill the list of [company, country]-lists, but only if the country is 'US'. key represents the keys of the inner dictionaries (i.e 0, 1, 2).
dictionary = {'company': {0: 'apple', 1: 'berry', 2: 'pear'}, 'country': {0: 'GB', 1: 'US', 2:'US'}}
y = [[dictionary['company'][key], dictionary['country'][key]] for key in dictionary['country'] if dictionary['country'][key] == 'US']

It returns
[['berry', 'US'], ['pear', 'US']]

A: myList = []
list(map(lambda x: myList.append(x) if x[1]=='US' else None,
    zip(dictionary['company'].values(), dictionary['country'].values())))


text:
Q: How to style my TextView and Button Image Inside ListView I want to make an app that have a list of quotes and author that i get from sqlite prepopulated database
I want to make something Like this

So in the Left, i have 2 textviews (1 for the quote, and the other one for the author)
and on the Right, theres a image button that everytime i click the heart image goes from grey to red, and if its clicked again, it turn red to grey
I already populated my listview with database, using 2 textviews and 1 image button from another xml. But i don't know how to style the font and change the image whenever its clicked
here is my code
DatabaseOpenHelper.java
public class DatabaseOpenHelper extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "mqn.db";
private static final int DATABASE_VERSION = 1;

private static final String TABLE_NAME = "quote";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_QUOTES = "quotesText";
public static final String COLUMN_AUTHOR= "author";
public static final String COLUMN_FAV = "fav";

private SQLiteDatabase database;

private final Context context;

// database path
private static String DATABASE_PATH;

/** constructor */
public DatabaseOpenHelper(Context ctx) {
    super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
    this.context = ctx;
    DATABASE_PATH = context.getFilesDir().getParentFile().getPath()
            + "/databases/";

}

/**
 * Creates a empty database on the system and rewrites it with your own
 * database.
 * */
public void create() throws IOException {
    boolean check = checkDataBase();

    SQLiteDatabase db_Read = null;

    // Creates empty database default system path
    db_Read = this.getWritableDatabase();
    db_Read.close();
    try {
        if (!check) {
            copyDataBase();
        }
    } catch (IOException e) {
        throw new Error("Error copying database");
    }
}

/**
 * Check if the database already exist to avoid re-copying the file each
 * time you open the application.
 *
 * @return true if it exists, false if it doesn't
 */
private boolean checkDataBase() {
    SQLiteDatabase checkDB = null;
    try {
        String myPath = DATABASE_PATH + DATABASE_NAME;
        checkDB = SQLiteDatabase.openDatabase(myPath, null,
                SQLiteDatabase.OPEN_READWRITE);
    } catch (SQLiteException e) {
        // database does't exist yet.
    }

    if (checkDB != null) {
        checkDB.close();
    }
    return checkDB != null ? true : false;
}

/**
 * Copies your database from your local assets-folder to the just created
 * empty database in the system folder, from where it can be accessed and
 * handled. This is done by transfering bytestream.
 * */
private void copyDataBase() throws IOException {

    // Open your local db as the input stream
    InputStream myInput = context.getAssets().open(DATABASE_NAME);

    // Path to the just created empty db
    String outFileName = DATABASE_PATH + DATABASE_NAME;

    // Open the empty db as the output stream
    OutputStream myOutput = new FileOutputStream(outFileName);

    // transfer bytes from the inputfile to the outputfile
    byte[] buffer = new byte[1024];
    int length;
    while ((length = myInput.read(buffer)) > 0) {
        myOutput.write(buffer, 0, length);
    }

    // Close the streams
    myOutput.flush();
    myOutput.close();
    myInput.close();

}

/** open the database */
public void open() throws SQLException {
    String myPath = DATABASE_PATH + DATABASE_NAME;
    database = SQLiteDatabase.openDatabase(myPath, null,
            SQLiteDatabase.OPEN_READWRITE);
}

/** close the database */
@Override
public synchronized void close() {
    if (database != null)
        database.close();
    super.close();
}

// insert a user into the database
public long insertUser(String quotesText, String author, String fav) {
    ContentValues initialValues = new ContentValues();
    initialValues.put(COLUMN_QUOTES, quotesText );
    initialValues.put(COLUMN_AUTHOR, author);
    initialValues.put(COLUMN_FAV, fav);
    return database.insert(TABLE_NAME, null, initialValues);
}

// updates a user
public boolean updateUser(long rowId, String quotesText, String author,
                          String fav) {
    ContentValues args = new ContentValues();
    args.put(COLUMN_QUOTES, quotesText);
    args.put(COLUMN_AUTHOR, author);
    args.put(COLUMN_FAV, fav);
    return database.update(TABLE_NAME, args, COLUMN_ID + "=" + rowId, null) > 0;
}

// retrieves a particular user
public Cursor getUser(long rowId) throws SQLException {
    Cursor mCursor = database.query(true, TABLE_NAME, new String[] {
                    COLUMN_ID, COLUMN_QUOTES, COLUMN_AUTHOR, COLUMN_FAV },
            COLUMN_ID + " = " + rowId, null, null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
    }

    return mCursor;
}

// delete a particular user
public boolean deleteContact(long rowId) {
    return database.delete(TABLE_NAME, COLUMN_ID + "=" + rowId, null) > 0;
}

// retrieves all users
public Cursor getAllUsers() {
    return database.query(TABLE_NAME, new String[] { COLUMN_ID,
                    COLUMN_QUOTES, COLUMN_AUTHOR, COLUMN_FAV }, null, null,
            null, null, null);
}

@Override
public void onCreate(SQLiteDatabase arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub

}

}

QuotesActivity.java
public class QuotesActivity extends AppCompatActivity {

TextView title;
Typeface myFont;
ListView quotesList;
ListView favLV;
DatabaseOpenHelper myDbHelper;
DatabaseAccess databaseAccess;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quotes);

    myDbHelper = new DatabaseOpenHelper(this);

    try {
        // check if database exists in app path, if not copy it from assets
        myDbHelper.create();
    } catch (IOException ioe) {
        throw new Error("Unable to create database");
    }

    try {
        // open the database
        myDbHelper.open();
        myDbHelper.getWritableDatabase();
    } catch (SQLException sqle) {
        throw sqle;
    }

    populateListView();

    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    toolbar.setNavigationIcon(R.drawable.back_button);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    title = (TextView) findViewById(R.id.titleQuote);
    myFont =  Typeface.createFromAsset(getAssets(), "Montserrat-Bold.otf");
    title.setTypeface(myFont);
    title.setTextSize(20);
    title.setTextColor(Color.rgb(240, 239, 223));

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

private void populateListView() {
    Cursor cursor = myDbHelper.getAllUsers();
    String[] from = new String[] {myDbHelper.COLUMN_QUOTES, myDbHelper.COLUMN_AUTHOR};
    int[] to = new int[] {R.id.quoteLV, R.id.authorLV};
    SimpleCursorAdapter myCursorAdapter;
    myCursorAdapter = new SimpleCursorAdapter(getBaseContext(), R.layout.quotes_listview, cursor, from, to,0);
    quotesList = (ListView) findViewById(R.id.quotesList);
    quotesList.setAdapter(myCursorAdapter);
}
}

Content_quotes.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="hendrasetiawan.mqn.QuotesActivity"
tools:showIn="@layout/activity_quotes">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/quotesList"
            android:layout_gravity="right"
            android:layout_weight="1" />

        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/favList"
            android:layout_weight="6" />

    </LinearLayout>

</LinearLayout>
</LinearLayout>

quotes_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/quoteLV"
    android:textSize="20dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/authorLV"
    android:textSize="20dp"/>
</LinearLayout>

Everytime i try to set the size of the font / change the typeface in Quotes Activity
i always get an on a null object reference android error
EDIT POST
My LogCat
(Note = My quoteLV and authorLV are now text1 and text2)
And i try to put text1.setTextSize(50); in populateView()
03-23 17:23:30.621 26550-26550/? I/art: Late-enabling -Xcheck:jni
03-23 17:23:30.659 26550-26550/hendrasetiawan.mqn W/System: ClassLoader referenced unknown path: /data/app/hendrasetiawan.mqn-1/lib/arm
03-23 17:23:30.953 26550-26590/hendrasetiawan.mqn D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
03-23 17:23:30.996 26550-26590/hendrasetiawan.mqn I/Adreno-EGL: : QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb
03-23 17:23:30.999 26550-26590/hendrasetiawan.mqn I/OpenGLRenderer: Initialized EGL, version 1.4
03-23 17:23:32.201 26550-26550/hendrasetiawan.mqn I/SQLiteAssetHelper: successfully opened database mqn.db
03-23 17:23:32.205 26550-26550/hendrasetiawan.mqn I/SQLiteAssetHelper: successfully opened database mqn.db
03-23 17:23:32.216 26550-26550/hendrasetiawan.mqn D/AndroidRuntime: Shutting down VM
03-23 17:23:32.217 26550-26550/hendrasetiawan.mqn E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: hendrasetiawan.mqn, PID: 26550
                                                                    java.lang.RuntimeException: Unable to start activity ComponentInfo{hendrasetiawan.mqn/hendrasetiawan.mqn.QuotesActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTextSize(float)' on a null object reference
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                        at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTextSize(float)' on a null object reference
                                                                        at hendrasetiawan.mqn.QuotesActivity.populateListView(QuotesActivity.java:83)
                                                                        at hendrasetiawan.mqn.QuotesActivity.onCreate(QuotesActivity.java:78)
                                                                        at android.app.Activity.performCreate(Activity.java:6251)
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                        at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-23 17:28:32.266 26550-26550/hendrasetiawan.mqn I/Process: Sending signal. PID: 26550 SIG: 9
NEW EDIT POST
content_quotes.xml
Inside here i only have 1 ListView
inside_listview.xml
Inside here i have 2 textViews and 1 ButtonImage
Quotes Activity
This java, SetContentView the content_quotes.xml
so when i style everything in content_quotes.xml, i can do it easily
And now, i fetch all of the quotes and author from database
to the 2 textviews (which is the inside_listview.xml)
and everytime i tried to style it the 2 textviews, i always got an error
is it because it came from another XML ??

A: To style favorite image button:
i haven't seen your code. you said you have populated your list view and have your item with two text views and an image button.
Change from image button to check box so turning heart button into red and gray will be easy.
in your item.xml have check box like this.
 <CheckBox
    android:layout_margin="8dp"
    android:layout_gravity="right|top"
    android:button="@null"
    android:id="@+id/id_homeListing_fav"
    android:drawableTop="@drawable/fav"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

note drawableTop tag its pointing to the fav.xml file, in your fav.xml file specify drawables for different states like checked and unchecked
note button tag which is null
code for fav.xml
<?xml version="1.0" encoding="utf-8"?>
  <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:drawable="@drawable/ic_fav_primary" android:state_checked="true"></item>
     <item android:drawable="@drawable/ic_fav_gray" android:state_checked="false"
    />

in above fav.xml
ic_fav_primary is your red icon and the other is gray icon.
then setOnChangeListner to the check box and do the actions accordingly.
and for customizing the text font See this Link

A: To change the font:

*

*Download the font you would like to use from the internet. This seems to be almost the same as your image: http://www.fontspring.com/fonts/typoforge-studio/cervo?utm_source=fontsquirrel.com&utm_medium=matcherator_link&utm_campaign=cervo

*Create a src/main/assets/fonts/ folder

*Move the downloaded ttf or otf font file to the folder

*Apply the downloaded font:Typeface type = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf");
txtyour.setTypeface(type);

To change the image after clicking on the layout
yourTextView.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
          yourImageView.setImageDrawable(R.drawable.image);
     }
});

Add some padding to both the TextView and the ImageView
android:padding="8dp"

This should give you an idea of how to style your layouts


text:
Q: LibGDX - How do I render two textures with different scales in a single shader? I'm trying to scale a texture produced in an FBO with a different scale than that of another texture and render both textures at the same time in a fragment shader so that I can blend them together.
I followed this tutorial to produce a lightmap for my game and I got a lightmap that works perfectly, but I want to transform the lightmap in the shader so that parallaxed objects in the background receive a proportionally scaled lightmap, so that their "3D" distance to a light source doesn't seem to affect their lighting, but their 2D distance does.
My best guess as to how to do this would be to scale the lightmap in place based on a parallaxed object's Z distance. Z distance in my game is directly proportional to an object's 2D distance to the camera.
Here are examples depicting what happens with the regular lightmap and what the desired effect would be. The lightmap here consists of a yellow radial gradient that is positioned at the yellow non-parallaxed "sun" off to the right:
Description of lightmap scaling
Animated example of current lighting
Animated example of intended lighting
Normally in my game, I scale parallax objects by zooming the camera attached to the SpriteBatch through something like this in LibGDX:
Array<Something> objects = new Array<Something>();
SpriteBatch batch = new SpriteBatch();
OrthographicCamera camera = new OrthographicCamera(screenWidth, screenHeight);

//{start loop, add objects, run logic, etc.}
...

for(int i=0;i<objects.size;i++){
   camera.zoom = objects.get(i).z;
   camera.update();
   batch.setProjectionMatrix(camera.combined);
   objects.get(i).sprite.draw(batch);
}

From what I've researched, there should be a way to do these kinds of transformations in the vertex shader. Doing such a transformation is straightforward through the default LibGDX vertex shader, which is set up to multiply the vertex position with the camera's transformation matrix like so:
void main() {
    v_color = a_color;
    v_texCoords = a_texCoord0;

    gl_Position =  u_projTrans * a_position;
}

But I'm not sure how I could scale only one of the two textures used in the fragment shader when the transformation is tied to the shared vertex position. For reference, here is the fragment shader as implemented from the tutorial:
void main() {
    vec4 diffuseColor = texture2D(u_texture, v_texCoords);

    vec2 lightCoord = (gl_FragCoord.xy / resolution.xy);
    vec4 light = texture2D(u_lightmap, lightCoord);

    vec3 ambient = ambientColor.rgb * ambientColor.a;
    vec3 intensity = ambient + light.rgb;
    vec3 finalColor = diffuseColor.rgb * intensity;

    gl_FragColor = v_color * vec4(finalColor, diffuseColor.a);
}

I think that it has to do with transforming the texture coordinates instead of the position and passing them to the lightmap instead of using the screen resolution to obtain the texture coordinates, but my attempts at doing so end up as a big mess because I'm not very knowledgeable of or experienced with OpenGL ES 2 or GLSL.
Is there a good method for scaling one texture in a two texture fragment shader differently than the other one? Or is there a better way to achieve what I'm trying to do with the lightmap?
Edit:
So I can accomplish what I'm trying to do by recreating the FBO lightmap at a different scale for each parallaxed object, but this creates huge performance problems for one of my intended platforms (Android).
I found some links that show that what I'm trying to do is possible, but they both describe passing in two different texture coordinates to the vertex shader, which doesn't seem to work with SpriteBatch. Is it possible to transform texture coordinates in the vertex shader so that I can pass transformed coordinates for the lightmap to the fragment shader? Or am I misunderstanding something about how texture coordinates work?

A: First of all, just in case I'm right in assuming that Something represent a single sprite: Every time you call batch.setProjectionMatrix(), the sprite batch is flushed, resulting in another draw call, which will be too many if you have more than a few dozen sprites. With your method of sending your array of objects to the sprite batch, you should have them sorted by z position, and then only call batch.setProjectionMatrix() if the z has changed since the last call of batch.draw(). I personally would keep a separate array of objects for each parallax layer to keep it simple and not worry about sorting.
Proceding from there:
First, when drawing your lightmap, do it for the smallest zoom your game will be supporting, so you won't ever have to scale your lightmap down and risk showing the clipped edges of your lightmap. So after fbo.begin(), make sure your cam.zoom is changed to your minimum cam.zoom for the scene.
To get a scaled lightmap coordinate, you need to calculate it in your vertex shader and pass it down to the fragment shader. First of all, you need the zoom level for your input, so you need to pass that in as a uniform. You can do that like this:
//including the changes explained way above, where objectLayers is an
//Array<LayerWrapper>, where LayerWrapper contains a zoom value and
//an Array<Something>
for(int i=0;i<objectLayers.size;i++){
    LayerWrapper layer = objectLayers.get(i);
    Array<Something> layerObjects = layer.objects;

    camera.zoom = layer.zoom;
    camera.update();
    batch.setProjectionMatrix(camera.combined);

    //update the zoom level in the shader you're using with the sprite batch
    customShader.bind();
    customShader.setUniformf("u_zoom", layer.zoom);

    for(Something object : layerObjects ){
        object.sprite.draw(batch);
    }
}

Then update your vertex shader to declare uniform float u_zoom; and varying vec2 v_lightCoords;. Your light coordinates will be scaled up based on zoom. And as long as we're passing a varying, we should also pre-calculate the exact texture coordinates, so you don't have to do it in the fragment shader, which results in a dependent texture read (an optimization that could have been done in the tutorial to begin with).
The vertex shader now looks like this:
void main()
{
    v_color = a_color;
    v_texCoords = a_texCoord0;
    vec4 screenSpacePosition = u_projTrans * a_position;
    gl_Position =  screenSpacePosition;

    v_lightCoords = (screenSpacePosition.xy * u_zoom) * 0.5 + 0.5;
}

Since v_lightCoordsalready has texture coordinates built in, you can simplify your fragment shader to do your texture lookup like this:
    vec4 Light = texture2D(u_lightmap, v_lightCoords);
and remove uniform vec2 resolution; which is no longer needed.


text:
Q: Upgrading Silverlight application while in use on clients I have a Silverlight 5 application which communicates with the server by a WCF service.
Most users that use the application are running it inside a browser (mostly Internet Explorer, but also other browsers are used) and a few install it OOB (Out Of Browser).
When the application starts, It checks for newer versions and upgrade if necessarily. Nothing out of the ordinary here.
Now and then, mostly in evenings and weekends, I do upgrades on the solution. That may be changes in the database, changes in the WCF service, changes in the Silverlight application itself, or a mix of all. And in most cases, that is absolutely no problem.
My problem is that some users never close their web browser. Some users even work via a Citrix window, and only close the Citrix window and goes home after work, letting the Silverlight application run and exist in the web browser. And some just don't close the browser at all.
Or if they run OOB, they let the application stay open. Those are my problem. Because they will never check for new updates. The Silverlight application will never upgrade, and also not fit to the new WCF service which may be upgraded.
That all makes the Silverlight applications crash and throw strange exceptions because the world around has changed.
Has anyone had similar problems and actually found a good solution?
I have tried:

*

*Creating a Timer that resets at any keyboard- or mouse clicks and exits the application after a given period of time with no activity. But it seems like this timer sometimes don't count, like when dosconnected from RDP or Citrix session.

*Checking for updates every time a certain control or window is showing. But that is not a good solution because all users may not use the same. It may also interrupt the user if they are working with something.
But they all seem to me like a little tacky work-arounds.
Any suggestions, anyone?

A: Restarting the timer while the user is active does not make sense to me. What if they are active at the time an update is released? Surely it is better to be interrupted than for the app to fall over?
Better to run the timer on a fixed interval. It would call CheckAndDownloadUpdateAsync and prompt the user if a restart is required.
For the fringe cases where the timer doesn't run or a critical update is published between intervals, you could try executing your update logic in the App.Application_UnhandledException method.
Just don't forget to mark the event as handled where you find there is indeed an update to install...
This way you should have complete coverage.

Edit: For In-Browser applications you only need to worry about when to refresh the page, as this can be enough to ensure the XAP is the latest.
Your timer could call some JavaScript to achieve this, but I think it would be better to simply trigger the refresh in the App.Application_UnhandledException event. You could write state to IsolatedStorage before hand if you really want to make this seamless.


text:
Q: How to show unread/read status of forum post's like vbulletin, phpbb, others? This is the million dollar question, I see it time and time again on here and other php coding related sites and forums but I have NEVER seen an answer to it.
So I started digging in and studying how some of the big high traffic forums accomplish this feature of showing you which threads have new unread posts in them and it appears that they store the thread ID number into a user cookie.  So there would be a cookie with a thread ID of every thread you have read within a certain amount of time.  Or something similar to this.
I then read on here that cookies can only store X amount of characters, so I am wanting to know how much data can be stored in a cookie?  If I have a 5-6 character ID number, how many could I fit into a cookie?

A:
More importantly though, the cookie specification says that browsers need only accept 20 cookies per domain.  This limit is increased to 50 by Firefox, and to 30 by Opera, but IE6 and IE7 enforce the limit of 20 cookie per domain.  Any cookies beyond this limit will either knock out an older cookie or be ignored/rejected by the browser.

Taken from this author's post
I believe for the unread/read status of forum posts should be done through the database. I could not find an example online, but I have read "PHP and MySQL Web Development (4th Edition)" and they have a section devoted to developing your own forum page. They supply example code and explain the process to get it started.

A: cookie limit in ie :
at most 300 cookies
at most 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header)
at most 20 cookies per unique host or domain name

A: I don't think they use cookie since that isn't going to persist if you switch computers (unless it's DB-based cookies that some frameworks provide). I'd assume they have a relationship table in the database that keep track of the latest date a user viewed a thread.


text:
Q: Open my Own Mac App Preferences I am newbie in Cocoa Application.
I want to programmatically open my application's preferences window
By googling,
I can just found -->
[[NSWorkspace sharedWorkspace] openFile:@"MyApp.prefPane"];"
Any help would be appreciated.---
Thanks.

A: You open the preference window just like any other within your app:
In App Delegate class:
- (IBAction)showPreferencePanel:(id)sender {
    if (!_preferenceController)
        _preferenceController = [[PreferenceController alloc] init];

    [_preferenceController showWindow:self];
}

Where PreferenceController is:
@interface PreferenceController : NSWindowController <NSWindowDelegate, NSToolbarDelegate, FontChooserViewDelegate>
...
@end

And in MainMenu.xib the showPreferencePanel method is hooked in like this:


text:
Q: How can I set leading zeros in AssemblyVersion like "2.03.406.2" in .net just adding a zero like below
[assembly: AssemblyVersion("2.03.406.2")]

results in 2.3.406.2
which is not what I want.
So this may not be possible?

A: Each portion of the assembly version is stored as a 16-bit integer, so no, it's not possible.

A: Probably you can read AssemblyFileVersionAttribute
AssemblyFileVersionAttribute[] attributes = (AssemblyFileVersionAttribute[])typeof(Program)
    .Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
Console.WriteLine(attributes[0].Version);

A: Each number represents a specific numerical value, Major, Minor, Build and Revision.
It isn't just an arbitary string.


text:
Q: Rails: How do I get only the saved models with .collection? I have a model Post that has_many of model Comment.
On a Posts show action, there is a list of Comments found with @comments = @post.comments.
I also have a form for creating new Comments. The form has its object created with @comment = @post.comments.build.
This all works for listing and successfully creating comments.
The problem occurs when there is an error when the comment is submitted. The errors are shown in the same form (so, on Post#show) via render "posts/show".
In this case, I have to set @comments = @post.comments again, but this time the list of comments includes the not-yet-saved comment that the user is trying to create.
I solved it by using @post.comments.all, which only gives me the saved models, but Rails complains that this is deprecated in Rails 4.
How do I remove the unsaved comment from the list of comments I get from @post.comments?

A: I ran into a similar issue with a Rails 5 application. This seemed like the most straightforward approach:
@comment = @post.comments.build
@comments = @post.comments.where.not(id: nil)

A: You could add a scope to the comment model to find only database rows instead of in memory data, for example:
class Comment < ActiveRecord::Base
  scope :by_post, ->(post) { where(post: post) }
end

called by: @comments = Comment.by_post(@post)

A: The most efficient way imho is just to ignore the new record in the view, instead of retrieving all comments again.
So in your view you will do something like:
= f.simple_fields_for :comments do |c|
  - unless c.object.new_record?
    = render 'comment_fields', :f => c

A: You can force load the comments. You have to do it like this:-
@comments = @post.comments(true)


text:
Q: Flutter: how to get the http response header The way I tried to post a data to the server, and then the server return the detail message which is encapsulated in response header for me, how to get this message out of response header?
var response = await http.post(...);
var detail_message = response['header'];

A: You must decode your response data if header response
var decodedData = jsonDecode(response);
var detail_message = decodedData['header'];

Otherwise:
var detail_message = response.headers;

A: https://pub.dev/documentation/http/latest/http/Response-class.html
var response = await http.post(...);
print('Response status: ${response.statusCode}');
print('Response body: ${response.headers}');
print('Response body: ${response.body}');


text:
Q: Trying to understand "pointer to member" I'm trying to understand how "pointer to member" works but not everything is clear for me.
Here is an example class:
class T
{
public:
    int a;
    int b[10];
    void fun(){}
};

The following code ilustrate the problem and contains questions:
void fun(){};

void main()
{
   T obj;
   int local;
   int arr[10];
   int arrArr[10][10];

   int *p = &local;   // "standard" pointer
   int T::*p = &T::a; // "pointer to member" + "T::" , that is clear

   void (*pF)() = fun;        //here also everything is clear
   void (T::*pF)() = T::fun;
   //or
   void (T::*pF)() = &T::fun;

   int *pA = arr; // ok
   int T::*pA = T::b; // error

   int (T::*pA)[10] = T::b; // error
   int (T::*pA)[10] = &T::b; //works;

//1. Why "&" is needed for "T::b" ? For "standard" pointer an array name is the representation of the
//   address of the first element of the array.

//2. Why "&" is not needed for the pointer to member function ? For "standard" pointer a function name
//   is the representation of the function address, so we can write &funName or just funName when assigning to the pointer.
//   That's rule works there.

//3. Why the above pointer declaration looks like the following pointer declaration ?:

   int (*pAA)[10] = arrArr; // Here a pointer is set to the array of arrays not to the array.
   system("pause");
}

A:
Why "&" is needed for "T::b" ?

Because the standard requires it. This is to distinguish it from accessing a static class member.
From a standard draft n3337, paragraph 5.3.1/4, emphasis mine:

A pointer to member is only formed when an explicit & is used and its operand is a  qualified-id not enclosed
  in parentheses. [Note: that is, the expression &(qualified-id), where the qualified-id is enclosed in
  parentheses, does not form an expression of type "pointer to member." Neither does qualified-id, because
  there is no implicit conversion from a qualified-id for a non-static member function to the type "pointer to
  member function" as there is from an lvalue of function type to the type "pointer to function" (4.3). Nor is
  &unqualified-id a pointer to member, even within the scope of the unqualified-id's class. — end note]

For "standard" pointer an array name is the representation of the address of the first element of the array.

Not really. An array automatically converts to a pointer to first element, where required. The name of an array is an array, period.

Why "&" is not needed for the pointer to member function ?

It is needed. If your compiler allows it, it's got a bug. See the standardese above.

For "standard" pointer a function name is the representation of the function address, so we can write &funName or just funName when assigning to the pointer.

The same thing aplies here as for arrays. There's an automatic conversion but otherwise a function has got a function type.
Consider:
#include <iostream>

template<typename T, size_t N>
void foo(T (&)[N]) { std::cout << "array\n"; }

template<typename T>
void foo(T*) { std::cout << "pointer\n"; }

int main()
{
    int a[5];
    foo(a);
}

Output is array.
Likewise for functions pointers:
#include <iostream>

template<typename T>
struct X;

template<typename T, typename U>
struct X<T(U)> {
    void foo() { std::cout << "function\n"; }
};

template<typename T, typename U>
struct X<T(*)(U)> {
    void foo() { std::cout << "function pointer\n"; }
};

void bar(int) {}

int main()
{
    X<decltype(bar)> x;
    x.foo();
}

Output is function.

And a clarification about this, because I'm not sure what exactly your comment is meant to say:
int arrArr[10][10];
int (*pAA)[10] = arrArr; // Here a pointer is set to the array of arrays not to the array.

Again, array-to-pointer conversion. Note that the elements of arrArr are int[10]s. pAA points to the first element of arrArr which is an array of 10 ints located at &arrArr[0]. If you increment pAA it'll be equal to &arrArr[1] (so naming it pA would be more appropriate).
If you wanted a pointer to arrArr as a whole, you need to say:
int (*pAA)[10][10] = &arrArr;

Incrementing pAA will now take you just past the end of arrArr, that's 100 ints away.

A: I think the simplest thing is to forget about the class members for a moment, and recap pointers and decay.
int local;
int array[10];

int *p = &local; // "standard" pointer to int

There is a tendency for people to say that a "decayed pointer" is the same as a pointer to the array.  But there is an important difference between arr and &arr.  The former does not decay into the latter
int (*p_array_standard)[10] = &arr;

If you do &arr, you get a pointer to an array-of-10-ints.  This is different from a pointer to an array-of-9-ints.  And it's different from a pointer-to-int.  sizeof(*p_array_standard) == 10 * sizeof(int).
If you want a pointer to the first element, i.e. a pointer to an int, with sizeof(*p) == sizeof(int)), then you can do:
int *p_standard = &(arr[0);

Everything so far is based on standard/explicit pointers.
There is a special rule in C which allows you to replace &(arr[0]) with arr.  You can initialize an int* with &(arr[0]) or with arr.  But if you actually want a pointer-to-array, you must do int (*p_array_standard)[10] = &arr;
I think the decaying could almost be dismissed as a piece of syntactic sugar.  The decaying doesn't change the meaning of any existing code.  It simply allows code that would otherwise be illegal to become legal.
int *p = arr; // assigning a pointer with an array.  Why should that work?
                  // It works, but only because of a special dispensation.

When an array decays, it decays to a pointer to a single element int [10] -> int*.  It does not decay to a pointer to the array, that would be int (*p)[10].

Now, we can look at this line from your question:
int (T::*pA3)[10] = T::b; // error

Again, the class member is not relevant to understanding why this failed.  The type on the left is a pointer-to-array-of-ints, not a pointer-to-int.  Therefore, as we said earlier, decaying is not relevant and you need & to get the pointer-to-array-of-ints type.
A better question would be to ask why this doesn't work  (Update: I see now that you did have this in your question.)
int T::*pA3 = T::b;

The right hand side looks like an array, and the left hand side is a pointer to a single element int *, and therefore you could reasonably ask: Why doesn't decay work here?
To understand why decay is difficult here, let's "undo" the syntactic sugar, and replace T::b with &(T::b[0]).
int T::*pA3 = &(T::b[0]);

I think this is the question that you're interested in.  We've removed the decaying in order to focus on the real issue.  This line works with non-member objects, why doesn't it work with member objects?
The simple answer is that the standard doesn't require it.  Pointer-decay is a piece of syntactic sugar, and they simply didn't specify that it must work in cases like this.
Pointers-to-members are basically a little fussier than other pointers.  They must point directly at the 'raw' entity as it appears in the object.
(Sorry, I mean it should refer (indirectly) by encoding the offset between the start of the class and the location of this member. But I'm not very good at explaining this.)
They can't point to sub-objects, such as the first element of the array, or indeed the second element of the array.
Q: Now I have a question of my own.  Could pointer decay be extended to work on member arrays like this?  I think it makes some sense.  I'm not the only one to think of this!  See this discussion for more.  It's possible, and I guess there's nothing stopping a compiler from implementing it as an extension.  Subobjects, including array members, are at a fixed offset from the start of the class, so this is pretty logical.

A: The first thing to note is that arrays decay into pointers to the first element.
int T::*pA = T::b;

There are two issues here, or maybe one, or more than two... The first is the subexpression T::b. The b member variable is not static, and cannot be accessed with that syntax. For pointer to members you need to always use the address-of operator:
int T::*pa = &T::b;  // still wrong

Now the problem is that the right hand side has type int (T::*)[10] that does not match the left hand side, and that will fail to compile. If you fix the type on the left you get:
int (T::*pa)[10] = &T::b;

Which is correct. The confusion might have risen by the fact that arrays tend to decay to the first element, so maybe the issue was with the previous expression: int *p = a; which is transformed by the compiler into the more explicit int *p = &a[0];. Arrays and functions have a tendency to decay, but no other element in the language does. And T::b is not an array.

Edit: I skipped the part about functions...
   void (*pF)() = fun;        //here also everything is clear
   void (T::*pF)() = T::fun;
   //or
   void (T::*pF)() = &T::fun;

It might not be as clear as it seems. The statement void (T::*pf)() = T::fun; is illegal in C++, the compiler you use is accepting it for no good reason. The correct code is the last one: void (T::*pf)() = &T::fun;.

A:
Why "&" is needed for "T::b" ?

Because that's how the language is specified. It was decided not to complicate the language with a member-to-pointer conversion just for the sake of saving a single character even though, for historical reasons, we have similar conversions for arrays and functions.

For "standard" pointer an array name is the representation of the address of the first element of the array.

No it isn't; it's convertible to a pointer to its first element due to an arcane conversion rule inherited from C. Unfortunately, that's given rise to a widespread (and wrong) belief that an array is a pointer. This kind of confusion is probably part of the reason for not introducing similar bizarre conversions for member pointers.

Why "&" is not needed for the pointer to member function ?

It is. However, your compiler accepts the incorrect void main(), so it may accept other broken code.

For "standard" pointer a function name is the representation of the function address, so we can write &funName or just funName when assigning to the pointer.

Again, the function name isn't a pointer; it's just convertible to one.

Why the above pointer declaration looks like the following pointer declaration ?

One is a pointer to an array, the other is a pointer to a member array. They are quite similar, and so look quite similar, apart from the difference which indicates that one's a member pointer and the other's a normal pointer.

A: int (T::*pA)[10] = &T::b; //works;

3.Why the above pointer declaration looks like the following pointer declaration ?

int (*pAA)[10] = arrArr;

To understand this, we needn't confuse ourselves with member arrays, simple arrays are good enough. Say've we two
int a[5];
int a_of_a[10][5];

The first (left-most) dimension of the array decays and we get a pointer to the first element of the array, when we use just the array's name. E.g.
int *pa = a;                 // first element is an int for "a"
int (*pa_of_a)[5] = a_of_a;  // first element is an array of 5 ints for "a_of_a"

So without using & operator on the array, when we assign its name to pointers, or pass it to function as arguments, it decays as explained and gives a pointer to its first element. However, when we use the & operator, the decay doesn't happen since we're asking for the address of the array and not using the array name as-is. Thus the pointer we get would be to the actual type of the array without any decay. E.g.
int (*paa) [5] = &a;                   // note the '&'
int (*paa_of_a) [10][5] = &a_of_a;

Now in your question the upper declaration is a pointer to an array's address without the decay (one dimension stays one dimension), while the lower declaration is a pointer to an array name with decay (two dimensions become one dimension). Thus both the pointers are to an array of same single dimension and look the same. In our example
int (*pa_of_a)[5]
int (*paa) [5]

notice that the types of these pointers are the same int (*) [5] although the value they point to are of different array's.

A: Because T on it's own already has a well defined meaning: the type Class T.  So things like T::b are logically used to mean members of Class T.  To get the address of these members we need more syntax, namely &T::b.  These factors don't come into play with free functions and arrays.

A: A pointer to a class or struct type points to an object in memory.
A pointer to a member of a class type actually points to an offset from the start of the object.
You can think of these kind of pointers as pointers to blocks of memory. These need an actual address and offset, hence the &.
A pointer to function points to the access point of the function in the assembly code. A member method in general is the same as a function that passes a this pointer as the first argument.
That's in crude nut shell the logic behind needing a & to get the address for members and object address in general.

A: void (*pF)() = fun;        //here also everything is clear

It doesn't work because function fun is undefined
int T::*pA = T::b; // error

What is T::b? T::b is not static member. So you need specific object. Instead write
int *pA = &obj.b[0];

Similarly,
int (T::*pA)[10] = &T::b; //works;

It can be compiled. But it will not work as you expected. Make b static or call obj.b to get access to defined member of defined object. We can easily check this. Create conctructor for your class T
class T
{
public:
    T() {
        a = 444;
    }
    int a;
    int b[10];
    void fun(){}
};

On what value points pA ?
 int T::*pA = &T::a;

*pA doesn't not point on variable with value 444, because no object has been created, no constructor has been called.


text:
Q: Integrating Gendarme reports into SonarQube I'd like to import gendarme reports into sonarqube.
A sonar-csharp-gendarme-plugin existed once for this purpose, but seems to have been abandoned.
Is there any replacement?

A: There is no replacement, and it is not supported. Gendarme is an inactive project for quite a while, and I really doubt its development will resume: Indeed, like FxCop, it does analysis based on the assemblies, not directly on the source code.
Now, with Visual Studio 2015, Roslyn analyzers are executed live as you type. This raised the bar of what people expect from code analyzers, and FxCop analyzers as well as Gendarme ones should be rewritten using Roslyn to improve the end-user's experience.
Now, if you really would like to, you still could develop a SonarQube plugin to integrate Gendarme results, but I don't think it is a good idea.


text:
Q: How do I use sqlalchemy to order results by a list? Suppose I have an Inventory table, with a status column with the following possible values: voided, to_order, priority, received and ordered.
When I query the database I would like to order the status column in this order:
to_order, priority, received, ordered, voided.

How do I use sqlalchemy to order my results by a list order?
My starting point is this: sort = desc(Inventory.status), and I'm unaware as to define my own sort order.

A: You'll have to resort to the ORDER BY + CASE combination.
Talking about pure SQL first, have a look at this example.
ORDER BY (
    CASE currency_code

    WHEN 'USD'
    THEN 1

    WHEN 'EUR'
    THEN 2

    ...

    END
) ASC

Fortunately, it's possible to do exactly this in SQLAlchemy's ORM, combining order_by and case.


text:
Q: Teradata - Numeric overflow occurred during computation I am having an issue with a calculation in one of my Teradata queries.  I am multiplying two numbers by each other but i am getting a "Numeric overflow occurred during computation." error when running the query.  I ran a type on both fields and they are DECIMAL(18,15) and DECIMAL(18,9).  I tried casting them both to DECIMAL(18,18) when i do the division but its still throwing errors.  Here is the calculation. UNITS is the 18,15 and PRICE is the 18,9. Can anyone please give me any tips on how to resolve this?
cast(UNITS as DECIMAL(18,18))* cast(PRICE as DECIMAL(18,18)) as  NEW_CALC

Thanks,
Craig

A: You use wrong datatypes, a DECIMAL(18,15) means 18 digits, 15 of them fractional, so the maximum value is 999.999999999999999.
And when you multiply two decimals, the number of fractional digits adds up, NEW_CALC results in 38 fractional digits. Do a TYPE(cast(UNITS as DECIMAL(18,18))* cast(PRICE as DECIMAL(18,18))).
This will work:
cast(UNITS as DECIMAL(38,15))* PRICE

But you better change the column's datatype to something like (18,2) or (18,4), I don't think anyone uses more than 4 digits for prices.


text:
Q: BAM mediator message header/body definition locations Where is the message header and body in a stream definition is mentioned in a WSO2 BAM mediator? In the Payload Data? Or can it be changed?

A: In BAM mediator, message body or header must be declared in the Payload Data.


text:
Q: Why '1' and (char)1 are not equal when compared in c++? My main goal is to convert int to char type. I used (char)1 to type cast, but it doesn't seem to work due to the following result:
When I compare '1' and (char)1 in c++ in the following code
if ('1' == (char)1)
{
    return 1;
}

However, it seems that the comparison is either invalid due to different variable type or they are actually not the same thing. I always thought converting integer 1 to character is (char)1. Can anyone tell me how I can convert integer 1 to char '1'?

A: '1' is equal to (char)49 according to http://www.asciitable.com/
(char)1 is equal to SOH (start of heading) which is a non-printable character.

A: Because the ASCII equivalent of '1' is 49, not 1.

A: '1' == The character CODE value for the printable 1, traditionally ASCII value, but today, the code point value in whatever charset is used.
The old trick is  (ch - '0') to get the numeric value.
Depending on the language you should use a conversion function for a full string.
C++ - stoi, stol or strol or stringstream
C - atoi or atol (these work in C++ too)

A: As ibiza said, char(49) is in fact what 1 is. This is because char draws from the ASCII library.

A: Because when you do (char)X with X a number, you are just converting X into the range of a char, either -128 to 127 or 0 to 255 (like a modulo).
For example, (char)300 gives 44 (because 300 % 256 = 44) and (char)1 gives 1. As said in the others comments, 1 is the ASCII equivalent of SOH (Start of Heading), and not of the character '1'.


text:
Q: Launching applications silently? My C++ application calls VLC as a subprocess. Is there a way to avoid having the GUI pop-up? I am looking for a Mac and a Windows solution. Hackish workarounds are welcome too.
PS: I know there is such a thing as cvlc (command-line version of VLC), but I haven't found any builds for it online. You do get it when you make the build yourself, but that hasn't worked out yet on my Snow Leopard machine. I also need a Windows version, but I don't feel courageous enough to attempt making a VLC build myself on this platform.
Solved
All I had to do was add the "-I dummy" parameters.

A: I found the answer. VLC allows you to start without GUI by using:
VLC -I dummy
Starts the "dummy" interface.
VLC -I rc
Starts the "remote control" interface, which allows you to send commands using the stdin channel.

A: There are a few options in this thread

A: When you create the VLC instance using the libvlc_new function you have a VLC arguments to not display VLC interface. See this small example.


text:
Q: Multiple conditions under IF in transact SQL I am trying to use 'and' in an If condition as follows:
Begin
If condition1 and condition2
then begin result1
end else begin result2;
End;
end;

what is wrong in the statement. Could anybody help in thei matter? Thanks!

A: As a wild guess, lose the 'then' (SFrejofsky's comment), and lose the first ; which is inside of a begin..end block.
Also if there is only executable line in a block then begin..end is not needed, so your code should look like this
If condition1 and condition2
  result1
else
  result2

A: Remove your THEN. Example
DECLARE @variable INT = 0
DECLARE @variable2 INT = 10

IF @variable > 0 AND @variable2 > 0
BEGIN

    SELECT 'Condition was met'

END
ELSE
BEGIN

    SELECT 'Condition was not met'

END

If you want to chain IFs:
DECLARE @variable INT = 0
DECLARE @variable2 INT = 10

IF @variable > 0 AND @variable2 > 0
BEGIN

    SELECT 'Condition 1 was met'

END
ELSE IF @variable = 0 AND @variable2 > 0
BEGIN

    SELECT 'Condition 2 was met'

END
ELSE
BEGIN

    SELECT 'No condition was met'

END

Also, you can avoid the BEGIN ... END if you just need one statement, but it can be tricky to read if expressions are long.
DECLARE @variable INT = 0
DECLARE @variable2 INT = 10

IF @variable > 0 AND @variable2 > 0
    SELECT 'Condition was met'
ELSE
    SELECT 'Condition was not met'

A: Begin
If condition1 and condition2
  result1
else
  result2
END


text:
Q: Catching String as Argument in Bash I have a script I use for Git
function push() {
  git add --all
  git commit -m $1
  git push
}

Which I invoke by
p "Commit message"

My question is, how can I pass everything after p as one argument, essentially passing everything after p as the commit message - importantly - I want to know if there is a way to do this without quotation marks

A: If that's the only argument you have, you can use $* in your script to get all the parameters. Also, quote them:
function push() {
    git add --all
    git commit -m "$*"
    git push
 }

You can use "$1", too, leaving place for more parameters, but in that case you must use quotes while invoking the function (say, $ push "Some message" instead of just $ push Some message). It's more correct, but for this function purposes - just to economise time - it may be more useful.
Anyway, I don't think it's a good idea to have such a function. git add is a good moment to review your commit, decide what to include in it and what to leave for other commits, and to construct a really nice commit message. Plus, you would often want to delay the push until you have a couple of commits.
I recommend you to use something like tig for easily selecting what to stage and the like.


text:
Q: How do I alter the path of geom_line? I am plotting salinity with depth in ggplot2, and I would like my geom_line to follow the data points along the y axis and not x axis.
This is what a sample of my data looks like:
Depth   Salinity
0       28.81
.25     28.93
.5      28.92
.75     28.92
1       28.92
1.25    28.93
1.5     28.93
1.75    28.94
2       28.94

And this is the code I use...
 ggplot(YSIData,aes(Salinity.1,-Depth))+
   geom_point(aes(Salinity.1,-Depth,color="Profile 1"))+
   geom_line()

...to generate this graph (there are more data points in this graph past 2 meters)
Depth vs Salinity
But I don't want the line to go from left to right, I want it to follow the points from top to bottom (aka the order in which they were collected). How would I change the way geom_line follows the path of my data points?

A: If understand your question correctly, you want to reverse the x axis. Then this might do:
ggplot(YSIData, aes(Salinity.1, -Depth)) + geom_point(aes(...)) + geom_line() + scale_x_reverse()


text:
Q: let me know the name of OpenGl book for beginners
Possible Duplicate:
OpenGL Beginner Tutorials

Please let me know the name of OpenGl book for beginners.

A: The Orange book.
Also The Red Book and OpenGL SuperBible are rather good.
Btw:
The Orange Book = OpenGL(R) Shading Language
The Red Book = The OpenGL Programming Guide:  The Official Guide to Learning OpenGL

A: You might try starting out with the famous "Red Book", aka OpenGL Programming Guide. It's dated though, and modern OpenGL versions use somewhat different ways to get things done, although if you're using pre-3.2 -version, I'm pretty sure you can use everything shown there (it's also easier to get started with older OpenGL, because new versions rely heavily on shaders). I don't know if the "Blue book" aka The OpenGL Reference Manual is available in HTML anymore (couldn't find it right now), but here's a link to the reference pages for multiple versions. There are also many tutorials available online, for starters you could try
NeHe and Lighthouse3d, and try googling for more.


text:
Q: How would I convert this ternary expression into if else statements? I'm trying to find a simpler way of converting this ternary expression into if else expression.
Account account = selection != 1 ? (Account)customer.Saving : (Account)customer.Checking;

A: you can write:
Account account;
if(selection != 1)
{
    account= (Account)customer.Saving
}
else{
    account= (Account)customer.Checking;
}


text:
Q: pyserial- sending in parameters at runtime- input vs. raw_input - security flaw? I am writing a program that opens and records data sent through a serial port into a text file. I am currently adding functionality to allow reconfiguring the serial port during run-time. I prompt the user to choose which variable to change one at a time, so as to keep it simple for myself (i would appreciate elegant solutions as well).
The pyserial function that creates the serial instance (serial.Serial()) has the following parameters:
import serial
ser = serial.Serial(port=0, baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=0, rtscts=0, writeTimeout=None, dsrdtr=None, interCharTimeout=None) #default values shown

I notice that while most are int() arguments, some are not, i.e. "timeout".
I know using int(raw_input("for the int() type variables)) would let me safely assign the int variables, but the variables with None as default would require an input() function to properly assign the possible None value.
I have read elsewhere that input() is generally not recommended, since it has potential for being exploited(something about eval()?). How then should i handle those inputs? i.e. using serial.Serial() where writeTimout = str(None) throws an error.
Thanks!

A: The safest way is just to accept the user's input as a string and then parse it. I.e. let the user enter key=value pairs:
baudrate = 9600
parity = N

Then parse these pairs, by splitting on '=' and stripping both sides. Assign the variables with a string lookup table (the baudrate string maps to the baudrate var, and so on). This way you can handle the None value any way you want.
This method is simple and safe. input will raise exceptions if the user input isn't valid Python, and you may not want that.


text:
Q: Is there a way to see how much R computation is left from mac terminal? I have been running an R script that takes around 4 days to complete. The script involves a for loop that contains a text progress bar indicator, like so:
pb = txtProgressBar(min = 1, max = 60000, initial = 1, style = 3)

for(i in 1:60000){
print(i)
setTxtProgressBar(pb,ind)}

Last night, the Rstudio screen seems to have frozen at 82%, but I can see from the Activity Monitor application that the analysis is still running. Having committed ~3 days to computation, I'd rather not ESC and cancel the process to this point, just to restart and potentially have the same problem occur.
Is there a way to view how much time in the computation is left from the Mac terminal?


text:
Q: Zend framework 2 LAMP returns 404 error while it was working on windows I have an application running perfectly on my windows as well as CentOS server, but recently I have changed my OS from windows to Ubuntu. Now public folder is called it triggers onBootStrap where I have custom logic to check if not logged in then redirect to loginAction of default Controller. Which redirects fine but none of the controller is working they returns 404 error.
Even my public controllers are not accessible.
Am I missing any dependent extension?

A: Could it be some directory separators are \ and not / ? If these are hard coded in, try replacing them with PHP constant DIRECTORY_SEPARATOR anywhere you have them, like so:
require_once 'path'.DIRECTORY_SEPARATOR.'to'.DIRECTORY_SEPARATOR.'file';

instead of:
require_once 'path/to/file';

There are several issues when developing in windows, and that's just one of them. Case insensitivity and character encoding are other problems you will face.
An easier solution than re-configuring everything in your site (or wamp/xampp etc) would be a portable development server setup you can share with your team, so I recommend you try a VM!
Download Vagrant and VirtualBox first. Then if you go to puphpet.com, you can fill in a form to configure your development server. Make it match as closely to your production server as possible.
Once you finish filling in the form, download the configuration zip, unzip it, cd into the folder, and type vagrant up. It takes a while first time araound, but when it's ready, you will have a full Linux server, and if you share the zip, everyone on your team will have identical setups, whether on Windows, Linux, or Mac.
Anyway, if you intend to keep devving natively in windows, check your php error_log


text:
Q: Laravel create database entery when hitting a route? I'm still teaching myself laravel. I'm making an order form in laravel and i have a table full of products and i want to make it so that when make a new order and add the products. It would make its own order when i click new order it will make a new order number up and save it to the database?
Would the best way be to make an orders table with
Schema::create('westcoOrders', function (Blueprint $table){
        $table->increments('id');
        $table->string('orderNumber');
        $table->json('content');
        $table->tinyInteger('sent')->default(0);
        $table->tinyInteger('delivered')->default(0);
        $table->timestamps();
    } );

or would it be better having a table multiple tables so i have one like the one above without the json entry and then have a westcoOrderItems table like this?
Schema::create('westcoOrderItems', function (Blueprint $table){
        $table->string('orderNumber');
        $table->string('quantity');
        $table->string('productName');
        $table->string('productCode');
        $table->string('price');
        $table->timestamps();
    } );
}

So then i have link the order number to the other table. Or is that a long way to go around it?
and if i do it that way i will have to find a way to make an order number when i hit the new order route?
I feel like I'm doing this the wrong/long way?

A: In my opinion, something like the following would be better:
// For orders
Schema::create('orders', function (Blueprint $table){
    $table->increments('id');
    $table->tinyInteger('is_delivered')->default(0);
    $table->tinyInteger('is_paid')->default(0);
    $table->timestamps();
});

// For ordered_items (one order may contain many products/ordered_items)
Schema::create('ordered_items', function (Blueprint $table){
    $table->increments('id')->unsigned();
    $table->integer('order_id')->unsigned(); // fk for order.id
    $table->string('quantity')->unsigned();
    $table->string('productName');
    $table->string('productCode');
    $table->decimal('price', 10, 2);
});

Then the models, for example:
namespace App;

use Illuminate\Database\Eloquent\Model;

class Order extends Model {

    public function items()
    {
        return $this->hasMany('Item::class');
    }
}

The Item class for ordered_items:
namespace App;

use Illuminate\Database\Eloquent\Model;

class Item extends Model {

    protected $table = 'ordered_items';

    public function order()
    {
        return $this->belongsTo(Order::class);
    }
}

Hope you got the idea. This is the simplest one.


text:
Q: Java play application running despite of having errors- how to resolve this errors? I just started with play using activator, I created new play app using
activator new firstApp play-java

Then I opened play console using activator and run the application, app was running fine.
Then I opened the project in my intellij as SBT, the project opened and started showing errors.
in routes file there were lines
GET     /                        controllers.HomeController.index
GET     /count                   controllers.CountController.count
GET     /message                 controllers.AsyncController.message

This errors are because method index, count and message are not static.
This is an obvious error since we cannot call to static method like this, why the code application is still running.
another error I am getting is in code
actorSystem.scheduler().scheduleOnce(
        Duration.create(time, timeUnit),
        () -> future.complete("Hi!"),
        exec
    );

It says this is an ambiguous method call.
My question is, if there are errors why application is running without
I created run configuration as SBT task and tried to run the app an I got bunch of errors.

A: These worked for me:
Open file root\build.sbt and click 'Import Project' or 'Refresh Project'.
Open file project\plugins.sbt and click 'Import Project' or 'Refresh Project'.
This will import all required libraries and after completing libraries will be visible under project view pane 'External Libraries' tree.
Go to File > Settings, select 'Play2' under 'Languages & Frameworks'.
Under right side Compiler tab check 'Use Play 2 compiler for this project' and Apply settings.


text:
Q: I keep running into the same problems every time I try to make a new program My current program is a simple game..  I am trying to make it to help figure out how to properly use OOP.  But every time I get a little bit into a new program I run into the same problem:
I make an instance to use in my game.  This instance could be anything - the main hero, a monster, whatever.  Everything is going good, the instance is exactly what I want it to be.  Maybe I manipulate it a little bit.
I then try to use a different class, I guess I create an instance of a different class, in an attempt to further manipulate the original instance.  Maybe I originally created my hero and changed his stats, and now at this point I am trying to have my hero say something based on the stats that were chosen.
This point is always where I hit a roadblock.  I can't seem to do what I want to do here - I can't use that original instance I made because It was just an instance and I don't know how to manipulate it(or even if I am supposed to) from within a new class.
So.. it's a fundamental design problem/lack of understanding of OOP.
But I feel like I have a decent grasp on how to actually program stuff.. I keep reading and reading and getting advice but I can't seem to get past this barrier.
I know people on this site don't seem to like posts like this but maybe someone here can Identify with what it is I am not grasping.
Here is an example of what I am talking about, the game I am trying to make right now.
package pkgnew.stupid.game;

import java.util.Scanner;

/**
 *
 * @author whyguy2
 */
public class Hero {
public static int heroattack = 1;
public static int herospeed = 1;
public static int heroarmorpen = 1;
public static int heroarmor = 1;
public static int herohealth = 5;
public static String inputstat;
public static int herothepoints = 0;

Hero(int points){
    spendpoint(points);
}

    public void attack(){

    }

    public void die(){
       System.exit(0);
    }

    public void winbattle(){
        System.out.println("You win the battle and have one new point to spend!");
        spendpoint(1);
        new NewEncounter();
    }

    public void levelup(){
        System.out.println("You have leveled up and receive 5 new points to spend");
        spendpoint(5);
        new NewEncounter();
    }

    public void spendpoint(int points){
        for(int x=0; x<points; x++){
    System.out.println("Available Points: " + points);
    System.out.println("Available Attributes:");
    System.out.println("attack: " + heroattack);
    System.out.println("speed: " + herospeed);
    System.out.println("armorpen: " + heroarmorpen);
    System.out.println("armor: " + heroarmor);
    System.out.println("health: " + herohealth);
    System.out.println(points);
    System.out.println(x);
    Scanner keyboard = new Scanner( System.in );
    inputstat = keyboard.next( );
    if(inputstat.equals("attack")){
    heroattack = heroattack + 1;
    }
    else if(inputstat.equals("speed")){
    herospeed = herospeed + 1;
    }
    else if(inputstat.equals("armorpen")){
    heroarmorpen = heroarmorpen + 1;
    }
    else if(inputstat.equals("armor")){
    heroarmor = heroarmor + 1;
    }
    else if(inputstat.equals("health")){
    herohealth = herohealth + 5;
    }
    else{
    System.out.println("Please pick one of the stats");
    x = x-1;
    }
        }

    }

}

public class StartGame {

    StartGame(){                                                            //runs through output for a new game
   System.out.println("Welcome to the game");
   System.out.println("Pick your hero's starting stats");
   Hero thishero = new Hero(10);                                                             //spends your points

   System.out.println("Let's Begin!/n/n");
   new NewEncounter();                                                              //goes into the encounter loops
    }

}

at this point I I try to program an encounter in the NewEncounter class, but that isn't possible because I can't use that instance of my hero that I created.  and I am pretty sure that my design is bad in the first place, I think I have read that you should be trying to use static variables as little as possible in the first place.  I am still reading trying to grasp this but I have read a lot and I feel like nothing is helping me.  I actually think a more "hands on" large scale project/tutorial might help me, but I don't know one.  Anyways thanks for any help and sorry for the long/blog-like post.

A: The standard way to use an instance of one class within another is to either store a reference to it or to pass it into the method that stores or uses it.
For example:
class Encounter {
    private final Hero mainHero;
    private final List<Hero> participants;

    public Encounter(Hero mainHero) {
        this.mainHero = mainHero;
        participants = new ArrayList<>();
    }

    public void addParticipant(Hero hero) {
        participants.add(hero);
    }
}

Allows:
Encounter encounter = new Encounter(hero);

or:
encounter.addParticipant(hero);

These can then be used within the class. For example:
class Encounter {
    public void moveAllParticipants() {
        participants.forEach(Hero::move);
    }
}

I notice you have used a lot of public static class variables. This is unusual and there are few good reasons to use them. One is to define constants. If that's your intent then I suggest you use the following standard form:
private static final int HERO_ATTACK = 1;

If you intend for these to be instance variables (i.e. different for each hero) then they should not be static nor public.
This is the sort of area that is well covered in the various Java tutorials. I suggest working through one of them and coming back here if you have further issues.


text:
Q: "Putative" vs. "surrogate" How similar or different is "putative" to "surrogate"? The term "surrogate father" is common, "putative father" is fairly so, too. But what may be the difference in connotation?

A: The two are hardly alike at all.
a putative father is a man who is said to be the biological father of a child without that fact being completely sure.
While it does not have to have a negative connotation, in many cases it can have them, because using the word questions the actual fatherhood. There are plenty of situations in which that doubt will be perceived as negative, although in some (clinical?) situations, it is not completely neutral.
I would not, however, expect a man to proudly go around and claim to be a child's putative father.
A surrogate father can roughly mean three things, non of them having normally negative connotations:

*

*A man who is not the father of a child but fulfils the father role for it.

*A man who donated his sperm for a child to be conceived, but does not play the father role.

*A man who became a father through the use of a surrogate mother.

For these three, and especially the 3rd definition, see here. I have not heard it often used in that sense, but it seems to be in use.
Contrary to putative, there is no doubt or uncertainty involved in the case of a surrogate father.


text:
Q: What is business logic code and what is data access code, and what's the difference? I ask this because it seems people usually consider the code that goes into a DAO or Repository implementation as "data access code", while the code that directly uses these DAOs/Repositories as "business logic code".
However, this doesn't seem to make logical sense.
Consider a business service method with code like the following (using Java, but it would be similar in C#, etc.):
public BigDecimal computeCustomerTotal(Customer customer) {
    List<Order> orders = orderRepository.findByCustomer(customer);

    BigDecimal total = orders.stream()
        .filter(Order::isActive).map(Order::getTotal).reduce(ZERO, BigDecimal::add);

    return total;
}

Sure, the above implementation doesn't make "proper" use of a database's capabilities, but bear with me. The point here is that, I assume, everyone agrees it contains only business logic code, with Customer and Order being domain entities (ie, they are not "data" objects).
So, what if I want to make it right, by moving the whole computation to the database, instead of executing in the client program? If I follow "conventional wisdom", I would create a new method in the repository:
public BigDecimal getCustomerTotal(Customer customer) {
    BigDecimal total = performQuery(
        "select sum(o.total) from Order o where o.customer = ?1 and o.active",
        customer);

    return total;
}

(Assume performQuery is a JPA-based utility method which takes a JPA-QL
sentence with optional arguments.)
The second implementation is obviously better than the first, as it probably performs better, and makes proper use of the underlying technologies (JPA/Hibernate, and a relational database).
The problem, though, is that business logic (the rule that only active orders should be considered) has been moved from a business service method to a (supposed) data access method, through a simple implementation change.
Also, this code which is now in the DAO/Repository does not actually know about data access concerns, such as the mapping from entity types and attributes to tables and columns, or about the actual SQL code that gets generated and sent to the DB engine.
Wouldn't it be more logical to regard both methods as containing only business logic code, and just get rid of the DAO/Repository/DAL altogether?
Personally, I don't see any data access code there, and to me things like DAOs, Repositories, or "data access layers" (DAL) are in reality anti-patterns. Note that even when using JDBC + SQL in a DAO/Repository implementation, it will inevitably contain business logic, typically in the form of "where" clauses.

A: The database layer is intended to isolate the rest of the application from the details of the database -- how to make a connection, the syntax used to talk to the db engine, etc.
The .Net Entity Framework version of your code would be:
var id = customer.id;
var customerOrdersTotal = db.Orders.
                          Where(o => o.CustomerId == id && o.Active).
                          Sum(o => o.Total);

Note that this would get translated into the sql your JPA version would use, but the exact same thing could be done without involving sql at all.
If you have a Customer that has Orders, then it would be:
var customerOrdersTotal = customer.Orders.
                          Where(o => o.Active).Sum(o => o.Total);

And this version could be written regardless of whether Orders is a virtual list or an actual list of orders.
The business doesn't care where the data is kept or how it is retrieved.  The point of a DAL is to abstract away the "how is this bit of data retrieved" and turn it into just the necessary (i.e. unavoidable) "how to request the data I want".  Without a DAL you have to mix the two functions together, which means you can't change one without changing the other.
Note that about half the time, you don't ever end up making any changes...but when you do it's a real pain if they are mixed together.
Edit: I'll add that your implication that "where" clauses in the data access code is a business concern is incorrect.  The data layer exists to serve business needs.  The data can be carved up and served in an infinite number of ways, some more useful than others.  Moving a condition from the business layer to the data layer simply means that the request is common enough to be included in the ways that are usefully provided out of the box. Preventing new orders when existing active orders exceeds $X is a business decision.

A:
What is business logic code and what is data access code, and what's the difference?

There is a short answer to that:
a) Code, that is used to open a connection to a DB, to retrieve data, do OR-mapping etc. is called data access code
 static public int AddProductCategory(string newName, string connString)
 {
     Int32 newProdID = 0;
     string sql =
         "INSERT INTO Production.ProductCategory (Name) VALUES (@Name); "
         + "SELECT CAST(scope_identity() AS int)";
     using (SqlConnection conn = new SqlConnection(connString))
     {
         SqlCommand cmd = new SqlCommand(sql, conn);
         cmd.Parameters.Add("@Name", SqlDbType.VarChar);
         cmd.Parameters["@name"].Value = newName;
         try
         {
             conn.Open();
             newProdID = (Int32)cmd.ExecuteScalar();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
     return (int)newProdID;
 }

Example taken from MSDN
b) Code, that is used transform this data or conataining the rules, when to retrieve this data is called business logic
Both are different responsibilities and are usually implemented in different layers of your application:
a) In a layer sometimes called service-layer sits the logic, when to retrieve what kind of data and how this data is treated aka business logic
b) In case you are implementing the Repository Pattern: this is the place where the data acces code lives.

The point here is that, I assume, everyone agrees it contains only business logic code, with Customer and Order being domain entities (ie, they are not "data" objects).

No. It is data access code, it retrieves data in a way which is relevant for the business logic.

Wouldn't it be more logical to regard both methods as containing only business logic code, and just get rid of the DAO/Repository/DAL altogether?

Neither of the methods contain any business logic. It is really only access code. The reason why you filter the data like you do is lead by business concerns, but that doesn't make them itself business logic.

Personally, I don't see any data access code there, and to me things like DAOs, Repositories, or "data access layers" (DAL) are in reality anti-patterns. Note that even when using JDBC + SQL in a DAO/Repository implementation, it will inevitably contain business logic, typically in the form of "where" clauses.

Maybe you should think about your definition of business logic.
These patterns are not in any way anti-patterns, these patterns allow clear separation of concerns.

A: It seems to me that you're just missing a class definition.
Declare a class CustomerOrders with GetOrdersTotal method.
It's a pure business object. There no such table in the db. It wraps an Order DAO and applies business rules on on it (active order, filter by customer id).
So, OrderRepository is your DAL and CustomerOrders is your BL


text:
Q: GAE flexible static files not updating after hours I've been using GAE flex for a couple years now, and am stumped by my app not serving updated static files hours after deployment.

*

*I haven't change any default caching of static files (which I believe is 10 minutes)

*I've redeployed my app several times to new versions in case it was a one-off weird thing

*I deleted all the contents of the staging bucket and redeployed

*In Chrome, I'm reloading the file with "Empty Cache and Hard Reload" but still see the old file

Any idea what could be the problem or how to fix it?
UPDATE:
Very odd:

*

*Static files are updated if accessed from https://my-app.appspot.com

*But not updated from https://www.my-domain.com
Another weird difference is how the static files are presented in the Chrome window.  With my-app.appspot.com, the text is line-wrapped.  With www.my-domain.com, the text is not line-wrapped.

A: Almost 24 hours later, the static files have been updated so it sorted itself out eventually.
The cached files from

*

*https://my-app.appspot.com

*https://www.my-domain.com
are still different in that one is line wrapped and one is not.
Would be very helpful if someone could explain why the static files are cached in different ways depending on the URL used to access them.


text:
Q: How can I merge multiple Arrays into one? I'm trying to merge all of the 11 arrays into one big array. All of the arrays have same number of elements and all the elements in each array correspond to the elements in other arrays. For example the first element of Days array corresponds to first element of Depths array, to first element of the IRIS_IDs array, to first element of the Latitudes array and so on.
When the merged array is displayed on Console screen it should look something like this:

I am reading in the data into each array from separate text files that contain the corresponding data
*Edit - I need to make it so that I am able to search for all the data that corresponds to a specific month. For example if I choose to type in January, the Console will display all of the data that corresponds to January. So in this example all the data about the earthquakes that happened in January will be shown.

A: If all you need is just to zip so you can print the data you can also:
var maxItems = (new int[] { Days.Length, Depths.Length, IRIS_IDs.Length,Latitudes.Length })
               .Max();

var result = Enumerable.Range(0, items)
          .Select(i => string.Join("\t", new [] { Days.ElementAtOrDefault(i),
                                                 Depths.ElementAtOrDefault(i),
                                                 IRIS_IDs.ElementAtOrDefault(i),
                                                 Latitudes.ElementAtOrDefault(i) }));

But it seems like you want to then perform operations on the collection so instead of just concatenations create a custom object to properly contain the data:
public class Data
{
    public string Day { get; set; }
    public string Depth { get; set; }
    public string IRIS_ID { get; set; }
    public string Latitude { get; set; }

    public override string ToString()
    {
        return $"{Day}, {Depth}, {IRIS_ID}, {Latitude}";
    }
}

And then you can:
var maxItems = (new int[] { Days.Length, Depths.Length, IRIS_IDs.Length,Latitudes.Length })
               .Max();

var reuslt = Enumerable.Range(0, maxItems)
          .Select(i => new Data
          {
              Day = Days.ElementAtOrDefault(i),
              Depth = Depths.ElementAtOrDefault(i),
              IRIS_ID = IRIS_IDs.ElementAtOrDefault(i),
              Latitude = Latitudes.ElementAtOrDefault(i)
          }).ToList();

This implementation will work by "best-effort" to populate all the data for all the objects - so if in some files you are missing records you will have null values in the corresponding objects

A: You can create a class to aggregate all the fields which you want to display, then iterate through all the elements and for each iteration create a new instance of this class and add to a list. Something like:
Class Merge
{
   public int Days {get; set;}
   public int Depths {get; set;}
etc...
}

for (int i = 0; i < Days; i++)
{
   var merge = new Merge(){Days = Days[0], Depths = Depths[0], ...}

   mergedList.Add(merge);
}

A: Example is simplified to 2 arrays.
Something like this:
string[] Days = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Day_1.txt");
string[] Depths = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Depth_1.txt");
...

string[] newArray = new string[Days.Length];
for(int x = 0; x < Days.Length;x++)
{
     newArray[x] = string.Format("{0} {1}", Days[x], Depths[x]);
}

A: I would solve this with a list of new data objects. You would want to loop through and create a new object with the same iterator in each array.
First create your new object:
public class MyDataObject
{
    public string Days { get; set; }
    public string Depth { get; set; }
    public string IRIS_IDs { get; set; }
    public string Latitudes { get; set; }
    // etc ...
}

Then set up your function that does the looping:
public IEnumerable<MyDataObject> MyObjectBuilder()
{
    // Declare return object
    var result = new List<MyDataObject>();

    // Get your data
    string[] Days = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Day_1.txt");
    string[] Depths = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Depth_1.txt");
    string[] IRIS_IDs = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\IRIS_ID_1.txt");
    string[] Latitudes = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Latitude_1.txt");
    // etc ...

    // Loop through items to build objects
    for(var i = 0; i <= Days.length(); i++)
    {
        result.Add(new MyDataObject {
            Days = Days[i],
            Depths = Depths[i],
            IRIS_IDs = IRIS_IDs[i],
            Latitudes = Latitudes[i],
            // etc ...
        }
    }

    // Return result
    return result;
}

A: You can do this as well
 string[] Days = System.IO.File.ReadAllLines(@"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Day_1.txt");
        string[] Depths = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Depth_1.txt");
        string[] IRIS_IDs = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\IRIS_ID_1.txt");
        string[] Latitudes = System.IO.File.ReadAllLines(@"C: \Users\Illimar\Desktop\Algorithms and Comlexity2\Latitude_1.txt");

        List<string> result = new List<string>();
        (new[] { Days, Depths, IRIS_IDs, Latitudes }).ToList().ForEach(a => result.AddRange(a));

A: Here are two ways to accomplish what you want.  The first solution is with arrays, as you asked, and another with Dictionary's.
In either case, define your data file types with an enum:
enum DataFileType
{
    Days = 0,
    Depths,
    IRIS_IDs,
    Latitudes,
    Longitudes,
    Magnitudes,
    Months,
    Regions,
    Times,
    Timestamps,
    Years
}

For the array solution we'll use DataFileType to define an array of file paths and create a parallel array of data:
static readonly string[] FileSpecs = new string[]
{
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Day_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Depth_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\IRIS_ID_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Latitude_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Longitude_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Magnitude_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Month_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Region_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Time_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Timestamp_1.txt" ,
    @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Year_1.txt"
};

static void Main(string[] args)
{
    string[][] data = new string[FileSpecs.Length][];
    // read the data
    for (int i = (int)DataFileType.Days; i <= (int)DataFileType.Years; i++)
        data[i] = System.IO.File.ReadAllLines(FileSpecs[i]);

    // grab some data
    string[] IRIS_IDs = data[(int)DataFileType.IRIS_IDs];
}

This array solution is fine - but not very flexible, and the casting of DataFileType to int is tedious.
Using Dictionary provides a lot more flexibility:
static readonly Dictionary<DataFileType, string> FileMap = new Dictionary<DataFileType, string> {
    { DataFileType.Days, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Day_1.txt" },
    { DataFileType.Depths, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Depth_1.txt" },
    { DataFileType.IRIS_IDs, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\IRIS_ID_1.txt" },
    { DataFileType.Latitudes, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Latitude_1.txt" },
    { DataFileType.Longitudes, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Longitude_1.txt" },
    { DataFileType.Magnitudes, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Magnitude_1.txt" },
    { DataFileType.Months, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Month_1.txt" },
    { DataFileType.Regions, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Region_1.txt" },
    { DataFileType.Times, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Time_1.txt" },
    { DataFileType.Timestamps, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Timestamp_1.txt" },
    { DataFileType.Years, @"C:\Users\Illimar\Desktop\Algorithms and Comlexity2\Year_1.txt" }
};

static void Main(string[] args)
{
    // read data - map FileDataType to data file content
    var dataMap = new Dictionary<DataFileType, string[]>();
    foreach (var kv in FileMap)
        dataMap[kv.Key] = System.IO.File.ReadAllLines(kv.Value);
    // grab some data
    string[] data = dataMap[DataFileType.IRIS_IDs];
}

Neither are the ultimate solution but should give you some ideas.


text:
Q: how to disable angular material typography styles? how to disable angular material typography styles after installed angular materials? It is changing my visual style and it is not easy to overwrite. I dont need it, just need to get rid of it.

A: Inside your index.html file, the body tag should have class="mat-typography", just remove this class and your styles shouldn't be overwritten anymore. You should also check if your Angular Material theme doesn't contain any custom typography like it's shown in Typography guide (https://material.angular.io/guide/typography)

A: Change below things in index.html file

*

*Remove all stylesheet links related to material.

*Then remove class="mat-typography" from body