问:
Cannot Php artisan serve cause of cannot redeclare class Composer
I can't run using php artisan serve cause of :

PHP Fatal error:  Cannot redeclare class Composer\Autoload\ComposerStaticInit4783eae8fdb0bbd7059e05caa6aed997 in /var/www/html/project/config/vendor/composer/autoload_static.php
   Script php artisan optimize handling the post-update-cmd event returned with error code 255

Heres is my autoload_static.php:

```<code>class ComposerStaticInit57efd0b78daf784a291fa20fc5e6edcd
{
    public static $files = array (
        '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
        '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
        '1d1b89d124cc9cb8219922c9d5569199' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
        '3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
        '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
        '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
        'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',
        'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
        'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
        'e7223560d890eab89cda23685e711e2c' => __DIR__ . '/..' . '/psy/psysh/src/Psy/functions.php',
        'f18cc91337d49233e5754e93f3ed9ec3' => __DIR__ . '/..' . '/laravelcollective/html/src/helpers.php',
        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
        'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
        '58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',
    );

}
</code>```

already try composer install and update but still didnt work at all. anyone know ?

答: So the problem is wrong step while compose require internvention/image. i didnt check the app/config.php first. should comment the provider and the aliases. i think the case is solve. thank you everyone.</p>

Body:
I can't run using php artisan serve cause of :

PHP Fatal error:  Cannot redeclare class Composer\Autoload\ComposerStaticInit4783eae8fdb0bbd7059e05caa6aed997 in /var/www/html/project/config/vendor/composer/autoload_static.php
   Script php artisan optimize handling the post-update-cmd event returned with error code 255

Heres is my autoload_static.php:

class ComposerStaticInit57efd0b78daf784a291fa20fc5e6edcd
{
    public static $files = array (
        '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
        '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
        '1d1b89d124cc9cb8219922c9d5569199' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
        '3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
        '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
        '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
        'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',
        'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
        'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
        'e7223560d890eab89cda23685e711e2c' => __DIR__ . '/..' . '/psy/psysh/src/Psy/functions.php',
        'f18cc91337d49233e5754e93f3ed9ec3' => __DIR__ . '/..' . '/laravelcollective/html/src/helpers.php',
        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
        'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
        '58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',
    );

}

already try composer install and update but still didnt work at all. anyone know ?


来源: stackexchange

问:
Leaflet marker on-click display data in div
I have a jacascript code which loads the geojson data from a file and displays circleMarkers (Cannot display normal markers as the popups don't work).

```<code>{
  $.ajax({
    dataType: "json",
    type: 'POST',
    url: "geojsonfile.php",
    beforeSend: function() {},
    success: function(data) {
      display = L.geoJson(data, {
        style: function(feature) {
          return {
            color: '#0515B5'
          };
        },
        pointToLayer: function(feature, latlng) {
          return new L.CircleMarker(latlng, {
            radius: 6,
            fillOpacity: 0.85
          });
        },
        onEachFeature: function(feature, layer) {
          layer.bindPopup("Name: " + feature.properties.name);
          document.getElementById("sname").innerHTML = feature.properties.name;
          layer.on({
            click: showData
          });

        }
      }).addTo(map);

    }
  }).error(function(xhr, status, error) {
    console.log(error);
  });

}

function showData(e) {
  $("#sdata").show();
}
</code>```

The html table where the data is to be displayed is

```<code><table  id="sdata">
  <tbody>
    <tr>
      <td> Name:</td>
      <td id="sname"></td>
    </tr>
  </tbody>
</table>
</code>```

But the problem is only the last value of the geojson is displayed in the table, Is it possible that onclicking the marker the value in the sname is displayed accordingly like the marker popup.

答:
Popups should work, you should bind them to the feature instead of the layer.

Not:

```<code>layer.bindPopup("Name: " + feature.properties.name);
</code>```

But:

```<code>feature.bindPopup("Name: " + feature.properties.name);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a jacascript code which loads the geojson data from a file and displays circleMarkers (Cannot display normal markers as the popups don't work).

{
  $.ajax({
    dataType: "json",
    type: 'POST',
    url: "geojsonfile.php",
    beforeSend: function() {},
    success: function(data) {
      display = L.geoJson(data, {
        style: function(feature) {
          return {
            color: '#0515B5'
          };
        },
        pointToLayer: function(feature, latlng) {
          return new L.CircleMarker(latlng, {
            radius: 6,
            fillOpacity: 0.85
          });
        },
        onEachFeature: function(feature, layer) {
          layer.bindPopup("Name: " + feature.properties.name);
          document.getElementById("sname").innerHTML = feature.properties.name;
          layer.on({
            click: showData
          });

        }
      }).addTo(map);

    }
  }).error(function(xhr, status, error) {
    console.log(error);
  });

}

function showData(e) {
  $("#sdata").show();
}

The html table where the data is to be displayed is

       Name:

But the problem is only the last value of the geojson is displayed in the table, Is it possible that onclicking the marker the value in the sname is displayed accordingly like the marker popup.

Body:
Popups should work, you should bind them to the feature instead of the layer.

Not:

layer.bindPopup("Name: " + feature.properties.name);

But:

feature.bindPopup("Name: " + feature.properties.name);


问:
React Native Expo building standalone app
I use Expo for development. I don't know how to build .apk for Android. I checked out Building Standalone Apps documentation. It says:

This will take a few minutes, you can check up on it by running exp
  build:status. When it’s done, you’ll see the url of a .apk (Android)
  or .ipa (iOS) file — this is your app.

```<code>exp build:android
</code>```

I tried a few times. It's been a while. No errors, no links. Nothing on the web portal. Am I doing something wrong?

答:
expo has it's integrated system if you are using their building structure.

The building takes a while as stated. (Around 5-10mins) your build process starts with the command;

```<code>exp build:android
</code>```

After a while, check the status of your build with command;

```<code>exp build:status
</code>```

If your build it done, this comman will give you your .apk file url. If not, it will say your build is still in progress and try in a little bit later again.

Body:
I use Expo for development. I don't know how to build .apk for Android. I checked out Building Standalone Apps documentation. It says:

This will take a few minutes, you can check up on it by running exp
  build:status. When it’s done, you’ll see the url of a .apk (Android)
  or .ipa (iOS) file — this is your app.

exp build:android

I tried a few times. It's been a while. No errors, no links. Nothing on the web portal. Am I doing something wrong?

Body:
expo has it's integrated system if you are using their building structure.

The building takes a while as stated. (Around 5-10mins) your build process starts with the command;

exp build:android

After a while, check the status of your build with command;

exp build:status

If your build it done, this comman will give you your .apk file url. If not, it will say your build is still in progress and try in a little bit later again.


问:
Social Media app how to correctly save login
I am coding an Android Social Media app, The frame is in Java and the actual data is just a WebView of the mobile view of my social media site.

The question I have is how do I save a user's password, is there anything wrong with storing the user's password in plain text (Not hashed or anything) in a file since using Internal Storage on an Android device means only my app can access the files?

Also when displaying the user's data such as activity, profile data, and feed (Which is all a HTML webpage) would it be safe to code the website to take URLs like www.mywebsite.com/mobile.php?user=example&session=String Of Characters

答: There is no issue in writing the password in SharedPreferences or internal storage as users can't access it until a device is rooted. The best approach is that you should save encrypted password or authToken instead but if you want to proceed with plain text password then apply a special check that if a device is Rooted then don't save password in plain way. </p>


问:
No rows found, C# using OleDB
I have been rewriting a C# program to better encapsulate accessing an Access database, using OleDb.  It runs, but doesn't find the row that exists, but running the SQL query in Access does find it.

The question is: what is wrong with my code?  Why don't I get any rows returned?

I'm using VS 2017 and Access 2013.  The PC is an up-to-date windows 10 x64 machine.

```<code>using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;

namespace OleDbTest
{
    class Program
    {
        static void Main( string[] args )
        {
            // Create Profile File object
            ProcessEJFile EJP = new ProcessEJFile(
                "Provider=Microsoft.ACE.OLEDB.12.0;" +
                @"Data Source=E:\Users\sallyw\Documents\Bar.accdb;" +
                "Persist Security Info=False;");

            // Get details of last header - this should return just one row
            string query =
            //      @"select * from stock_head where sh_ref in ( select max( stock_head.[ sh_ref ] ) FROM stock_head WHERE sh_ref like ""[#]%"")";

                    "select sh_id, sh_ref, sh_lineno, sh_type, sh_supplier, sh_datetime from stock_head where sh_id = 19;";

            //      "select * from stock_head where sh_ref = 19;"

            List<StockHead> shlist = EJP.GetStockHead(query, null );
            if ( shlist == null )
            {
                Console.WriteLine( "shlist is null" );
            }
            else
            {
                Console.WriteLine( "shlist contains {0} entries", shlist.Count );
            }
            Console.ReadLine();
        }
    }

    class ProcessEJFile
    {
        AccessDatabase Accdb = null;

        public ProcessEJFile( string connectionString )
        {
            Accdb = new AccessDatabase( connectionString );
            Console.WriteLine( "ProfessEJFile #1 - connection string = {0}", connectionString );
        }

        public List<StockHead> GetStockHead( string sql, params object[] args )
        {
            DataTable t;
            if ( args == null )
            {
                Console.WriteLine( "GetStockHead #1 - args are NULL " );
            }
            else
            {
                Console.WriteLine( "GetStockHead #2 - {0} arguments passed", args.Count() );
            }

            Accdb.ExecuteQuery( out t, sql, args );

            if ( t != null )
            {
                List<StockHead> shlist = new List<StockHead>();

                foreach ( DataRow r in t.Rows )
                {
                    Console.WriteLine( t.ToString() );
                    //StockHead sh = new StockHead(
                    //    (int)r["sh_id"],
                    //    (string)r["sh_ref"],
                    //    (int)r["sh_lineno"],
                    //    (string)r["sh_type"],
                    //    (string)r["sh_supplier"],
                    //    (DateTime)r["sh_datetime"]);
                    //shlist.Add( sh );
                }
                return shlist;
            }
            else
            {
                Console.WriteLine( "GetStockHead #3 - t is null" );
                return null;
            }
        }
    }
    class AccessDatabase
    {
        public OleDbConnection conn = new OleDbConnection();

        public AccessDatabase( string connection )
        {
            conn.ConnectionString = connection;
        }

        public bool OpenDatabase()
        {
            try
            {
                conn.Open();
            }
            catch ( Exception ex )
            {
                Console.WriteLine( "OpenDatabase()\n" + ex.Message );
                return false;
            }
            return true;
        }

        public void CloseDatabase()
        {
            if ( conn == null )
                return;

            conn.Close();
        }

        public void ExecuteQuery( out DataTable dataTable, string sql, params object[] args )
        {
            dataTable = new DataTable();
            string query;

            // Simplified version not validating or cleaning arguments in any way
            if (args == null )
            {
                query = sql;
            }
            else
            {
                query = string.Format( sql, args );
            }
            Console.WriteLine( "ExecuteQuery #3 - query = '{0}'", query );

            if ( OpenDatabase() )
            {
                OleDbCommand command = new OleDbCommand( query, conn );
                OleDbDataAdapter adapter = new OleDbDataAdapter( command );
                adapter.Fill( dataTable );
            }
            else
            {
                Console.WriteLine( "ExecuteQuery #9 - cannot open database" );
            }
        }
    }

    class StockHead
    {
        public int sh_id;              // autonumber
        public string sh_ref;          // short text
        public int sh_lineno;          // Number
        public string sh_type;         // short text
        public string sh_supplier;     // short text
        public DateTime sh_datetime;   // date/time

        public StockHead( int id, string refno, int lineno, string type, string supplier, DateTime datetime )
        {
            sh_id = id;
            sh_ref = refno;
            sh_lineno = lineno;
            sh_type = type;
            sh_supplier = supplier;
            sh_datetime = datetime;
        }
    }
}
</code>```

Data in CSV format, class stock_head shows the Access column types:

```<code>1,"#000001",,"IR","INITIAL RESET",20/8/2013 08:33:00
2,"#000002",,"SD","FORMATTING",20/8/2013 08:34:00
3,"#000003",,"SD","FOLDER CREATE",20/8/2013 08:35:00
4,"#000004",,"SD","FOLDER SELECT",20/8/2013 08:35:00
5,"#000005",,"NS","NO SALE",20/8/2013 11:14:00
6,"#000006",,"NS","NO SALE",20/8/2013 11:46:00
7,"#000007",,"NS","NO SALE",20/8/2013 12:16:00
8,"#000008",,"SALE",,20/8/2013 15:11:00
9,"#000009",,"SALE",,20/8/2013 15:30:00
10,"#000010",,"Z1",,20/8/2013 15:32:00
11,"#000011",,"NS","NO SALE",20/8/2013 15:32:00
12,"#000012",,"SALE",,20/8/2013 16:46:00
13,"#000013",,"SALE",,20/8/2013 16:47:00
14,"#000014",,"SALE",,20/8/2013 17:32:00
15,"#000015",,"Z1",,20/8/2013 19:25:00
16,"#000016",,"NS","NO SALE",20/8/2013 19:25:00
17,"#000017",,"Z1",,20/8/2013 21:52:00
18,"#000018",,"NS","NO SALE",20/8/2013 21:52:00
19,"#000019",,"SALE",,23/8/2013 18:27:00
20,"#000020",,"SALE",,23/8/2013 19:06:00
21,"#000021",,"SALE",,23/8/2013 20:24:00
22,"#000022",,"SALE",,23/8/2013 20:36:00
23,"#000023",,"SALE",,23/8/2013 21:21:00
24,"#000024",,"SALE",,23/8/2013 21:57:00
25,"#000025",,"SALE",,23/8/2013 22:38:00
26,"#000026",,"Z1",,23/8/2013 22:40:00
27,"#000027",,"NS","NO SALE",23/8/2013 22:40:00
28,"#000028",,"SALE",,24/8/2013 16:09:00
29,"#000029",,"SALE",,24/8/2013 16:28:00
30,"#000030",,"SALE",,24/8/2013 16:58:00
</code>```

答:
This is simple to be edit GetStockHead function

```<code>public List<StockHead> GetStockHead( string sql, params object[] args )
{
    DataTable t;
    if ( args == null )
    {
        Console.WriteLine( "GetStockHead #1 - args are NULL " );
    }
    else
    {
        Console.WriteLine( "GetStockHead #2 - {0} arguments passed", args.Count() );
    }

    Accdb.ExecuteQuery( out t, sql, args );

    if ( t != null )
    {
        List<StockHead> shlist = new List<StockHead>();

        foreach ( DataRow r in t.Rows )
        {
            Console.WriteLine( t.ToString() );
            StockHead sh = new StockHead(
                (int)r["sh_id"],
                (string)r["sh_ref"],
                (int)r["sh_lineno"],
                (string)r["sh_type"],
                (string)r["sh_supplier"],
                (DateTime)r["sh_datetime"]);
            shlist.Add( sh );
        }
        return shlist;
    }
    else
    {
        Console.WriteLine( "GetStockHead #3 - t is null" );
        return null;
    }
}
</code>```

Title: No rows found, C# using OleDB

Body:
I have been rewriting a C# program to better encapsulate accessing an Access database, using OleDb.  It runs, but doesn't find the row that exists, but running the SQL query in Access does find it.

The question is: what is wrong with my code?  Why don't I get any rows returned?

I'm using VS 2017 and Access 2013.  The PC is an up-to-date windows 10 x64 machine.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;

namespace OleDbTest
{
    class Program
    {
        static void Main( string[] args )
        {
            // Create Profile File object
            ProcessEJFile EJP = new ProcessEJFile(
                "Provider=Microsoft.ACE.OLEDB.12.0;" +
                @"Data Source=E:\Users\sallyw\Documents\Bar.accdb;" +
                "Persist Security Info=False;");

            // Get details of last header - this should return just one row
            string query =
            //      @"select * from stock_head where sh_ref in ( select max( stock_head.[ sh_ref ] ) FROM stock_head WHERE sh_ref like ""[#]%"")";

                    "select sh_id, sh_ref, sh_lineno, sh_type, sh_supplier, sh_datetime from stock_head where sh_id = 19;";

            //      "select * from stock_head where sh_ref = 19;"

            List<StockHead> shlist = EJP.GetStockHead(query, null );
            if ( shlist == null )
            {
                Console.WriteLine( "shlist is null" );
            }
            else
            {
                Console.WriteLine( "shlist contains {0} entries", shlist.Count );
            }
            Console.ReadLine();
        }
    }

    class ProcessEJFile
    {
        AccessDatabase Accdb = null;

        public ProcessEJFile( string connectionString )
        {
            Accdb = new AccessDatabase( connectionString );
            Console.WriteLine( "ProfessEJFile #1 - connection string = {0}", connectionString );
        }

        public List<StockHead> GetStockHead( string sql, params object[] args )
        {
            DataTable t;
            if ( args == null )
            {
                Console.WriteLine( "GetStockHead #1 - args are NULL " );
            }
            else
            {
                Console.WriteLine( "GetStockHead #2 - {0} arguments passed", args.Count() );
            }

            Accdb.ExecuteQuery( out t, sql, args );

            if ( t != null )
            {
                List<StockHead> shlist = new List<StockHead>();

                foreach ( DataRow r in t.Rows )
                {
                    Console.WriteLine( t.ToString() );
                    //StockHead sh = new StockHead(
                    //    (int)r["sh_id"],
                    //    (string)r["sh_ref"],
                    //    (int)r["sh_lineno"],
                    //    (string)r["sh_type"],
                    //    (string)r["sh_supplier"],
                    //    (DateTime)r["sh_datetime"]);
                    //shlist.Add( sh );
                }
                return shlist;
            }
            else
            {
                Console.WriteLine( "GetStockHead #3 - t is null" );
                return null;
            }
        }
    }
    class AccessDatabase
    {
        public OleDbConnection conn = new OleDbConnection();

        public AccessDatabase( string connection )
        {
            conn.ConnectionString = connection;
        }

        public bool OpenDatabase()
        {
            try
            {
                conn.Open();
            }
            catch ( Exception ex )
            {
                Console.WriteLine( "OpenDatabase()\n" + ex.Message );
                return false;
            }
            return true;
        }

        public void CloseDatabase()
        {
            if ( conn == null )
                return;

            conn.Close();
        }

        public void ExecuteQuery( out DataTable dataTable, string sql, params object[] args )
        {
            dataTable = new DataTable();
            string query;

            // Simplified version not validating or cleaning arguments in any way
            if (args == null )
            {
                query = sql;
            }
            else
            {
                query = string.Format( sql, args );
            }
            Console.WriteLine( "ExecuteQuery #3 - query = '{0}'", query );

            if ( OpenDatabase() )
            {
                OleDbCommand command = new OleDbCommand( query, conn );
                OleDbDataAdapter adapter = new OleDbDataAdapter( command );
                adapter.Fill( dataTable );
            }
            else
            {
                Console.WriteLine( "ExecuteQuery #9 - cannot open database" );
            }
        }
    }

    class StockHead
    {
        public int sh_id;              // autonumber
        public string sh_ref;          // short text
        public int sh_lineno;          // Number
        public string sh_type;         // short text
        public string sh_supplier;     // short text
        public DateTime sh_datetime;   // date/time

        public StockHead( int id, string refno, int lineno, string type, string supplier, DateTime datetime )
        {
            sh_id = id;
            sh_ref = refno;
            sh_lineno = lineno;
            sh_type = type;
            sh_supplier = supplier;
            sh_datetime = datetime;
        }
    }
}

Data in CSV format, class stock_head shows the Access column types:

1,"#000001",,"IR","INITIAL RESET",20/8/2013 08:33:00
2,"#000002",,"SD","FORMATTING",20/8/2013 08:34:00
3,"#000003",,"SD","FOLDER CREATE",20/8/2013 08:35:00
4,"#000004",,"SD","FOLDER SELECT",20/8/2013 08:35:00
5,"#000005",,"NS","NO SALE",20/8/2013 11:14:00
6,"#000006",,"NS","NO SALE",20/8/2013 11:46:00
7,"#000007",,"NS","NO SALE",20/8/2013 12:16:00
8,"#000008",,"SALE",,20/8/2013 15:11:00
9,"#000009",,"SALE",,20/8/2013 15:30:00
10,"#000010",,"Z1",,20/8/2013 15:32:00
11,"#000011",,"NS","NO SALE",20/8/2013 15:32:00
12,"#000012",,"SALE",,20/8/2013 16:46:00
13,"#000013",,"SALE",,20/8/2013 16:47:00
14,"#000014",,"SALE",,20/8/2013 17:32:00
15,"#000015",,"Z1",,20/8/2013 19:25:00
16,"#000016",,"NS","NO SALE",20/8/2013 19:25:00
17,"#000017",,"Z1",,20/8/2013 21:52:00
18,"#000018",,"NS","NO SALE",20/8/2013 21:52:00
19,"#000019",,"SALE",,23/8/2013 18:27:00
20,"#000020",,"SALE",,23/8/2013 19:06:00
21,"#000021",,"SALE",,23/8/2013 20:24:00
22,"#000022",,"SALE",,23/8/2013 20:36:00
23,"#000023",,"SALE",,23/8/2013 21:21:00
24,"#000024",,"SALE",,23/8/2013 21:57:00
25,"#000025",,"SALE",,23/8/2013 22:38:00
26,"#000026",,"Z1",,23/8/2013 22:40:00
27,"#000027",,"NS","NO SALE",23/8/2013 22:40:00
28,"#000028",,"SALE",,24/8/2013 16:09:00
29,"#000029",,"SALE",,24/8/2013 16:28:00
30,"#000030",,"SALE",,24/8/2013 16:58:00

Body:
This is simple to be edit GetStockHead function

public List<StockHead> GetStockHead( string sql, params object[] args )
{
    DataTable t;
    if ( args == null )
    {
        Console.WriteLine( "GetStockHead #1 - args are NULL " );
    }
    else
    {
        Console.WriteLine( "GetStockHead #2 - {0} arguments passed", args.Count() );
    }

    Accdb.ExecuteQuery( out t, sql, args );

    if ( t != null )
    {
        List<StockHead> shlist = new List<StockHead>();

        foreach ( DataRow r in t.Rows )
        {
            Console.WriteLine( t.ToString() );
            StockHead sh = new StockHead(
                (int)r["sh_id"],
                (string)r["sh_ref"],
                (int)r["sh_lineno"],
                (string)r["sh_type"],
                (string)r["sh_supplier"],
                (DateTime)r["sh_datetime"]);
            shlist.Add( sh );
        }
        return shlist;
    }
    else
    {
        Console.WriteLine( "GetStockHead #3 - t is null" );
        return null;
    }
}


问:
How to work around poor text rendering in text backed by a CALayer
I have some variable text in an NSTextField that renders on a CALayer background view. As a CALayer does not support sub-pixel aliasing for text rendering of any text on top of it, this text looks rubbish.

A bit of googling reveals the reasons why this is, and that text must be rendered onto an opaque background to have SPA enabled. Rendering onto an opaque background is something I'd like to avoid if at all possible in this case. Is there a better workaround?

I am completely amenable to rendering the text myself into an NSImage, if that will help, but I can't find any confirmed reports that it will.

It looks absolutely fine in Interface Builder so I know the secret is somewhere inside this computer just straining to get out.

答:
Workaround found. Nothing in Quartz can render text with Sub-Pixel Aliasing on top of a transparent background, seemingly. However, you CAN render text to an offscreen bitmap buffer, providing that offscreen bitmap buffer has been created in the correct fashion. The background of this buffer must be opaque.

My view previously had a PNG background that was slightly transparent. I could have simply made this background opaque and rendered to it without problem, but as this view needs to fade in and out, it needed to be CALayer-backed, so the text renders once properly, and then subsequently renders without Sub-Pixel Aliasing.

Here's my code. It seems incredibly verbose, I'd love it if anyone could help me whittle it down. It assumes you have an NSImageView called _title and an NSString called title.

```<code>// Create the attributed string
NSMutableAttributedString *attStr = [[[NSMutableAttributedString alloc] initWithString: title] autorelease];

NSRange strRange = NSMakeRange(0, [attStr length]);
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize: NSSmallControlSize]];

[attStr addAttribute: NSForegroundColorAttributeName value: [NSColor whiteColor] range: strRange];
[attStr addAttribute: NSFontAttributeName value: font range: strRange];

NSMutableParagraphStyle *paraStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
[paraStyle setAlignment: NSCenterTextAlignment];
[paraStyle setLineBreakMode: NSLineBreakByTruncatingMiddle];
[attStr addAttribute: NSParagraphStyleAttributeName value: paraStyle range: strRange];

// Set up the image context
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * [_title frame].size.width;
NSUInteger bitsPerComponent = 8;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// These constants are necessary to enable sub-pixel aliasing.
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;

// Create the memory buffer to be used as the context's workspace
unsigned char *contextBuffer = malloc([_title frame].size.height * [_title frame].size.width * 4);

CGContextRef context = CGBitmapContextCreate(contextBuffer,
                                             [_title frame].size.width,
                                             [_title frame].size.height,
                                             bitsPerComponent,
                                             bytesPerRow,
                                             colorSpace,
                                             bitmapInfo);

[NSGraphicsContext saveGraphicsState];

[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]];

CGContextSetFillColorWithColor(context, CGColorGetConstantColor(kCGColorBlack));
CGRect rectangle = CGRectMake(0, 0, [_title frame].size.width,[_title frame].size.height);
CGContextAddRect(context, rectangle);
CGContextFillPath(context);

CTLineRef line = CTLineCreateWithAttributedString((CFAttributedStringRef)attStr);

CGContextSetTextPosition(context, 10.0, 10.0);
CTLineDraw(line, context);
CFRelease(line);

// Create a data provider from the context buffer in memory
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, contextBuffer, bytesPerRow * [_title frame].size.height, NULL);

// Create an image from the data provider
CGImageRef imageRef = CGImageCreate ([_title frame].size.width,
                                     [_title frame].size.height,
                                     bitsPerComponent,
                                     bytesPerPixel * 8,
                                     bytesPerRow,
                                     colorSpace,
                                     bitmapInfo,
                                     dataProvider,
                                     NULL,
                                     false,
                                     kCGRenderingIntentDefault
                                     );

// Turn it into an NSImage
NSImage *newImage = [[[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize] autorelease];

CGDataProviderRelease(dataProvider);
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CGImageRelease(imageRef);

free(contextBuffer);

[NSGraphicsContext restoreGraphicsState];

[_title setImage: newImage];
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Workaround found. Nothing in Quartz can render text with Sub-Pixel Aliasing on top of a transparent background, seemingly. However, you CAN render text to an offscreen bitmap buffer, providing that offscreen bitmap buffer has been created in the correct fashion. The background of this buffer must be opaque.

My view previously had a PNG background that was slightly transparent. I could have simply made this background opaque and rendered to it without problem, but as this view needs to fade in and out, it needed to be CALayer-backed, so the text renders once properly, and then subsequently renders without Sub-Pixel Aliasing.

Here's my code. It seems incredibly verbose, I'd love it if anyone could help me whittle it down. It assumes you have an NSImageView called _title and an NSString called title.

// Create the attributed string
NSMutableAttributedString *attStr = [[[NSMutableAttributedString alloc] initWithString: title] autorelease];

NSRange strRange = NSMakeRange(0, [attStr length]);
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize: NSSmallControlSize]];

[attStr addAttribute: NSForegroundColorAttributeName value: [NSColor whiteColor] range: strRange];
[attStr addAttribute: NSFontAttributeName value: font range: strRange];

NSMutableParagraphStyle *paraStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
[paraStyle setAlignment: NSCenterTextAlignment];
[paraStyle setLineBreakMode: NSLineBreakByTruncatingMiddle];
[attStr addAttribute: NSParagraphStyleAttributeName value: paraStyle range: strRange];

// Set up the image context
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * [_title frame].size.width;
NSUInteger bitsPerComponent = 8;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// These constants are necessary to enable sub-pixel aliasing.
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;

// Create the memory buffer to be used as the context's workspace
unsigned char *contextBuffer = malloc([_title frame].size.height * [_title frame].size.width * 4);

CGContextRef context = CGBitmapContextCreate(contextBuffer,
                                             [_title frame].size.width,
                                             [_title frame].size.height,
                                             bitsPerComponent,
                                             bytesPerRow,
                                             colorSpace,
                                             bitmapInfo);

[NSGraphicsContext saveGraphicsState];

[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]];

CGContextSetFillColorWithColor(context, CGColorGetConstantColor(kCGColorBlack));
CGRect rectangle = CGRectMake(0, 0, [_title frame].size.width,[_title frame].size.height);
CGContextAddRect(context, rectangle);
CGContextFillPath(context);

CTLineRef line = CTLineCreateWithAttributedString((CFAttributedStringRef)attStr);

CGContextSetTextPosition(context, 10.0, 10.0);
CTLineDraw(line, context);
CFRelease(line);

// Create a data provider from the context buffer in memory
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, contextBuffer, bytesPerRow * [_title frame].size.height, NULL);

// Create an image from the data provider
CGImageRef imageRef = CGImageCreate ([_title frame].size.width,
                                     [_title frame].size.height,
                                     bitsPerComponent,
                                     bytesPerPixel * 8,
                                     bytesPerRow,
                                     colorSpace,
                                     bitmapInfo,
                                     dataProvider,
                                     NULL,
                                     false,
                                     kCGRenderingIntentDefault
                                     );

// Turn it into an NSImage
NSImage *newImage = [[[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize] autorelease];

CGDataProviderRelease(dataProvider);
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CGImageRelease(imageRef);

free(contextBuffer);

[NSGraphicsContext restoreGraphicsState];

[_title setImage: newImage];


问:
Can you dynamically rename a class name?
Is it possible in Java to give a class or even its functions a new name at run time. By reading in the new names as arguments or on a configuration file when the program is started?

UPDATE:

Here is the purpose of this. I am using Java Script Engine to allow any JSR 223 compatible Scripting Language to access our API. Some of our clients are not used to using Java and it's naming conventions and would feel more comfortable using their own specific naming conventions. So I am required to give them the capability to dynamically change the API's class and function names without actually changing them in the code. It was suggested I use a Map and some sort of binding with a string name and the actual Java name e.g.,

```<code>    map.put("Hello",HelloWorld.class)

    Object obj = new Hello();
</code>```

which should be the same as,

```<code>    Object obj = new HelloWorld();
</code>```

If this is not possible please tell me why. I need a solid Java expertise answer. This is out of my league and I need facts to tell people why this is not possible even though myself I am almost sure it's not possible.

Possible Solution:

Here is the closets solution I have come up with. Using this link,
https://weblogs.java.net/blog/2005/08/10/reflection-and-dynamically-changing-classes
I could add in the names at run time, use composition to create an Adapter Class, and then compile the file, and voila the Script Language folks could use their defined names instead of my API's Java names.

Is this the only conceivable way to accomplish this?

UPDATE 2:

Here is another possible solution for anyone trying this too,

http://asm.ow2.org/doc/faq.html

That'll take you directly to their frequently asked questions which will have one for this exact problem.

答:
Yes, you are able to do that using javassist.
In particular, you have to edit NewExpr.</p>

Body:
Is it possible in Java to give a class or even its functions a new name at run time. By reading in the new names as arguments or on a configuration file when the program is started?

UPDATE:

Here is the purpose of this. I am using Java Script Engine to allow any JSR 223 compatible Scripting Language to access our API. Some of our clients are not used to using Java and it's naming conventions and would feel more comfortable using their own specific naming conventions. So I am required to give them the capability to dynamically change the API's class and function names without actually changing them in the code. It was suggested I use a Map and some sort of binding with a string name and the actual Java name e.g.,

    map.put("Hello",HelloWorld.class)

    Object obj = new Hello();

which should be the same as,

    Object obj = new HelloWorld();

If this is not possible please tell me why. I need a solid Java expertise answer. This is out of my league and I need facts to tell people why this is not possible even though myself I am almost sure it's not possible.

Possible Solution:

Here is the closets solution I have come up with. Using this link,
https://weblogs.java.net/blog/2005/08/10/reflection-and-dynamically-changing-classes
I could add in the names at run time, use composition to create an Adapter Class, and then compile the file, and voila the Script Language folks could use their defined names instead of my API's Java names.

Is this the only conceivable way to accomplish this?

UPDATE 2:

Here is another possible solution for anyone trying this too,

http://asm.ow2.org/doc/faq.html

That'll take you directly to their frequently asked questions which will have one for this exact problem.


问:
if else condition using sql query
I have problem to generate SQL query for below table.
Here is my table:

```<code>County          | Store     | Stock | Display | Designation
--------------- | --------- | ----- | ------- | ------------
USA             | USD       | 1     | Yes     | Merchandiser
USA             | USD       | 2     | Yes     | Promoter
</code>```

I want to be result like this

```<code>County          | Store     | Stock | Display | Designation
--------------- | --------- | ----- | ------- | ------------
USA             | USD       | 2     | Yes     | Merchandiser
USA             | USD       | 2     | Yes     | Promoter
</code>```

The Scenario is if Designation is Promoter, use both Display and Stock data.
If Designation is from Merchandiser, use data from Promoter for Stock data
How can i achieve this?

答:
Try This

```<code>SELECT County,
           Store ,
           (CASE WHEN (Designation = 'Merchandiser') THEN (SELECT SUM(STOCK) FROM TABLE WHERE County = County AND Designation = 'Promoter' GROUP BY County) ELSE STOCK END) AS "stock",
           Display,
           Designation
FROM table
</code>```

This request give you the needed result.

Title: if else condition using sql query

Body:
I have problem to generate SQL query for below table.
Here is my table:

County          | Store     | Stock | Display | Designation
--------------- | --------- | ----- | ------- | ------------
USA             | USD       | 1     | Yes     | Merchandiser
USA             | USD       | 2     | Yes     | Promoter

I want to be result like this

County          | Store     | Stock | Display | Designation
--------------- | --------- | ----- | ------- | ------------
USA             | USD       | 2     | Yes     | Merchandiser
USA             | USD       | 2     | Yes     | Promoter

The Scenario is if Designation is Promoter, use both Display and Stock data.
If Designation is from Merchandiser, use data from Promoter for Stock data
How can i achieve this?

Body:
Try This

SELECT County,
           Store ,
           (CASE WHEN (Designation = 'Merchandiser') THEN (SELECT SUM(STOCK) FROM TABLE WHERE County = County AND Designation = 'Promoter' GROUP BY County) ELSE STOCK END) AS "stock",
           Display,
           Designation
FROM table

This request give you the needed result.


问:
Cordova Hook should run only if --release is added in build command
I have a Cordova hook that executes after execution of build command. And one hook which executes before build command is executed.

I want it to executes only if --release attribute is added in build command.

Is it possible? As I am doing something in hook (i.e. changing version code of builds.) which I want to do only for release builds.

Please ask if something is unclear to you.

答:
I wrote a similar hook sometime back but not exactly the same. That was to parameterize the app id to install facebook plugin. You can follow the similar approach to address your issue too.

These links should help you out - SO post on hook and sample hook github repo. May be in your case you gotta set the release attribute as environment variable before every build instead of passing it as an build attribute. Hope it helps.

UPDATE: For mac OS, you can set environmental variables in the user directories .bash_profile


问:
recursive xml schema generation
I have an xml with a recursive element such as in the example below. A contains a sequence of B elements. Each B element contain a C, D, E and F element. Each F except the last one in the sequence contains a B element.

```<code><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<A>
  <B>
    <C></C>
    <D></D>
    <E></E>
          <F>
            <B>
              <C></C>
              <D></D>
              <E></E>
                    <F>
                      <B>
                        <C></C>
                        <D></D>
                        <E></E>
                        <F></F>
                      </B>
                    </F>
           </B>
        </F>
   </B>
</A>
</code>```

When I generate a schema for this xml using an online generator I get a really long schema file. Is there no way to write a shorter recursive schema for this xml?

答:
In your case where each element F except the last one in the sequence contains B element, I can offer tge following schema.
By using choice constuction it is possible to make last F element not recursive.
This schema validates correctly, but I'm not sure can it be an graceful solution.</p>

```<code><xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="A">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="B" type="B" minOccurs="0"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="F" type="B"/>
  <xsd:complexType name="B">
    <xsd:sequence>
      <xsd:element name="C" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      <xsd:element name="D" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      <xsd:element name="E" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      <xsd:choice>
        <xsd:element ref="F" minOccurs="0" maxOccurs="1"/>
        <xsd:element name="F" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      </xsd:choice>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>
</code>```

Title: recursive xml schema generation

Body:
I have an xml with a recursive element such as in the example below. A contains a sequence of B elements. Each B element contain a C, D, E and F element. Each F except the last one in the sequence contains a B element.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

    <C></C>
    <D></D>
    <E></E>
          <F>

              <C></C>
              <D></D>
              <E></E>
                    <F>

                        <C></C>
                        <D></D>
                        <E></E>
                        <F></F>

                    </F>

        </F>

When I generate a schema for this xml using an online generator I get a really long schema file. Is there no way to write a shorter recursive schema for this xml?

Body:
In your case where each element F except the last one in the sequence contains B element, I can offer tge following schema.
By using choice constuction it is possible to make last F element not recursive.
This schema validates correctly, but I'm not sure can it be an graceful solution.

<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="A">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="B" type="B" minOccurs="0"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="F" type="B"/>
  <xsd:complexType name="B">
    <xsd:sequence>
      <xsd:element name="C" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      <xsd:element name="D" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      <xsd:element name="E" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      <xsd:choice>
        <xsd:element ref="F" minOccurs="0" maxOccurs="1"/>
        <xsd:element name="F" type="xsd:string" minOccurs="0" maxOccurs="1"/>
      </xsd:choice>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>


问:
Bean instance is not getting loaded
I need a help regarding dependency injection.

I hava a bean class which is having a object reference of JdbcTemplate and I am using @Autowired to
create instance of that object. But that object is not getting loaded and as a result NullPointerException is thrown
from setCustName() method.

Please help

Bean Class :

```<code>class CustomerBean {

    private String custName;

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void setCustName(String custName) {
    this.custName = custName;
    jdbcTemplate.update(query);
    }
}
</code>```

XML :

```<code><bean id="myjdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource" />
 </bean>

 <bean id="custBean" class="com.test.CustomerBean">
        <property name="custName" value="John" />
 </bean>
</code>```

Stacktrace:

```<code>PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'custName' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1419)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
</code>```

答:
Use <context:annotation-config> which enables the usage of different annotations in bean classes.

Also I strongly recommend against usage of different dependencies in properties setters. In your code sample you assume that the jdbcTemplate was autowired before the call of the setter, fact that you cannot be sure of.

Therefore the logic that you placed in the setter, regarding the jdbc template would be more properly placed in a method annotated with @PostConstruct.

Title: Bean instance is not getting loaded

Body:
I need a help regarding dependency injection.

I hava a bean class which is having a object reference of JdbcTemplate and I am using @Autowired to
create instance of that object. But that object is not getting loaded and as a result NullPointerException is thrown
from setCustName() method.

Please help

Bean Class :

class CustomerBean {

    private String custName;

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void setCustName(String custName) {
    this.custName = custName;
    jdbcTemplate.update(query);
    }
}

XML :

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

 <bean id="custBean" class="com.test.CustomerBean">
        <property name="custName" value="John" />
 </bean>

Stacktrace:

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'custName' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1419)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)


问:
can I use ul li instead of select dropdown and with jquery make it part of a form?
I went really long way trying to rewrite select to ul li and style it accordingly. But I'm getting really annoyed with the weight of code and minor annoyances on the way.

So I'm thinking to ditch the idea completely, and just use normal ul li menu and some kind of javascript to make it function like select (for form submission etc).

So is this possible? any example code you can give me?

My concerns is Cross browser compatibility.

答:
To completely do it as list and with javascript is not the best idea because everyone that has no javascript cannot use this functionality.

Here is a jQuery implementation that has the regular form select fallback (In fact it maps a existing select). You just need to change the first selector and style the list ... the script does the rest.

```<code>jQuery( '.woocommerce-ordering select' ).each( function() {

    var target = jQuery( this );

    var selected = target.find( 'option:selected' ).text();

    var map = jQuery( '<div class="selectmap"><span>' + selected + '</span><ul class="selectmap"></ul></div>' ).insertAfter( target );

    target.hide();

    target.find( 'option' ).each( function() {

        var c = jQuery( this );
        var u = map.find( 'ul' );

        console.log( u );

        console.log( c.text() );

        jQuery( '<li data-value="' + c.attr( 'value' ) + '">' + c.text() + '</li>' ).appendTo( u );

    } );

    map.find( 'li' ).click( function() {

        map.find( 'span' ).text( jQuery( this ).text() );
        target.val( jQuery( this ).attr( 'data-value' ) ).trigger( 'change' );

    } );

} );
</code>```

Body:
To completely do it as list and with javascript is not the best idea because everyone that has no javascript cannot use this functionality.

Here is a jQuery implementation that has the regular form select fallback (In fact it maps a existing select). You just need to change the first selector and style the list ... the script does the rest.

jQuery( '.woocommerce-ordering select' ).each( function() {

    var target = jQuery( this );

    var selected = target.find( 'option:selected' ).text();

    var map = jQuery( '<div class="selectmap"><span>' + selected + '</span><ul class="selectmap"></ul></div>' ).insertAfter( target );

    target.hide();

    target.find( 'option' ).each( function() {

        var c = jQuery( this );
        var u = map.find( 'ul' );

        console.log( u );

        console.log( c.text() );

        jQuery( '<li data-value="' + c.attr( 'value' ) + '">' + c.text() + '</li>' ).appendTo( u );

    } );

    map.find( 'li' ).click( function() {

        map.find( 'span' ).text( jQuery( this ).text() );
        target.val( jQuery( this ).attr( 'data-value' ) ).trigger( 'change' );

    } );

} );


问:
OpenAL doesn't work when using AVAudioRecorder and AVAudioPlayer
i have been troubled about audio problem for several days. i don't think OpenAL get along with AVAudio functions.

i have my own OpenAL class. ( wrapped the MyOpenAL class )
my app start to record using AVAudioRecorder. i stop recording. and then i clicked the "OpenAL Play"button that play any sound using OpenAL.
i can't hear it.
but i can hear my recording when i clicked the "AVAudioPlayer Play" button using AVAudioPlayer.

i tested oalTouch,avTouch,SpeakHear sample code.
they resulted same.
in oalTouch, when AVAudioPlayer stop, OpenAL stop playing simultaneously. this is why i think so.

Does OpenAL have the problem using AVAudio~ Functions together?

I was googling for a long time. but i couln't find out the solutions and the same problems issue.

thanks for reading mine.

答: I'm using AVAudioRecorder (to record) and OpenAL (to playback) and they both go quite well. Just wanted to check if you use Play_And_Record as option when you initialize your AVAudioRecorder?</p>


问:
Method not allowed in Laravel 5.4
I am getting an method not allowed error while submitting a select box.

I am sending file url and array from view. I printed these values from controller it works fine but when trying to insert into db I am getting an error MethodNotAllowedHttpException. The Routes are working fine if I use dd( $excelData) i am getting the data.

```<code>public function uploadExcelData(Request $request)
{
    $url   = request('link');
    $array = request('index');
     print_r($array);
     echo $url;

    $excelData    = (Excel::load($url))->get();

    if(!empty($excelData) && $excelData->count()){

        foreach ($excelData->toArray() as $key => $value) {

            if(!empty($value)){

                    $insert[] = ['JobTitle' => $value[$array[0]], 'Skills' => $value[$array[1]],
                                 'Package'=>$value[$array[2]],"Location"=>$value[$array[3]]];
            }
        }

        if(!empty($insert)){
            Jobposting::insert($insert);
            return back();
        }else{
            echo "empty";

        }
    }
}
</code>```

This is the blade file

<?php
//print_r($excelHeaders);
 // print_r($dbHeaders);
 // @dd($excelData);
 //echo $url; onsubmit="return insertOrder();"
 ?>
<form  action="{{ URL::to('uploadExcelFile') }}" class="form-horizontal" method="POST" onsubmit="return insertOrder();">
{{ csrf_field() }}

@for ($i=1; $i < sizeof($dbHeaders); $i++)

   <input type="text" name="" value="{{$dbHeaders[$i]}}" disabled="disabled" class="droptargetinputs inputfields">

   <select class="order">
   <option>Select</option>
    @for ($j=1; $j < sizeof($excelHeaders); $j++)
      <option value="{{ $excelHeaders[$j]}}">{{ $excelHeaders[$j]}}</option>
    @endfor
   </select>
 <input type="hidden" name="link" value="{{$url}}">

@endfor

<input type="submit" name="submit" value="click">	</tb>

</form>

```

My Routes:

Route::get('uploadHome','ExcelController@showUpload');

Route::POST('importExcelFile', 'ExcelController@importExcel');

/*Route::match(['get', 'post'],'uploadExcelFile', 'ExcelController@uploadExcelData');
*/

Route::POST('uploadExcelFile', 'ExcelController@uploadExcelData');

答:
Assuming you double checked this:

The Routes are working fine if i use dd( $excelData) i am getting the data.

I think the problem may be here:

```<code>return back();
</code>```

I think there is a mess in your route verbs somewhere. So you could try to redirect like this:

```<code>return redirect('/my-route-that-works');
</code>```

If this still does not work, you should post your routes file too because in this case, I think your routes are not "working fine".

Reading your comment and your update, it seems you wrote Route::POST in uppercase, that's not the right way. Try replacing:

```<code>Route::POST
</code>```

By:

```<code>Route::post
</code>```

Title: Method not allowed in Laravel 5.4

Body:
I am getting an method not allowed error while submitting a select box.

I am sending file url and array from view. I printed these values from controller it works fine but when trying to insert into db I am getting an error MethodNotAllowedHttpException. The Routes are working fine if I use dd( $excelData) i am getting the data.

public function uploadExcelData(Request $request)
{
    $url   = request('link');
    $array = request('index');
     print_r($array);
     echo $url;

    $excelData    = (Excel::load($url))->get();

    if(!empty($excelData) && $excelData->count()){

        foreach ($excelData->toArray() as $key => $value) {

            if(!empty($value)){

                    $insert[] = ['JobTitle' => $value[$array[0]], 'Skills' => $value[$array[1]],
                                 'Package'=>$value[$array[2]],"Location"=>$value[$array[3]]];
            }
        }

        if(!empty($insert)){
            Jobposting::insert($insert);
            return back();
        }else{
            echo "empty";

        }
    }
}

This is the blade file

<?php
//print_r($excelHeaders);
 // print_r($dbHeaders);
 // @dd($excelData);
 //echo $url; onsubmit="return insertOrder();"
 ?>
<form  action="{{ URL::to('uploadExcelFile') }}" class="form-horizontal" method="POST" onsubmit="return insertOrder();">
{{ csrf_field() }}

@for ($i=1; $i < sizeof($dbHeaders); $i++)

   <input type="text" name="" value="{{$dbHeaders[$i]}}" disabled="disabled" class="droptargetinputs inputfields">

   <select class="order">
   <option>Select</option>
    @for ($j=1; $j < sizeof($excelHeaders); $j++)
      <option value="{{ $excelHeaders[$j]}}">{{ $excelHeaders[$j]}}</option>
    @endfor
   </select>
 <input type="hidden" name="link" value="{{$url}}">

@endfor

<input type="submit" name="submit" value="click">	</tb>

</form>

My Routes:

Route::get('uploadHome','ExcelController@showUpload');

Route::POST('importExcelFile', 'ExcelController@importExcel');

/*Route::match(['get', 'post'],'uploadExcelFile', 'ExcelController@uploadExcelData');
*/

Route::POST('uploadExcelFile', 'ExcelController@uploadExcelData');

Body:
Assuming you double checked this:

The Routes are working fine if i use dd( $excelData) i am getting the data.

I think the problem may be here:

return back();

I think there is a mess in your route verbs somewhere. So you could try to redirect like this:

return redirect('/my-route-that-works');

If this still does not work, you should post your routes file too because in this case, I think your routes are not "working fine".

Reading your comment and your update, it seems you wrote Route::POST in uppercase, that's not the right way. Try replacing:

Route::POST

By:

Route::post


问:
How to convert pandas statement to sql queries?
I have a task that I want to do a task using sql but the problem is I know pandas for making queries in a Dataframe. I have made a mask to query a Dataframe but it is pretty impossible to learn whole sql in few hours.Is there any way to convert pandas statements into sql queries.

My pandas Dataframe query look something like this :

```<code>    df=df[(df['a']>=something) & (df['b']=='sinf')...and some more]
</code>```

答:
Sounds like:</p>

```<code>Select *
From df
Where df.a>=something and df.b=sinf
</code>```

Body:
I have a task that I want to do a task using sql but the problem is I know pandas for making queries in a Dataframe. I have made a mask to query a Dataframe but it is pretty impossible to learn whole sql in few hours.Is there any way to convert pandas statements into sql queries.

My pandas Dataframe query look something like this :

    df=df[(df['a']>=something) & (df['b']=='sinf')...and some more]

Body:
Sounds like:

Select *
From df
Where df.a>=something and df.b=sinf


问:
SQL function in Excel
How can I use an SQL function that gives me a table in Excel. I looked everywhere and couldn't find a solution.

Thanks in advance

答:
you will need  programming to perform this task.
 many programming languages support such features.</p>

Title: SQL function in Excel


问:
In Nearby Message API How Can I get NearBy devices list who are connected??
Using Nearby Connection API we can get the Endpoints (means Nearby devices list)..So In Nearby Message API How Can I get NearBy devices list who are connected like NCAPI?? </p>

答: The Nearby Connections API in Google Play Services 11 allows you to discover and send payloads to nearby devices. </p>


问:
How to use explode function for finding the result like this? and please explain the meaning of each $delimiter used inside the explode function
My input is $text = '( ( LED AND DIODE ) OR ( "LEE power" and system ) ) '

I am applying explode function on this input

```<code>function multiexplode ($delimiters,$string)
{
    $ready = str_replace($delimiters, $delimiters[0], $string);
    $launch = explode($delimiters[0], $ready);
    return  $launch;
}
$exploded = multiexplode(array(' ',":" ), $text);
for($i=0;$i<(count($exploded));$i++)
    echo "<br> $exploded[$i]";
</code>```

My output is coming like this

```<code>0 - (
1 - (
2 - LED
3 - AND
4 - DIODE
5 - )
6 - OR
7 - (
8 - "LEE
9 - power"
10 - and
11 - system
12 - )
13 - )
</code>```

But I want to output like the following

```<code>0 - (
1 - (
2 - LED
3 - AND
4 - DIODE
5 - )
6 - OR
7 - (
8 - LEE power
9 - and
10 - system
11 - )
12 - )
</code>```

I want to store all words inside " " in one element of array.

答:
While this isn't a thoroughly-tested answer, this answers your current issue as you described it. Best of luck!

```<code>function concatenateQuotedElements($input_array)
{
  //As per the question, we'll be exploding our array by spaces " ".
  $pieces = explode(" ", $input_array);

  //This array will be returned as our final array of concatenated elements.
  $output_array = array();

  /*When we happen upon an element containing a
  parenthesis ('"') as the first character, we'll
  temporarily store so that we may concatenate
  future elements with it.*/
  $stored_element = null;
  $stored_position = null;

  /*Parse through our array and look for any character
  that contains a " and see whether it's at the beginning
  or the end of the string element.*/
  for ($i = 0; $i < count($pieces); $i++)
  {

    //If we detect a parenthesis in our element...
    if (strpos($pieces[$i], '"') !== false)
    {

      //See if it's at the beginning, and if it is, store it or future use.
      if (substr($pieces[$i], 0, 1) === '"')
      {
        $stored_element = $pieces[$i];
        $stored_position = $i;
      }

      /*Or, see if it's at the end of the string. If it is, we need to see
       if there's been a previous element with an opening parenthesis that
       we've stored and concatenate this element onto our stored element.*/
      if (
          substr($pieces[$i], -1) === '"' &&
          $stored_element !== null &&
          $stored_position !== null
         )
      {
        $output_array[$stored_position] = $stored_element . " " . $pieces[$i];

        /*Reset our temporary storage so that it hold
        any forthcoming elements with parenthesis.*/
        $stored_element = null;
        $stored_position = null;

        /*Finally, [Continue] to the next element without
        pushing this as a non-concatenated, standalone element.*/
        continue;
      }
    }

    array_push($output_array, $pieces[$i]);
  }

  return $output_array;
}
</code>```

For a specific output pertaining to your given array, you can use:

```<code>//Our example array given in the question:
$array = '( ( LED AND DIODE ) OR ( "LEE power" and system ) )';

//Our output:
$concatenate_quotes_array = concatenateQuotedElements($array);

//"Pretty print" the array result of the function
echo "```";
print_r($concatenate_quotes_array);
echo "```";
</code>```

Output:

```<code>Array
(
    [0] => (
    [1] => (
    [2] => LED
    [3] => AND
    [4] => DIODE
    [5] => )
    [6] => OR
    [7] => (
    [8] => "LEE power"
    [9] => and
    [10] => system
    [11] => )
    [12] => )
)
</code>```

Body:
My input is $text = '( ( LED AND DIODE ) OR ( "LEE power" and system ) ) '

I am applying explode function on this input

function multiexplode ($delimiters,$string)
{
    $ready = str_replace($delimiters, $delimiters[0], $string);
    $launch = explode($delimiters[0], $ready);
    return  $launch;
}
$exploded = multiexplode(array(' ',":" ), $text);
for($i=0;$i<(count($exploded));$i++)
    echo "
 $exploded[$i]";

My output is coming like this

0 - (
1 - (
2 - LED
3 - AND
4 - DIODE
5 - )
6 - OR
7 - (
8 - "LEE
9 - power"
10 - and
11 - system
12 - )
13 - )

But I want to output like the following

0 - (
1 - (
2 - LED
3 - AND
4 - DIODE
5 - )
6 - OR
7 - (
8 - LEE power
9 - and
10 - system
11 - )
12 - )

I want to store all words inside " " in one element of array.

Body:
While this isn't a thoroughly-tested answer, this answers your current issue as you described it. Best of luck!

function concatenateQuotedElements($input_array)
{
  //As per the question, we'll be exploding our array by spaces " ".
  $pieces = explode(" ", $input_array);

  //This array will be returned as our final array of concatenated elements.
  $output_array = array();

  /*When we happen upon an element containing a
  parenthesis ('"') as the first character, we'll
  temporarily store so that we may concatenate
  future elements with it.*/
  $stored_element = null;
  $stored_position = null;

  /*Parse through our array and look for any character
  that contains a " and see whether it's at the beginning
  or the end of the string element.*/
  for ($i = 0; $i < count($pieces); $i++)
  {

    //If we detect a parenthesis in our element...
    if (strpos($pieces[$i], '"') !== false)
    {

      //See if it's at the beginning, and if it is, store it or future use.
      if (substr($pieces[$i], 0, 1) === '"')
      {
        $stored_element = $pieces[$i];
        $stored_position = $i;
      }

      /*Or, see if it's at the end of the string. If it is, we need to see
       if there's been a previous element with an opening parenthesis that
       we've stored and concatenate this element onto our stored element.*/
      if (
          substr($pieces[$i], -1) === '"' &&
          $stored_element !== null &&
          $stored_position !== null
         )
      {
        $output_array[$stored_position] = $stored_element . " " . $pieces[$i];

        /*Reset our temporary storage so that it hold
        any forthcoming elements with parenthesis.*/
        $stored_element = null;
        $stored_position = null;

        /*Finally, [Continue] to the next element without
        pushing this as a non-concatenated, standalone element.*/
        continue;
      }
    }

    array_push($output_array, $pieces[$i]);
  }

  return $output_array;
}

For a specific output pertaining to your given array, you can use:

//Our example array given in the question:
$array = '( ( LED AND DIODE ) OR ( "LEE power" and system ) )';

//Our output:
$concatenate_quotes_array = concatenateQuotedElements($array);

//"Pretty print" the array result of the function
echo "<pre>";
print_r($concatenate_quotes_array);
echo "</pre>";

Output:

Array
(
    [0] => (
    [1] => (
    [2] => LED
    [3] => AND
    [4] => DIODE
    [5] => )
    [6] => OR
    [7] => (
    [8] => "LEE power"
    [9] => and
    [10] => system
    [11] => )
    [12] => )
)


问:
Django, Ajax url not found in js file
I'm making the website using django, python and javascript.
I get an error

'Not found: /schedule/{% url 'schedule_delete' %}' when I use the ajax in js file

fullcalendar.js

```<code>function eventElementHandlers(event, eventElement) {
    eventElement
        .click(function(ev) {
            var start = event.start;
            var id = event.id;
            var title = event.title;

            var allData = {'csrfmiddlewaretoken': '{{ csrf_token }}', "id":id, "start":start, "title":title};
            $.ajax({
                url: "{% url 'schedule_delete' %}",
                type: "POST",
                data: allData,
                dataType: "json",

                success: function(response){
                    alert("success!");
                    $('#used_session'+id).html(response.used_session);

                },
                error:function(error){
                    alert("fail!");
                }
            });
  }
</code>```

urls.py

```<code>from django.conf.urls import url
from . import views

urlpatterns= [
url(r'^$', views.home, name='home'),
url(r'^schedule_delete/$', views.schedule_delete, name='schedule_delete'),

]
</code>```

I also made schedule_delete in views.py.

Why url is wrong?? The same url format was okay in the other template. Is url foramt different depending on the django template or js file??

Any help will be very helpful to me, thanks!

答:
you can not use "{% url 'schedule_delete' %}" in your js file. You first need to take this url in an input in your html form and then read it using javascript or jquery.

In html write.

```<code><button ... id="ajax-button" data-ajax-target="{% url 'named-url' %}">
</code>```

and in javascript simply do

```<code>$.post($("#ajax-button").attr("data-ajax-target"), ... );
</code>```

this is just an example you can do similar in other ways also.

Title: Django, Ajax url not found in js file

Body:
I'm making the website using django, python and javascript.
I get an error

'Not found: /schedule/{% url 'schedule_delete' %}' when I use the ajax in js file

fullcalendar.js

function eventElementHandlers(event, eventElement) {
    eventElement
        .click(function(ev) {
            var start = event.start;
            var id = event.id;
            var title = event.title;

            var allData = {'csrfmiddlewaretoken': '{{ csrf_token }}', "id":id, "start":start, "title":title};
            $.ajax({
                url: "{% url 'schedule_delete' %}",
                type: "POST",
                data: allData,
                dataType: "json",

                success: function(response){
                    alert("success!");
                    $('#used_session'+id).html(response.used_session);

                },
                error:function(error){
                    alert("fail!");
                }
            });
  }

urls.py

from django.conf.urls import url
from . import views

urlpatterns= [
url(r'^$', views.home, name='home'),
url(r'^schedule_delete/$', views.schedule_delete, name='schedule_delete'),

]

I also made schedule_delete in views.py.

Why url is wrong?? The same url format was okay in the other template. Is url foramt different depending on the django template or js file??

Any help will be very helpful to me, thanks!

Body:
you can not use "{% url 'schedule_delete' %}" in your js file. You first need to take this url in an input in your html form and then read it using javascript or jquery.

In html write.

<button ... id="ajax-button" data-ajax-target="{% url 'named-url' %}">

and in javascript simply do

$.post($("#ajax-button").attr("data-ajax-target"), ... );

this is just an example you can do similar in other ways also.


答:
You are making a request to the url /schedule/schedule_delete/ but it looks like your urls.py is setup only to handle the url /schedule_delete/. Are you including the schedule urls.py from a main urls.py?

Also as the other answerer noted, you can't use django template variables in a javascript file.

Title: Django, Ajax url not found in js file


问:
Parallax scroll bar below fixed container
I am trying to use the parallax effect on a site that has a fixed nav bar at the top of the page. Due to the way the parallax effect deals with overflows, the scroll bar appears to sit underneath the fixed nav bar at the top of the page.

I have included a fiddle to demonstrate this.

I have tried placing the fixed navbar div inside the parallax container. This moves the navbar beneath the scrollbar but also results in the navbar not fixing to the top of the page.

Here is my code so far...

HTML

```<code>  <div class="navbar">NavBar</div>
  <div class="parallax">
    <div class="parallax_layer parallax_layer_back">
      <img class="backgroundImage" src="https://images.pexels.com/photos/131212/pexels-photo-131212.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb">
    </div>
    <div class="parallax_layer parallax_layer_base">
      <div class="title">Title</div>
      <div class="content">Content area</div>
    </div>
  </div>
</code>```

CSS

```<code>.parallax {
  height: 100vh;
  overflow-x: hidden;
  overflow-y: initial;
  perspective: 1px;
  -webkit-perspective: 1px;
}

.parallax_layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.parallax_layer_base {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.parallax_layer_back {
  transform: translateZ(-1px);
  -webkit-transform: translateZ(-1px);
}

.parallax_layer_back { transform: translateZ(-1px) scale(2); }

.parallax_layer_deep { transform: translateZ(-2px) scale(3); }

/* Example CSS for content */

* {
  margin: 0;
  padding: 0;
}

.title {
  position: absolute;
  left: 10%;
  top: 30%;
  color: white;
  font-size: 300%;
}

.backgroundImage {
  width: 100%;
  height: auto;
}

.content {
  margin-top: 100vh;
  width: 100%;
  height: 800px;
  background-color: #e67e22;
}

.navbar {width:100%; position: fixed; z-index: 999; background-color: red;}
</code>```

答:
Based on your source code, I have made a few changes. I'll explain step by step.

Assume that your NavBar's height is 50px, I lower .parallax class 50px down by using margin-top:50px;.

Also, we need to change your NavBar's position property from fixed to absolute.

Now there will be 2 scrollbar, one for the body and one for the .parallax contents. To hide the body's scrollbar, which is unnecessary, we can use overflow:hidden; for body tag.

This time, you will see that your NavBar won't cover the scrollbar, but the bottom of the scrollbar is unfortunately  unseeable since the contents is shifted 50px from to top. To solve this I use a simple Jquery code to set .parallax height equal to the remaining window's height.

You can have a look at the snippet.

$(document).ready(function(){
  $(".parallax").css("height",$(window).height()-50);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.parallax {
  margin-top:50px;
  overflow-x: hidden;
  overflow-y: initial;
  perspective: 1px;
  -webkit-perspective: 1px;
}

.parallax_layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.parallax_layer_base {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.parallax_layer_back {
  transform: translateZ(-1px);
  -webkit-transform: translateZ(-1px);
}

/* Depth Correction */

.parallax_layer_back { transform: translateZ(-1px) scale(2); }

.parallax_layer_deep { transform: translateZ(-2px) scale(3); }

/* Example CSS for content */

* {
  margin: 0;
  padding: 0;
}

.title {
  position: absolute;
  left: 10%;
  top: 30%;
  color: white;
  font-size: 300%;
}

.backgroundImage {
  width: 100%;
  height: auto;
}

.content {
  margin-top: 100vh;
  width: 100%;
  height: 800px;
  background-color: #e67e22;
}

.navbar {
  width:100%;
  position: absolute;
  top:0;
  z-index: 999;
  background-color: red;
  height:50px;
}

body{
  overflow:hidden;
}</code>```

 NavBar

Title

Content area

```

Body:
I am trying to use the parallax effect on a site that has a fixed nav bar at the top of the page. Due to the way the parallax effect deals with overflows, the scroll bar appears to sit underneath the fixed nav bar at the top of the page.

I have included a fiddle to demonstrate this.

I have tried placing the fixed navbar div inside the parallax container. This moves the navbar beneath the scrollbar but also results in the navbar not fixing to the top of the page.

Here is my code so far...

HTML

NavBar

Title

Content area

CSS

.parallax {
  height: 100vh;
  overflow-x: hidden;
  overflow-y: initial;
  perspective: 1px;
  -webkit-perspective: 1px;
}

.parallax_layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.parallax_layer_base {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.parallax_layer_back {
  transform: translateZ(-1px);
  -webkit-transform: translateZ(-1px);
}

.parallax_layer_back { transform: translateZ(-1px) scale(2); }

.parallax_layer_deep { transform: translateZ(-2px) scale(3); }

/* Example CSS for content */

* {
  margin: 0;
  padding: 0;
}

.title {
  position: absolute;
  left: 10%;
  top: 30%;
  color: white;
  font-size: 300%;
}

.backgroundImage {
  width: 100%;
  height: auto;
}

.content {
  margin-top: 100vh;
  width: 100%;
  height: 800px;
  background-color: #e67e22;
}

.navbar {width:100%; position: fixed; z-index: 999; background-color: red;}

Body:
Based on your source code, I have made a few changes. I'll explain step by step.

Assume that your NavBar's height is 50px, I lower .parallax class 50px down by using margin-top:50px;.

Also, we need to change your NavBar's position property from fixed to absolute.

Now there will be 2 scrollbar, one for the body and one for the .parallax contents. To hide the body's scrollbar, which is unnecessary, we can use overflow:hidden; for body tag.

This time, you will see that your NavBar won't cover the scrollbar, but the bottom of the scrollbar is unfortunately  unseeable since the contents is shifted 50px from to top. To solve this I use a simple Jquery code to set .parallax height equal to the remaining window's height.

You can have a look at the snippet.

$(document).ready(function(){
  $(".parallax").css("height",$(window).height()-50);
});

.parallax {
  margin-top:50px;
  overflow-x: hidden;
  overflow-y: initial;
  perspective: 1px;
  -webkit-perspective: 1px;
}

.parallax_layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.parallax_layer_base {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.parallax_layer_back {
  transform: translateZ(-1px);
  -webkit-transform: translateZ(-1px);
}

/* Depth Correction */

.parallax_layer_back { transform: translateZ(-1px) scale(2); }

.parallax_layer_deep { transform: translateZ(-2px) scale(3); }

/* Example CSS for content */

* {
  margin: 0;
  padding: 0;
}

.title {
  position: absolute;
  left: 10%;
  top: 30%;
  color: white;
  font-size: 300%;
}

.backgroundImage {
  width: 100%;
  height: auto;
}

.content {
  margin-top: 100vh;
  width: 100%;
  height: 800px;
  background-color: #e67e22;
}

.navbar {
  width:100%;
  position: absolute;
  top:0;
  z-index: 999;
  background-color: red;
  height:50px;
}

body{
  overflow:hidden;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="navbar"> NavBar </div>
  <div class="parallax">
    <div class="parallax_layer parallax_layer_back">
      <img class="backgroundImage" src="https://images.pexels.com/photos/131212/pexels-photo-131212.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb">
    </div>
  <div class="parallax_layer parallax_layer_base">
    <div class="title">Title</div>
    <div class="content">Content area</div>
  </div>
</div>


答:
Your javascript files have no access to a django context, since you are only rendering html files through django. What you need to do is put your javascript inline in your templates to be able to access the {% url %} template tag.

An alternative way is to create for example a data-url html attribute which you set to your url, and access that attribute in your javascript file.

Edit:

I am not sure what your html looks like but I assume your eventElement is a button.

```<code><button data-url="{% url 'schedule-delete' %}"></button>
</code>```

When you click the button your event handler is called in your js file:

```<code>function eventElementHandlers(event, eventElement) {
    eventElement
        .click(function(ev) {

            ...

            $.ajax({
                url: $(eventElement).data('url'),
                ...
</code>```

Title: Django, Ajax url not found in js file

Body:
Your javascript files have no access to a django context, since you are only rendering html files through django. What you need to do is put your javascript inline in your templates to be able to access the {% url %} template tag.

An alternative way is to create for example a data-url html attribute which you set to your url, and access that attribute in your javascript file.

Edit:

I am not sure what your html looks like but I assume your eventElement is a button.

<button data-url="{% url 'schedule-delete' %}"></button>

When you click the button your event handler is called in your js file:

function eventElementHandlers(event, eventElement) {
    eventElement
        .click(function(ev) {

            ...

            $.ajax({
                url: $(eventElement).data('url'),
                ...


问:
event is not null but _invocationList is null?
I thought that if I have this code:

```<code>    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        if (PropertyChanged != null) PropertyChanged(this, e);
    }
</code>```

and the PropertyChanged event wasn't hooked, ProeprtyChanged would be null, but I'm getting a PropertyChanged that is not null and whose _invocationList member is null and whose _invocationCount member is 0. This (I think) is causing an ArgumentOutOfRangeException when I invoke PropertyChanged(this, e). Any idea where could the problem be?

This is my stack trace from the OnClick event:

at System.Collections.ArrayList.get_Item(Int32 index)
     at System.Windows.Forms.BindingsCollection.get_Item(Int32 index)
     at System.Windows.Forms.BindingManagerBase.PushData(Boolean& success)
     at System.Windows.Forms.PropertyManager.OnCurrentChanged(EventArgs ea)
     at System.Windows.Forms.BindToObject.PropValueChanged(Object sender, EventArgs e)
     at System.EventHandler.Invoke(Object sender, EventArgs e)
     at System.ComponentModel.PropertyDescriptor.OnValueChanged(Object component, EventArgs e)
     at System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(Object component, EventArgs e)
     at System.ComponentModel.ReflectPropertyDescriptor.OnINotifyPropertyChanged(Object component, PropertyChangedEventArgs e)
     at Player.DataBaseManager.OnPropertyChanged(PropertyChangedEventArgs e) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 100
     at Player.DataBaseManager.set_TableNames(List`1 value) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 30
     at Player.DataBaseManager.UpdateTableNames() in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 95
     at Player.DataBaseManager.ExecuteNonQuery(String sqlQuery) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 336
     at WebScraperAndPlayer.DataBaseEditor.deleteTableButton_Click(Object sender, EventArgs e) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\BuilderForm2\Data\DataBaseEditor.cs:line 90
     at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
     at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

答:
Found the problem. I had a data table editor that had a TablesList property bound to a list of data tables in a data base manager object. In its set accessor I checked to see if the table still existed in the list and if it didn't the editor closed and removed the data binding from the data base manager. So, while the internals of .NET were looping through the objects bound to TablesList, one of them removed itself from the list. But .NET doesn't notice this change because of the way the loop is written:

```<code>int numLinks = Bindings.Count;
for (int i = 0; i < numLinks; i++) {
    if (Bindings[i].PushData()) {
        success = false;
    }
}
</code>```

I was basically removing the binding from inside the PushData() call. My solution was to attach an event handler to the PropertyChanged event and check the table list there. Apparently whatever loop .NET uses to loop through the invocation list of events let you remove an event while in the loop.

I guess the moral would be: Never remove a Binding that updates a property from the set accessor of that property; but is OK to remove an event handler from the event handler itself. Right?

Body:
I thought that if I have this code:

    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        if (PropertyChanged != null) PropertyChanged(this, e);
    }

and the PropertyChanged event wasn't hooked, ProeprtyChanged would be null, but I'm getting a PropertyChanged that is not null and whose _invocationList member is null and whose _invocationCount member is 0. This (I think) is causing an ArgumentOutOfRangeException when I invoke PropertyChanged(this, e). Any idea where could the problem be?

This is my stack trace from the OnClick event:

at System.Collections.ArrayList.get_Item(Int32 index)
     at System.Windows.Forms.BindingsCollection.get_Item(Int32 index)
     at System.Windows.Forms.BindingManagerBase.PushData(Boolean& success)
     at System.Windows.Forms.PropertyManager.OnCurrentChanged(EventArgs ea)
     at System.Windows.Forms.BindToObject.PropValueChanged(Object sender, EventArgs e)
     at System.EventHandler.Invoke(Object sender, EventArgs e)
     at System.ComponentModel.PropertyDescriptor.OnValueChanged(Object component, EventArgs e)
     at System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(Object component, EventArgs e)
     at System.ComponentModel.ReflectPropertyDescriptor.OnINotifyPropertyChanged(Object component, PropertyChangedEventArgs e)
     at Player.DataBaseManager.OnPropertyChanged(PropertyChangedEventArgs e) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 100
     at Player.DataBaseManager.set_TableNames(List`1 value) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 30
     at Player.DataBaseManager.UpdateTableNames() in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 95
     at Player.DataBaseManager.ExecuteNonQuery(String sqlQuery) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\Player\DataBaseManager2.cs:line 336
     at WebScraperAndPlayer.DataBaseEditor.deleteTableButton_Click(Object sender, EventArgs e) in C:\Users\Juan Luis\My Dropbox\Documents\CodeWebScraper sin Player\WebScraperAndPlayer\BuilderForm2\Data\DataBaseEditor.cs:line 90
     at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
     at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

Body:
Found the problem. I had a data table editor that had a TablesList property bound to a list of data tables in a data base manager object. In its set accessor I checked to see if the table still existed in the list and if it didn't the editor closed and removed the data binding from the data base manager. So, while the internals of .NET were looping through the objects bound to TablesList, one of them removed itself from the list. But .NET doesn't notice this change because of the way the loop is written:

int numLinks = Bindings.Count;
for (int i = 0; i < numLinks; i++) {
    if (Bindings[i].PushData()) {
        success = false;
    }
}

I was basically removing the binding from inside the PushData() call. My solution was to attach an event handler to the PropertyChanged event and check the table list there. Apparently whatever loop .NET uses to loop through the invocation list of events let you remove an event while in the loop.

I guess the moral would be: Never remove a Binding that updates a property from the set accessor of that property; but is OK to remove an event handler from the event handler itself. Right?


问:
How can I use a select2 selectbox with dataTables?
I want to use a select2 selectbox inside my bootstrap datatable. I need to use the full select2 js But it is not working and I am wondering why.

$(document).ready(function() {
    var table = $('#example').DataTable( {
        scrollY:        "300px",
        scrollX:        true,
        scrollCollapse: true,
        paging:         false,
        fixedColumns:   {
            leftColumns: 1,
            rightColumns: 1
        }
    } );
} );

$("#e1").select2();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>td, th{background-color:white;}</code>```

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>

<link href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.2/select2.css" rel="stylesheet"/>

                First name
                Last name
                Position
                Office
                Age
                Start date
                Salary
                Extn.
                E-mail

                <select  id="e1">
        <option value="AL">Alabama</option>
        <option value="Am">Amalapuram</option>
        <option value="An">Anakapalli</option>
        <option value="Ak">Akkayapalem</option>
        <option value="WY">Wyoming</option>
    </select>
                Satou
                Accountant
                Tokyo
                33
                2008/11/28
                $162,700
                5407
                a.satou@datatables.net

```

答:
You are using a CSS 3.2 version along with a 4.0.3 version of the libray! Since version 4 is a complete rewrite any UI will fail. Find matching versions here.

You need to instantiate select2 after dataTables is initialised. You can do that in the drawCallback callback.

Do not use id's to reference the select2's. I guess you will have a lot of select2's on multiple pages, so give them a dummy class like dt-select2 so you can initialise all visible select2's in one call. But by all mean preserve the id's for reference in event handlers.

Example :

```<code>$('#example').DataTable({
  ...
  drawCallback: function() {
     $('.dt-select2').select2();
  }
})
</code>```

demo

ContentLicense: CC BY-SA 4.0

Body:
I want to use a select2 selectbox inside my bootstrap datatable. I need to use the full select2 js But it is not working and I am wondering why.

$(document).ready(function() {
    var table = $('#example').DataTable( {
        scrollY:        "300px",
        scrollX:        true,
        scrollCollapse: true,
        paging:         false,
        fixedColumns:   {
            leftColumns: 1,
            rightColumns: 1
        }
    } );
} );

$("#e1").select2();

td, th{background-color:white;}

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>

<link href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.2/select2.css" rel="stylesheet"/>

                First name
                Last name
                Position
                Office
                Age
                Start date
                Salary
                Extn.
                E-mail

                <select  id="e1">
        <option value="AL">Alabama</option>
        <option value="Am">Amalapuram</option>
        <option value="An">Anakapalli</option>
        <option value="Ak">Akkayapalem</option>
        <option value="WY">Wyoming</option>
    </select>
                Satou
                Accountant
                Tokyo
                33
                2008/11/28
                $162,700
                5407
                a.satou@datatables.net

Body:
You are using a CSS 3.2 version along with a 4.0.3 version of the libray! Since version 4 is a complete rewrite any UI will fail. Find matching versions here.

You need to instantiate select2 after dataTables is initialised. You can do that in the drawCallback callback.

Do not use id's to reference the select2's. I guess you will have a lot of select2's on multiple pages, so give them a dummy class like dt-select2 so you can initialise all visible select2's in one call. But by all mean preserve the id's for reference in event handlers.

Example :

$('#example').DataTable({
  ...
  drawCallback: function() {
     $('.dt-select2').select2();
  }
})

demo