Q: Use DatePart() function on calculated field Access 2010 Okay so I would like to create a calculated field in access to automatically create an invoice number in the format that my company is already using.
The format is MM/YY-Group Number
I already have a field with the group number in it, and another field that has a date in the format of m/d/yyyy
I would like to pull the two digit month and the two digit year from the date field in the calculated field. I know I could use the DatePart function, but for whatever reason that function doesn't seem to work in a calculated field expression.
If anybody has any ideas of how I could accomplish this I would appreciate it.

A: Something like this should work:
Right("0" & Month([DateField]),2) & "/" & Right(Year([DateField]),2) & "-" & [GroupNumber]


Q: webpack gl-matrix as an external I'm writing a library using gl-matrix as a dependency. I'm using webpack to output the src and want to exclude gl-matrix part from my code but list it as a dependency.
But turns out I can only packed the gl-matrix into the lib, or have error saying objects from gl-matrix like vec3 is undefined in my lib. Any ideas?
webpack.config.js
module.exports = {
  //...
  output: {
    filename: 'minimal-gltf-loader.js',
    path: path.resolve(__dirname, 'build'),
    library: 'MinimalGLTFLoader',
    libraryTarget: 'umd'
  },
  externals: {
    glMatrix: {
      commonjs: 'gl-matrix',
      commonjs2: 'gl-matrix',
      amd: 'gl-matrix'
    }
  }
}

minimal-gltf-loader.js (my lib)
import {vec3, vec4, quat, mat4} from 'gl-matrix';
//...
export { MinimalGLTFLoader };

the app
import {vec3, vec4, quat, mat4} from 'gl-matrix';
var mgl = require('../build/minimal-gltf-loader.js');

A: externals: {
    'gl-matrix': {
      commonjs: 'gl-matrix',
      commonjs2: 'gl-matrix',
      amd: 'gl-matrix'
    }
}

external dict name should match name of the lib

A:   externals: [
    {
      'gl-matrix': {
        root: 'window',
        commonjs: 'gl-matrix',
        commonjs2: 'gl-matrix',
        amd: 'gl-matrix'
      }
    }
  ]

If you import gl-matrix via script tag, it will be several global variables like vec3,mat4, but not gl-matrix.vec3,gl-matrix.mat4.
So you can set them to one variable and then use this variable as webpack external root config.
Then I found that window object has window attr that points to it self, so use 'window' in root field is a better choice and it's doesn't need to declare a united variable anymore.


Q: video.js unable to read local videos I've a little video.js player and i'm new to web devlopment.
I want it to read my local videos but i've a message:
"Sorry no compatible source and playback technology were found for this video."
But: If i use the external link given by video.js as sample, i can read the video.
I downloaded some samples to try out. An OGV one worked on the website i downloaded it. But when i try with my own, it doesn't work and show the same error.
Here is the .jsp code :
   <div id="videoPlayer">
        <video id="videoClip" class="video-js vjs-default-skin"
               controls preload="auto" width="640" height="360"
               poster="http://video-js.zencoder.com/oceans-clip.png"
               data-setup='{"example_option":true}'>

            <source src="/home/ogda/Bureau/war/src/main/resources/small.ogv type=video/ogg" />
        </video>
    </div>

    <script type="text/javascript" language="javascript">
        var videoPlayer = videojs("videoClip");
        videoPlayer.on("pause", changeVideo);
        //videoPlayer.src("/home/ogda/Bureau/war/src/main/resources/lol.mp4");
        videoPlayer.play();
    </script>

Thank you !
EDIT : ANSWER
Commenters were right.
The solution was siomply to put the videos on a webserver !

A: This is a sandbox problem. The browser does not allow loading local resources for security reasons. If you need it still, use a local webserver on your machine.

A: Most major browsers don't allow you to load in local files, since that poses a security error, e.g. people stealing secure files.
You need to test this on localhost, or setup some other server to test it.
Or, if you're using Chrome, you can turn on the flag that'll allow you to load in local files.
chrome --allow-file-access-from-files

run this from command line


Q: GTK3: gtk_menu_popup_at_pointer() without trigger_event I'm working on an otherwise non-GTK application (actually SDL2), where the right click into the window causes to open a GTK pop-up menu, so as you can see, here, GTK is just used for that purpose (and for some other, like file selection dialogue box, etc, but it's not the scope of my question).
I can happily use gtk_menu_popup(), and it works nicely. The only problem is the following warning during compilation:
warning: ‘gtk_menu_popup’ is deprecated: Use '(gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)' instead
Which is fair enough, so I want to use gtk_menu_popup_at_pointer(), since this is what I want basically. However this is my problem. That it expects a trigger_event, which I don't have, since no GTK event triggered that, but my own code, which is SDL2 ... According to the documentation I can use NULL as the trigger_event, however if I do this, I get the following messages at stdout, and no popup is shown:
Gtk-WARNING **: 19:10:53.512: no trigger event for menu popup
Gtk-CRITICAL **: 19:10:53.512: gtk_menu_popup_at_rect: assertion 'GDK_IS_WINDOW (rect_window)' failed
My question: is it possible to solve my problem (using GTK popup from a non-GTK application) without using deprecated function (gtk_menu_popup - which is actually works, just it's ugly that I use a deprecated feature ...).
The popup menu is created with gtk_menu_new() it has no "parent" or containers, or anything, since it's the only thing I want to use from GTK at this part of my application.


Q: Scraping selective links from a webpage I have created a scraper using python which is parsing links from a webpage. It scrapes 10 links from that site. Is it possible if i want to parse the first 8 links or the last 8 links out of that 10 links? Actually, I can't get any idea how to do so. Any help would be highly appreciated.
import requests
from lxml import html

url = "http://www.supplyhouse.com/"
def Selectivelinks(address):
    response = requests.get(address)
    tree = html.fromstring(response.text)
    titles = tree.xpath('//ul[@id="shop-by-category-list"]')
    for title in titles:
        links=title.xpath('.//a/@href')
        for lnk in links:
            print(lnk)
Selectivelinks(url)

A: If links returns a list. Then you can fetch the last 8 links using links[:-8]
Consider x contains a list of numbers from 1-10 then x[-8:] will return the last 8 items in the list
x = [i for i in range (0, 10)]
print x[-8:]
# [2, 3, 4, 5, 6, 7, 8, 9]

Also known as list slicing.


Q: When a mysql database value is null, JTable getValue is not working I have a JTable that gets values from mysql and I have a MouseClicked action that when I click a row, it takes the values and writes to the JTextFields. The problem is when mysql value is null, it gives NullPointerException and dosen't write anything to the JTextFields.
It works when they are not null and shows the whole information where I want it. But I want it to write them as a empty JTextFields without error when they are null.
This is my mouseclick action code that only works when selected row's value is not null:
 private void calisanTablosuMouseClicked(java.awt.event.MouseEvent evt) {
    int selectedrow = calisanTablosu.getSelectedRow();
    alan_adSoyad.setText(calisanTablosu.getValueAt(selectedrow,1).toString());
    }

Not very good at English so basic explanation or just the code will be good. Thanks.


Q: When IP aliasing how does the OS determine which IP address will be used as source for outbound TCP/IP connections? I have a server running Ubuntu Server with four IP addresses aliased on a single NIC.
eth0       192.168.1.100
eth0:0     192.168.1.101
eth0:1     192.168.1.102
eth0:2     192.168.1.103

(Using 192.168.x.x for sake of example, assume these are NAT-ed to a range of public IP addresses)
One of our clients publishes their inventory via FTP, so we log in nightly to download a large file from their server.  Their firewall expects our (passive) FTP connection to be made from 192.168.1.100.
Given that my server logically has four IP addresses on a single adapter, how does the operating system determine which IP address is used as source for outbound TCP/IP connections?
Let's say I ssh into my server on 192.168.1.101 and run FTP interactively.  Will the outbound TCP/IP connection use 192.168.1.101 because the OS knows that's the interface over which my shell is connected?
What if the FTP task is run non-interactively via a cron job where there is no shell?
As you can probably tell, this has me quite confused, so I hope my questions have at least
made sense.
Edit
To clarify why I'm asking -- I haven't made any changes to the routing table and it actually lists 'eth0' as the IFace for the 0.0.0.0 routes.  However, all indications are that it is actually using eth0:0 as the source.
Destination    Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0        192.168.1.1     0.0.0.0         UG    100    0        0 eth0

I can fiddle with the routing table or have our client change their firewall rules to get the behavior I need, but I'm trying to gain a little insight into how this works to know if there's a bug in the OS or just my naive understanding of how all the pieces fit together.
Thanks

A: It uses whatever the default gateway is in the routing table, unless there is a specific route telling it to use another: route -n
EDIT: I read your question too quick it seems...
Since you are using passive mode and the client will always be initiating the connection, I think src ip field in the IP header will always appear as whatever IP the client connected to. If it were active mode the server was initiating the connection, I think it would always be the 'Primary' IP.  If your addresses are in the same subnet, Linux will make the first address you added 'Primary' and the others secondary.
I am not entirely sure though, I would run tcpdump -n and see what it sees as the src IP.
EDIT2: Okay, I wrote the above from the standpoint that you were running the server, so since you are the client and initiating the connection, I think it will always appear to come from the Primary IP address, but again, try it and see with tcpdump.

A: I see in your example that all the ips are too close not to be in the same network
are you sure that you are actually multihoming and not simply having 4 IP aliases?
if the latter is the case then you can set the source ip on a route with something similar to this

/sbin/ip route show
  192.168.222.0/24 dev eth0  proto kernel  scope link  src 192.168.222.178
  169.254.0.0/16 dev eth0  scope link
  default via 192.168.222.1 dev eth0
sudo /sbin/ip route replace default via 192.168.222.1 src 192.168.222.178
/sbin/ip route show
  192.168.222.0/24 dev eth0  proto kernel  scope link  src 192.168.222.178
  169.254.0.0/16 dev eth0  scope link
  default via 192.168.222.1 dev eth0  src 192.168.222.178

see man interfaces on how to make it persistent between reboots

A: Unless your FTP job has a way of specifying the interface to use for connections, I believe it defaults to the first physical interface on the relevant subnet (eth0 in this case). If you had a server with two NICs on different subnets, it'd figure out which interface to use based on the routing table.
As there is only a single physical interface on the system (eth0) and four virtuals/aliases (eth0:0 through eth0:2) on the same subnet, outbound traffic will use the eth0 IP address as the source unless the application is smart enough to declare an outbound interface.

A: You could see which device and src ip address will be used by ip route get command like below:
$ /sbin/ip route get 1.1.1.1
1.1.1.1 via 2.2.2.2 dev eth0  src 2.2.2.2
    cache  mtu 1500 advmss 1460 hoplimit 64

I haven't tried this in aliased environment, but hope this helps.

A: By default, on Linux, if an interface has multiple addresses that are on different subnets, traffic destined for the respective subnets will have the proper source IP.  That is, if eth0 has two addresses 192.168.1.1/24 and 10.1.1.1/8, then traffic to anything on the 10.0.0.0 subnet will have source 10.1.1.1, and traffic to anything on the 192.168.1.0 subnet will have source 192.168.1.1.  You can also assign source addresses explicitly in this case by using the "src 1.2.3.4" option to "ip route".
In your case, though, all your addresses are on the same subnet, so the "primary" one (as revealed by "ip addr list dev eth0") is used as the source IP for traffic exiting on that interface.  I think it's possible to control the source IPs in this case just using "ip route", but I've found it easier to use iptables to rewrite the source addresses for traffic of interest.
If you want to force a specific source address to be used for specific destinations, you can do it with a SNAT rule:
iptables -t nat -I POSTROUTING -o eth0 -d dest-IP-or-net/mask -s primary-IP-of-eth0 -j SNAT --to-source desired-source-IP

So if your "primary" eth0 IP is 192.168.100.1, but you want traffic to 1.2.3.4 to have a source of 192.168.100.2, then do this:
iptables -t nat -I POSTROUTING -o eth0 -d 1.2.3.4/0 -s 192.168.100.1 -j SNAT --to-source 192.168.100.2

Note that the "-s 192.168.100.1" is important: it prevents forwarded traffic's source addresses being rewritten by this rule.
If you are going to implement complex network configurations on Linux, you should read the Linux Advanced Routing and Traffic Control documentation, http://lartc.org

A: When establishing an outbound connection, your server will look in its routing table to determine which of your four interfaces to use; your TCP connections will have a source IP of your exit interface.
netstat -rn

Will give you the output of your routing table; look for any specific entries matching the client IP you are trying to connect to. If none exist, then you will be using a default route (0.0.0.0, mask 0.0.0.0). If you have multiple default routes, the one with the lowest cost will be the one used.


Q: Add fields on runtime - Microsoft Fakes Framework Using Microsoft Fakes Framework, I am working on Unit Tests. But I encouter a problem. I need to fake a dbml DataContext. This are Linq to SQL classes.
What I need to do is faking method InsertOnSubmitT0() of the class System.Data.Linq.Table. I want to add the param object to be add to a local field instead of writing it to the database.
My question is: how can I add the local field Transports on runtime on the existing class Table? Something like this:
using (ShimsContext.Create())
            {
                var shimLinq = new ShimTable<Transport>()
                {
                    //something like this:
                    //addField("transports", List<Transport>, false);
                    InsertOnSubmitT0 = (transport) =>
                    {
                        Transport t = (Transport)transport;
                    }
                };
             }

A: Generally speaking you can't add something to an existing type. (you can however create a subtype at runtime and add things to that)
In your case though I suggest just using a regular variable that you capture when you create the shim, you can then return that variable as part of your shim and read it later at your descresion
var thelist = new List<Transport>(); //fill out whatever test data you want here, in the case of TransportsGet
using (ShimsContext.Create())
  {
    var shimLinq = new ShimTable<Transport>()
    {
      InsertOnSubmitT0 = (transport) =>
      {
        Transport t = (Transport)transport;
        thelist = t.Transports; // assign your outer variable, or do the asserts directly
      }
    };
  }
// do assertions on thelist here

In the comments you mentioned shimming TransportsGet, you can do this the same way and just return thelist in that shim. Then you can do asserts on thelist variable at the end of the test.
However if you want to test a .Where statement, that wont show up on the actual list directly, you have to test it some other way. You could have a thelist with invalid banks and assert that the code doesn't return anything for example


Q: Using GLEW in a static library I have a static library project and a standard windows executable project that uses the static library. In the static library, I initialise GLEW and use various gl* functions in various classes (including templates). In the executable, I initialise GLFW (which happens before initialising GLEW, as required by the library) and use functions and classes defined in the static library.
However, I am getting access violations when glfwPollEvents() is called which makes me wonder if it's valid to include and initialise GLEW in a static library project used in an executable project with GLFW included and initialised.
In addition, is there anything special about static libraries in terms of memory access between the lib and exe? Is it possible to use gl* functions in both the static library and the executable project which alter the same context?


Q: Conditional renaming with batch file i'd like to rename two files in a specific directory on my computer with a batch file.
The problem is that i'd like, if it's possible doing so with standard batch commands, to rename the files conditionally. To be more specific, my example is as follows:
I've got two "hosts" files located in C:\Windows\System32\drivers\etc; one is named "hosts", the other is named "hosts_X", a "hosts" file that contains specific instructions that i need to be active in a specific case.
I'd like to switch between this two "hosts" files: there are two cases: case "A" in which there's a "hosts" file and a "hosts_X" file, case "B" in which the original "hosts" file is renamed to "hosts_Y" and "hosts_X" is renamed to "hosts".
Is it possible to have a single batch file that renames the two files conditionally? Like, if there's a file named "hosts" and a file named "hosts_x", rename "hosts" to "hosts_y" and "hosts_x" to hosts, and if there's a file named "hosts" and a file named "hosts_y", rename "hosts" to "hosts_x" and "hosts_y" to "hosts"?
Thank you for any info and help!

A: I summarize the useful suggestions by Liturgist and Alex K. and answer this question to get it removed from list of questions with no answer.
Batch file according to idea provided by Liturgist:
@echo off
if not "%~1" == "" (
    if exist "C:\Windows\System32\drivers\etc\hosts_%~1" (
        copy /Y "C:\Windows\System32\drivers\etc\hosts_%~1" C:\Windows\System32\drivers\etc\hosts
    ) else (
        echo %~f0 %*
        echo.
        echo Error: There is no file C:\Windows\System32\drivers\etc\hosts_%~1
        echo.
        pause
    )
) else (
    echo %~f0
    echo.
    echo Please call this batch file with either X or Y as parameter.
    echo.
    pause
)

The batch file must be called with a parameter which specifies which hosts file should become active with at least hosts_X and hosts_Y in directory C:\Windows\System32\drivers\etc.
The parameter should be either X or Y.
An additional file check is made in case of parameter does not specify an existing hosts file resulting in an error message.
There is also a message output if batch file is called without a parameter.
Batch file according to idea provided by Alex K.:
@echo off
if exist C:\Windows\System32\drivers\etc\hosts_X (
    ren C:\Windows\System32\drivers\etc\hosts hosts_Y
    ren C:\Windows\System32\drivers\etc\hosts_X hosts
    echo hosts_X is now the active hosts file.
) else (
    ren C:\Windows\System32\drivers\etc\hosts hosts_X
    ren C:\Windows\System32\drivers\etc\hosts_Y hosts
    echo hosts_Y is now the active hosts file.
)
echo.
pause

This batch file toggles active hosts file depending on which template hosts file currently exists:

*

*With hosts_X existing, hosts is renamed to hosts_Y and hosts_X is renamed to hosts.

*Otherwise with hosts_Y existing, hosts is renamed to hosts_X and hosts_Y is renamed to hosts.

There should be never hosts, hosts_X and hosts_Y all existing at the same time in the directory as this would result in failing file renames. But all 3 files existing at same time should not be a use case to take into account for this task. (Using move /Y instead of ren with second file name having also full path would help in this not to expect use case.)
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

*

*call /? ... for an explanation of %~1, %~f0 and %*.

*copy /?

*echo /?

*if /?

*ren /?

*pause /?


Q: Is this list-initialization of an array of unknown size valid in C++0x? Is this list-initialization of an array of unknown size valid in C++0x?
int main() { int x[]{0, 1,2,3,4}; return x[0]; }

I believe it is valid, but would appreciate some confirmation.
If anyone could quote from the C++0x-FCD to support their case, it would be greatly appreciated.
Thanks!

A: This goes from 8.5/16 first bullet to 8.5.4 list-initialization and from 8.5.4/3 third bullet to 8.5.1 aggregate initialization and then 8.5.1/4 says

An array of unknown size initialized with a brace-enclosed initializer-list containing n initializer-clauses, where shall be greater than zero, is deﬁned as having elements

The only difference if the object is an array between = { ... } and { ... } is that the first is called copy-list-initialization and the second is called direct-list-initialization, so both are kinds of list-initialization. The elements of the array are copy-initialized from the elements of the initializer list in both cases.
Notice that there is a subtle difference between those forms if the array has a size and the list is empty, in which case 8.5.4 second bullet applies:
struct A {
  explicit A();
};

A a[1]{};    // OK: explicit constructor can be used by direct initialization
A a[1] = {}; // ill-formed: copy initialization cannot use explicit constructor

This difference does not apply to lists that have content in which case third bullet applies again, though
struct A {
  explicit A(int);
};

A a[1]{0};    // ill-formed: elements are copy initialized by 8.5.1
A a[1] = {0}; // ill-formed: same.

The FCD changed this compared to the previous draft, and initialization with an empty initializer list now always works even with explicit default constructors. This is because the FCD states that the elements are value-initialized, and value initialization doesn't care about explicitness since it doesn't do overload resolution on default constructors (it couldn't figure out better or worse matches anyway). The previous draft used normal overload resolution on the constructors and thus rejected explicit default constructors during copy initialization. This defect report did that change.

A: Yes, it is valid, and has been for decades, even in C. The size is simply set to the number of elements supplied. I don't know the reference, unfortunately.
(Added bonus...) If you need the number of elements use sizeof(x)/sizeof(*x). It's safer than hard-coding a constant that may become invalid if you add or remove entries.
EDIT: As pointed out in the comments, the code in question is missing an = (a fact that I missed), without which it isn't valid in any current standard of C or C++.


Q: array_map w/ null value I use the following to take an array called $list and turn it into URLs:
function genIMG($sValue) {
return 'http://asite.com/'.$sValue.'?&fmt=jpg';
}
$IMGurls = array_map("genIMG", array_unique($list));
foreach($IMGurls as $imgLink) {
echo "". $imgLink ."
";
}

This works, but I also have some null values in the array.  How can I have the array map ignore any values of null?  Otherwise it just creates something like this:
http://asite.com/?&fmt=jpg with no file name since it was null.

A: You $list must have contained empty values use array_filter
    $IMGurls = array_map("genIMG", array_unique(array_filter($list)));

Example
$list = array(1,2,3,4,5,"","",7);

function genIMG($sValue) {
    return 'http://asite.com/' . $sValue . '?&fmt=jpg';
}

$IMGurls = array_map("genIMG", array_unique(array_filter($list)));
foreach ( $IMGurls as $imgLink ) {
    echo "" . $imgLink . "
";
}

Output
http://asite.com/1?&fmt=jpg
http://asite.com/2?&fmt=jpg
http://asite.com/3?&fmt=jpg
http://asite.com/4?&fmt=jpg
http://asite.com/5?&fmt=jpg
http://asite.com/7?&fmt=jpg


Q: search function not working - Ruby on rails I'm new to Ruby on Rails and trying to implement a search function with simple form to filter out availabilities results. After I press search button, it still stays on the same page and not running the search function in the controller. The permitted is false. I'm wondering why this might occur. Is there anything wrong with the search_params I wrote?
Rails version is 6.0.2.1.
views/availabilities/_searchform.html.erb
<form>

        <%= simple_form_for :search, :url => search_rides_result_path, :method => :get do |f| %>

                <%= f.input :start_city, label: 'Start City', class: "form-control", error: 'Start address is mandatory, please specify one' %>

                <%= f.input :start_street_address, label: 'Start Street Address', class: "form-control" %>

                <%= f.input :end_city, label: 'Destination City', class: "form-control" %>

                <%= f.input :end_street_address, label: 'Destionation Street Address', class: "form-control" %>

                <%= f.input :trip_time, as: :datetime, inline_label: 'Yes, remember me', class: "form-control" %>

                <%= f.input :lowest_acceptable_price, label: 'Expected Price', class: "form-control" %>

            <%= f.submit "Search", class: "btn btn-primary" %>
        <% end %>

</form>

routes.rb file.
  get 'search_rides', to: "availabilities#index"
  get 'search_rides_result', to: "availabilities#search"

availabilities_controller.rb
  def index
    @availabilities = Availability.unmatched
  end

  def search
    @availabilities = Availability.unmatched.search(search_params[:start_city])
  end

  def search_params
    params.require(:search).permit(:start_city, :start_street_address, :end_city, :end_street_address, :trip_time, :lowest_acceptable_price)
  end

models/availability.rb
class Availability < ApplicationRecord
    has_many :users, :through => :posts
    has_one :request
    scope :unmatched, ->{ where(matched_request_id: -1) }

    def self.search (params)
        puts "start searching"
        results = city_matches(start_city, end_city, params[:start_city], params[:end_city])
        return nil unless results
        results
    end

A: Instead of using 2 different methods for search, try combining both in index method. Your index method will now look as follows:
def index
  if params[:search]
    @availabilities = Availability.unmatched.search(search_params[:start_city])
  else
    @availabilities = Availability.unmatched
  end
end

Change the form url to search_rides_path. This way search results will be rendered in same view upon form submission.


Q: How to create auto email response when the receiver opens the mail? Hi
My boss wants me to create auto email response when the receiver opens the mail. Most of our clients use gmail but they can use any kinds of mail system. How can I create it ?
Thanks

A: It's not going to be the answer your boss wants to hear, but last time I looked into this there's no reliable way of knowing when someone has opened an email you've sent.
Traditionally (to find out email read counts for marketing emails) it's been done by embedding an image in the email and then having the loading of that image from your server trigger some action; you could do this and have the image address point to a script which sends the auto response then returns a single pixel transparent gif (for example), but it's becoming more standard to disable images in emails these days, so that isn't a 100% reliable route.
That said, if the people you send emails to are more likely than not to load non-embedded images, that is one way to achieve it :)

A: Read Receipts are not available in GMail:
http://www.google.com/support/forum/p/gmail/thread?tid=3ad9e2c7914d3f0e&hl=en
There's not much support for this feature in many email clients. It's a privacy issue.


Q: Session_Start firing multiple times I have a base web ui project, I also have other 'plugin' projects which are just other mvc web applications.
I take the dll's and views from them and toss them into my main web ui's bin and views folder so they can just be added or removed at any time which does work.
each 'plugin' contains a GET method that is called from the main web ui to load the menu options from each of the 'plugins'.
After each URL is called, the main web ui fires the `Session_Start'
menu.Append(HelperMethods.GetModuleMenuHTML(controller, SecurityController.CurrentDomain()));

public static string GetModuleMenuHTML(string controllerName, string currentDomain)
    {
        string html = string.Empty;
        try
        {
            //THIS LINE HERE IS CAUSING Session_Start to fire again
            //IN THE MAIN WEB UI
            html = new WebClient().DownloadString(string.Format("{0}/{1}/GetMenu", currentDomain, controllerName));
        }
        catch (Exception ex)
        {

        }
        return html;
    }

What is causing Session_Start to fire when calling html = new WebClient().DownloadString(string.Format("{0}/{1}/GetMenu", currentDomain, controllerName)); and how can I prevent that from happening?
Does this have something to do with me just dropping in the dll and views from another project directly into the main web ui projects as a "plugin" (which does however load correctly into my UI) to be easily added and removed?

A: Its mainly because of this:
html = new WebClient().DownloadString(string.Format("{0}/{1}/GetMenu", currentDomain, controllerName));

This line uses WebClient class to get the html, but the WebClient class is stateless, and each time its called it uses another request with no cookies, so the server thinks it a new request, and starts a new session.

A: The WebClient request is recursively starting a new session. As a hack, you could modify your Session_Start() to check if the incoming url is /{controller}/GetMenu and simply avoid the WebClient call. See: https://stackoverflow.com/a/18656561.
Otherwise, perhaps decorating your MenuController with SessionStateAttribute (https://msdn.microsoft.com/en-us/library/system.web.mvc.sessionstateattribute(v=vs.118).aspx) might avoid the Session_Start altogether (if GetMenu() doesn't use the session state).


Q: Trying to render a full page video background in Next.js but getting blank page I'm trying to have a full page video background in the homepage of my Nextjs application but am just getting blank white space where the content should be.
I'm fairly new to Nextjs and am probably making a silly mistake here, if anyone could point this out I'd really appreciate the help.
My mp4 video is stored within public/assets as so here:

This is my index.js file:
import Head from 'next/head';
import Image from 'next/image';
import React, { useRef, useEffect, useState } from 'react';
import ScrollAnimation from '../components/ScrollAnimation';
import Footer from '../components/Footer';
import Header from '../components/Header';

export default function Home() {

  return (

        <title>Greystone</title>
        <link rel='icon' href='/favicon.ico' />
        <link
          rel='preload'
          href='/fonts/FairplayDisplay/FairplayDisplay-Bold.ttf'
          as='font'
          crossOrigin=''
        />
        <link
          rel='preload'
          href='/fonts/FairplayDisplay/FairplayDisplay-Regular.ttf'
          as='font'
          crossOrigin=''
        />

          {/* Page 1 */}

            <video autoplay loop muted className='w-full h-screen z-10'>
              <source
                src='../public/assets/bubble-video.mp4'
                type='video/mp4'
              />
            </video>

              <ScrollAnimation />

We’re Greystone.

                We think recruitment is broken. Be part of something better.

                Greystone brings the top 10% of talent together in an exclusive
                club, then pairs those dream hires with the right clients. It’s
                role-finding, reimagined.

FIND OUT MORE

  );
}

Many thanks in advance if anyone can help!

A: It seems I didn't need to have 'public' in the src url call for anyone who may experience a similar issue in future. The video tag now looks like so:
<video autoPlay loop muted className='w-full h-screen z-10'>
              <source src='/assets/bubble-video.mp4' type='video/mp4' />
            </video>

A: adding mute attribute to the video tag solved a similar issue for me
<video
  preload="auto"
  playsInline
  autoPlay
  muted
  loop
>
  <source src="/video.mp4" type="video/mp4" />
</video>


Q: Why rewritten dynamic routs don't work with basePath and locales in Next.js? For example I have project structure like this:
.
└── pages
    ├── news
    │   ├── [slug].tsx
    │   └── index.tsx
    └── reviews.tsx

All pages are static generated
My next.config.js has following rules
const BASE_PATH = process.env.APP_HOST === 'be' ? `/${process.env.APP_LANGUAGE}` : undefined;
const paths = {
   news: {
      nl: '/nieuws',
      en: '/news',
      fr: '/actualite',
      de: '/neuigkeiten',
   },
   reviews: {
      nl: '/reviews',
      en: '/reviews',
      fr: '/avis',
      de: '/bewertungen',
   },
};

module.exports = {
   async rewrites() {
      return [
        {
          source: paths.reviews,
          destination: '/reviews',
        },
        {
          source: `${paths.news}/:path*`,
          destination: '/news/:path*',
        },
      ]
    },
    basePath: BASE_PATH,
    i18n:
      process.env.APP_HOST === 'be'
        ? {
            locales: ['default', process.env.APP_LANGUAGE],
            defaultLocale: 'default',
            localeDetection: false,
          }
        : undefined,
    trailingSlash: process.env.APP_HOST === 'be',
    sassOptions: {
      prependData: `$basePath: '${BASE_PATH || ''}';`,
    },
    env: {
      APP_HOST: process.env.APP_HOST,
      APP_LANGUAGE: process.env.APP_LANGUAGE,
    }
}

If process.env.APP_HOST !== "be" static and dynamic routes work perfect
If process.env.APP_HOST === "be" static routes work fine but dynamic route gives 404 page.
For example process.env.APP_HOST = "be" and process.env.APP_LANGUAGE = "de"
In getStaticPaths all paths for articles are correct.
/de/bewertungen/ the page is correct
/de/neuigkeiten/ the page is correct
/de/neuigkeiten/some-article-path/ - 404 error
I've tried to change paths in rewrites, set locale: false for dynamic path, tried make rewrite in next middleware - nothing works for me


Q: sql query to find the value exist in source I have the following query,
select Vendor_ID, Descr, source, Name, Parent_Vendor_ID from VENDOR;

Data:
VendorID       Descr    Source  name     Parent Vendor ID
1234          ONLINE    ABC     JACK     6666
5689          OFFSHORE  XYZ      SAM     5555
9999          SHOP      TTT     EBAY     1234
6666         ECOMMERCE  FRE    AMERICAS

From the above table data 5555 doesn't exist in Vendor ID field. so I need the output as below
VendorID    Descr      Source   name    Parent Vendor ID    EXIST
1234        ONLINE      ABC     JACK    6666                Yes
5689        OFFSHORE    XYZ     SAM    **5555               No**
9999        SHOP        TTT     EBAY    1234                Yes
6666        ECOMMERCE   FRE    AMERICAS

I need to find if the Parent_Vendor_ID exist in Field 1 Vendor_ID. if exist simply need a column with Yes/No. If yes YES else NO
Output should be all fields + Parent_Vendor_ID_Exist
select Vendor_ID, Descr, source, Name, Parent_Vendor_ID,Parent_Vendor_ID Exist

I tried to if else but its not returning all values. Can someone please suggest?

A: select v1.Vendor_ID, v1.Descr, v1.source, v1.Name, v1.Parent_Vendor_ID,
       case when v2.Vendor_ID is null
            then 'NO'
            else 'YES'
       end as Parent_Vendor_ID_Exist
from vendor v1
left join vendor v2 on v1.Parent_Vendor_ID = v2.Vendor_ID

A: SELECT v1.Vendor_ID
     , v1.Descr
     , v1.source
     , v1.Name
     , v1.Parent_Vendor_ID
     , nvl2(v2.vendor_id,'Yes','No') as parent_exist
  FROM VENDOR v1
  LEFT OUTER JOIN vendor v2
      ON (v1.parent_vandor_id = v2.vendor_id);

A: Try this..
SELECT Vendor_ID, Descr, source, Name, Parent_Vendor_ID,
CASE
     WHEN
         EXISTS( SELECT Vendor_ID FROM VENDOR v2 WHERE v1.Parent_Vendor_ID = v2.Vendor_ID)
    THEN
        'Yes'
    ELSE
        'No'
    END as "Parent_Vendor_ID Exist"
 FROM VENDOR v1;

let me know if this works.


Q: Why is this method reference failing at runtime but not the corresponding lambda call? I have these two interfaces. One is public (A), the other one is package private (AA). A extends AA.
package pkg.a;

@FunctionalInterface
public interface A extends AA {

}

.
package pkg.a;

interface AA {

    default void defaultM() {
        System.out.println(m());
    }

    String m();
}

I have this code (in a different package):
package pkg;

import java.util.Arrays;
import java.util.List;

import pkg.a.A;

public class Test {

    public static void main(String[] args) {
        List<A> list = Arrays.asList(() -> "imp1", () -> "imp2");

        list.stream().forEach(a -> a.defaultM());
        list.stream().forEach(A::defaultM);
    }
}

When running the above code the list.stream().forEach(A::defaultM); throws the below exception. Why? Why can't the method reference access the methods defined in the package-private interface while the lambda expression can? I'm running this in Eclipse (Version: 2018-12 (4.10.0)) with Java version 1.8.0_191.
imp1
imp2
Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
    at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
    at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
    at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
    at pkg.Test.main(Test.java:14)
Caused by: java.lang.IllegalArgumentException: java.lang.IllegalAccessException: class is not public: pkg.a.AA.defaultM()void/invokeInterface, from pkg.Test
    at java.lang.invoke.MethodHandles$Lookup.revealDirect(MethodHandles.java:1360)
    at java.lang.invoke.AbstractValidatingLambdaMetafactory.<init>(AbstractValidatingLambdaMetafactory.java:131)
    at java.lang.invoke.InnerClassLambdaMetafactory.<init>(InnerClassLambdaMetafactory.java:155)
    at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:299)
    at java.lang.invoke.CallSite.makeSite(CallSite.java:302)
    ... 3 more
Caused by: java.lang.IllegalAccessException: class is not public: pkg.a.AA.defaultM()void/invokeInterface, from pkg.Test
    at java.lang.invoke.MemberName.makeAccessException(MemberName.java:850)
    at java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:1536)
    at java.lang.invoke.MethodHandles$Lookup.revealDirect(MethodHandles.java:1357)
    ... 7 more

A: This appears to be a bug in certain Java versions.
I can replicate it if I compile and run it with JDK 8, specifically:

tj$ javac -version
javac 1.8.0_74
tj$ java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

...but not with JDK 11 or 12, specifically:

tj$ javac -version
javac 11.0.1
tj$ java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

and

tj$ javac -version
javac 12.0.2
tj$ java -version
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

I can also replicate it if I compile with JDK 8 but run it with JDK 12's runtime, suggesting a compilation problem.

A: This is a bug:
Method reference uses wrong qualifying type.

A reference to a method declared in a package-access class (via a
  public subtype) compiles to a lambda bridge; the qualifying type in
  the bridge method is the declaring class, not the referenced class.
  This leads to an IllegalAccessError.

Fixed in Java 9.


Q: Malfunction of a jQuery slideToggle() implementation I've got a problem with the following setup:
I have a button that is inside a nav element.
<nav id="navbuttons">
    <button type = "button" id="projectsMenu" onclick="slideProjects()">Projects</button>
</nav>

which should slide in/out the following nav element when clicked:
<nav id="projects">
    We're projects
</nav>

To do this, I'm using the following JavaScript/jQuery function:
function slideProjects(){
                $(document).ready(function(){
                        $("#projectsMenu").click(function(){
                                $("#projects").slideToggle("slow");
                        });
                });
        }

This causes eratic behavior of the button and the secondary nav (which has more stuff in it than "We're projects", but they're just examples of the same thing I'm asking about). The button has to be clicked twice in order to get the second nav to show, and even then, it "winks" at you (it slides down, slides up, then slides down again, sometimes multiple times).
From what I understand/have been told, I have this problem because there are too many "onclick" event handlers on in the process, which brings a need for multiple clicks like I mentioned earlier. If I remove onclick from the html element (I was told it was deprecated), it doesn't seem to listen to the button. Is this correct, and what do I do to fix this?

A: It should be just
<nav id="navbuttons">
    <button type="button" id="projectsMenu">Projects</button>
</nav>

then
$(document).ready(function () {
    $("#projectsMenu").click(function () {
        $("#projects").stop(true).slideToggle("slow");
    });
});

Demo: Fiddle
because in your case, the actual slideToggle code is not executed in the first click... in the slideProjects method you are registering a click handler which is sliding the element. Instead you can just use the dom ready handler to add a click handler to the projectsMenu element and there is no need to have a onclick handler.


Q: JQuery Ajax call returns "Error: Not enough storage is available to complete this operation." So I am getting the above error when I am trying to pass the result.target of an OnLoad event in the FileReader.readAsArrayBuffer call using an jQuery Ajax POST call. The POST call is not actually being made (as monitored by Fiddler). This call works for files tested to about 120 mbs. I am trying to upload a 218 mb file though now. Also this seems to be IE specific, as it works in Chrome.
Call:
$.ajax({
 type: 'POST',
 url: url,
 contentType: 'application/json;odata=verbose',
 data: fileData,
 processData: false,
 headers: { ACCEPT: 'application/json;odata=verbose', "X-RequestDigest": formDigest, "If-Match": "*" }
}).done(function (results) {
    //Do Stuff
});

As context, fileData is the result.target created through a file upload via the HTML 5 File API. I am trying to pass a file to upload in SharePoint via the Web API.

A: Servers usually have limits on file sizes that can be uploaded. It sounds like you're running into the servers limit. If you own the server, you can raise the cap, otherwise you could try asking the server's admin.


Q: How to detect fling on TextView without cancelling scroll? Trying to detect a fling on a  TextView using simpleGestureDetector:
public void onCreate(Bundle savedInstanceState) {

    ...

    textContent.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent ev) {
                return gestureDetector.onTouchEvent(ev);
        }
    });
}

class MyGestureDetector extends SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {

            if(foo) {
                fooBar();
                return true;
            }
        return super.onFling(e1, e2, velocityX, velocityY);
    }
}

This works in the sense that my code fooBar() is run if the conditions foo are met, but the problem I find is that when the conditions aren't met, returning super.onFling() causes the fling to be cancelled, it seems, since the textview scroll no longer continues after the finger is lifted on a fling.  Here is the XML:
<RelativeLayout
    android:id="@+id/main_area"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    <TextView
        android:id="@+id/main_text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp"
        android:textSize="16dp"
        android:lineSpacingExtra="2dip"
    />
</RelativeLayout>

Is there any way I can keep the ordinary scroll behaviour and still detect the fling?
EDIT: Sorry, my bad, this had nothing to do with the gesture detector, it was just because I took the TextView out of its ScrollView - for some reason it seems TextViews don't have smooth (inertia) scrolling like ScrollViews.

A: The difference between scroll and fling events is that the user lifts his finger in the end of the movement in order to make it a fling. (and the speed is higher).
Therefore, I think it is not possible to combine both events as they are (too) similar to detect (before ending them) which one is being performed.
Also from a user perspective, using both gestures at the same time is confusing (due to the similarity).
So the answer is: no there is no way to keep the ordinary scroll behaviour and still detect the fling.
(at least I tried in the past and did not succeed in using both events in a proper way)

A: I'm not sure this will be your problem, but why do you return true if your condition is met? If you don't want the event to be consumed, you should return false (or super.onFling). That's what the return value is for.


Q: Underlay same histogram in each panel This is a followup to this, this, and this question.
Currently, I have a twelve-panel lattice in which the same dark histogram outline is superimposed on twelve different solid gray histograms:

This makes it easy to compare the new data in each panel with the same set of other data.  Leaving out some details that are irrelevant to this question, my code looks like this:
histogram(~ foo | bar,
          data=mydata[mydata$bar!="none",],  # get only the 12 categories
          col=mylightgray, border=mylightgray,
          panel=function(...){panel.histogram(...) # add histogram to ea. panel:
                              panel.histogram(x=mydata[mydata$bar=="none",]$foo,
                                  col="transparent", border="black")})

Now I want to reverse the colors, so to speak: I want to superimpose different outline histograms on the same solid gray histogram.
Here's the problem:
If I simply swap the colors, so that the main histogram has col="transparent" and border="black", while the panel function histogram uses mylightgray, the gray histograms will be on top, and will obscure parts of the outline histogram, which defeats the purpose of putting two histograms in one panel.
On the other hand, if I swap the data specification, so that the outer main histogram uses bar=="none" and the panel histogram uses bar!="none", I only get one panel.
The problem is that it's the main histogram call, not the extra panel function, that both writes first and also controls the number of panels.  It appears to be impossible to create multiple panels in which the plot that's on the bottom is the same--unless I just create a dataframe with twelve duplicates of the same data.  I wonder if there's a solution without producing special data.

A: Swap the colors and the order of the panel.histograms calls. That is, plot the gray histogram first.


Q: How to use subprocess Popen? I'm trying to execute a command using Popen.
The command uses some PostGIS/Postgresql utility programs to upload a raster file to a database and works when executed from the command line. It uses unix style pipes to chain 2 commands and looks like this:
"C:\\Program Files\\PostgreSQL\\9.2\\bin\\raster2pgsql.exe" -d -I -C -e -Y -F -t 128x128 "C:\\temp\\SampleDTM\\SampleDTM.tif" test | "C:\\Program Files\\PostgreSQL\\9.2\\bin\\psql.exe" -h localhost -p 5432 -d adr_hazard -U postgres

When using within Python, I make it a string with the ' codes:
command = '"C:\\Program Files\\PostgreSQL\\9.2\\bin\\raster2pgsql.exe" -d -I -C -e -Y -F -t 128x128 "C:\\temp\\SampleDTM\\SampleDTM.tif" test | "C:\\Program Files\\PostgreSQL\\9.2\\bin\\psql.exe" -h localhost -p 5432 -d adr_hazard -U postgres'

attempting to execute it results in an error:
p = subprocess.Popen(command)

ERROR: Unable to read raster file: test

The error seems like the command was not parsed correctly (it is interpreting the wrong argument as the raster file)
Am I using Popen wrong?

A: Your command uses pipe |. It requires a shell:
p = subprocess.Popen(command, shell=True)

The command itself as far as I can tell looks ok.

A: It's not necessary to use shell=True to achieve this with pipes. This can be done programmatically with pipes even where concern about insecure input is an issue. Here, conn_params is a dictionary with PASSWORD, NAME (database name), USER, and HOST keys.
raster2pgsql_ps = subprocess.Popen([
    'raster2pgsql', '-d', '-I', '-C', '-e', '-Y', '-F', '-t', '128x128',
    'C:\\temp\\SampleDTM\\SampleDTM.tif',
    'test'
], stdout=subprocess.PIPE)

# Connection made using conninfo parameters
# http://www.postgresql.org/docs/9.0/static/libpq-connect.html
psql_ps = subprocess.check_output([
    'psql',
    'password={PASSWORD} dbname={NAME} user={USER} host={HOST}'.format(**conn_params),
], stdin=raster2pgsql_ps.stdout)

A: The following worked for me on Windows, while avoiding shell=True
One can make use of Python's fstring formatting to make sure the commands will work in windows.
Please note that I used shp2pgsql but it should be a very similar process for raster2pgsql.
Parameters for the shp2pgsql: srid is the coordinate system of the shape file, filename is the path to the shape file to be imported, tablename is the name you'd like to give your table.
import os
import subprocess

shp2pgsql_binary = os.path.join(pgsql_dir, "bin", "shp2pgsql")
psql_binary = os.path.join(pgsql_dir, "bin", "psql")

command0 = f'\"{shp2pgsql_binary}\" -s {srid} \"{filename}\" {tablename}'
command1 = f'\"{psql_binary}\" \"dbname={databasename} user={username} password={password} host={hostname}\"'

try:
    shp2pgsql_ps = subprocess.Popen(command0, stdout=subprocess.PIPE)
    psql_ps = subprocess.check_output(command1, stdin=shp2pgsql_ps.stdout)
except:
    sys.stderr.write("An error occurred while importing data into the database, you might want to \
                        check the SQL command below:")
    sys.stderr.write(command)
    raise

To adpat to raster2pgsql, you just need to modify the string in command0, e.g. -s {srid} becomes -d -I -C -e -Y -F -t 128x128. The string for command1 can remain the same.

A: It will be better to use subprocess.Popen in this way:
proc = subprocess.Popen(['"C:\\Program Files\\PostgreSQL\\9.2\\bin\\raster2pgsql.exe"', '-d', '-I', '-C', '-e', '-Y', '-F', '-t', '128x128', '"C:\\temp\\SampleDTM\\SampleDTM.tif"', 'test', '|', '"C:\\Program Files\\PostgreSQL\\9.2\\bin\\psql.exe"', '-h', 'localhost', '-p', '5432', '-d', 'adr_hazard', '-U', 'postgres'], shell = True, stdout = subprocess.pipe, stderr = subprocess.STDOUT)
proc.wait()
result = proc.stdout.readlines()#if you want to process the result of your command
proc.kill()

B.T.W, it's good to format the path first, use:
path = os.path.normalpath("C:\\Program Files\\PostgreSQL\\9.2\\bin\\raster2pgsql.exe")

this will avoid some path problems for different OS platform.
The shell = True is important if you want to execute your command just like executing it in local shell.
Hope will help you.

A:   PIPE = subprocess.PIPE
  pd = subprocess.Popen(['"C:\\Program Files\\PostgreSQL\\9.2\\bin\\raster2pgsql.exe", '-d', '-I', '-C', '-e', '-Y', '-F', '-t', '128x128', "C:\\temp\\SampleDTM\\SampleDTM.tif", 'test'],
    stdout=PIPE, stderr=PIPE)
  stdout, stderr = pd.communicate()


Q: how to combine a variable and a special character into a regular expression I need to do something like this:
st = 'abcdef'
wr = 'ab'

if re.search(^wr,st):
    print 'OK'

the problem is I cannot combine special character with a variable (i.e. ^wr). Is there a way to do that?


Q: How to find which key is pressed, not which character it will be? I need to find out which key was pressed, not what character it would be.
For example, I want after pressing 'a' a number such (1) create so I can map it to other languages. In common way we can find it is 'a' or we can have it's hash code, but is it possible to have char or hash code in a language and find out what char or hash code it would be in another language?
Attention some language have not the standard keyboard so pressing a key not mean a certain character.

A: There's no reason to do this in any language i've seen.
(besides the fact that you didn't specify in which language you are trying to achieve this)
All languages allow you to get the character code from a keypress.
If you know which encoding was used (UTF 8, Ascii, you name it), it's trivial to map the code to the actual character.
Assigning a different keyboard layout on OS level means that it no longer matters which keyboard layout you are using.
if you have a QWERTY keyboard, switch it to AZERTY and press the button where the q would be, you get an a, despite the letters on the keyboard still saying QWERTY.
If you are using a chinese keyboard, the characters no longer map to any western set, so the character codes will not match up with UTF8 or ASCII, but CP963 (or another chinese codepage, depending on several factors), which is so different there is no real way to translate it to UTF8 or ASCII.


Q: Remove an item from a UICollectionView I have a set of images showing in a UICollectionView. When the user taps on an image, it spawns a UIActionSheet with a few options for that image. One of them id removing the photo from the UICollectionView. When the user selects remove button in the UIActionSheet, it pops up an alert view asking for confirmation. If the user selects yes, it should remove the photo.
My problem is, to remove the item from the UICollectionView, you have to pass the indexPath to the deleteItemsAtIndexPaths event. Since the final confirmation is granted in the alert view's didDismissWithButtonIndex event, I can't figure out a way to get the indexPath of the selected image from there to pass it to deleteItemsAtIndexPaths event. How can I do this?
Here's my code:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (buttonIndex) {
        case 0:
            deletePhotoConfirmAlert = [[UIAlertView alloc] initWithTitle:@"Remove Photo"
                                                                 message:@"Do you want to remove this photo?"
                                                                delegate:self
                                                       cancelButtonTitle:@"Cancel"
                                                       otherButtonTitles:nil, nil];
            [deletePhotoConfirmAlert addButtonWithTitle:@"Yes"];
            [deletePhotoConfirmAlert show];

            break;
        case 1:
            NSLog(@"To Edit photo");
            break;
    }
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (alertView == deletePhotoConfirmAlert) {
        if (buttonIndex == 1) {
            // Permission to delete the button is granted here.
            // From here deleteItemsAtIndexPaths event should be called with the indexPath
        }
    }
}

- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths
{

}

A: Why not make use of [self.collectionView indexPathsForSelectedItems]; . I have done this for deleting multiple images at a time.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
  if (alertView == deletePhotoConfirmAlert) {
    if (buttonIndex == 1) {
        // Permission to delete the button is granted here.
        NSArray *selectedItemsIndexPaths = [self.collectionView indexPathsForSelectedItems];

       // Delete the items from the data source.
        [self deleteItemsFromDataSourceAtIndexPaths:selectedItemsIndexPaths];

        // Now delete the items from the collection view.
        [self.collectionView deleteItemsAtIndexPaths:selectedItemsIndexPaths];
    }
  }
}

// This method is for deleting the selected images from the data source array
-(void)deleteItemsFromDataSourceAtIndexPaths:(NSArray  *)itemPaths {
   NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
   for (NSIndexPath *itemPath  in itemPaths) {
     [indexSet addIndex:itemPath.row];
   }
   [self.images removeObjectsAtIndexes:indexSet]; // self.images is my data source
}

Edit
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
   NSArray *indexpaths = [self.collectionView indexPathsForSelectedItems];
   DetailViewController *dest = [segue destinationViewController];
   dest.imageName = [self.images objectAtIndex:[[indexpaths objectAtIndex:0] row]];
}


Q: Horizontal lookup using unstructured lookup keys I need to find the rate for a given location and weight, using a lookup table that lists rates per location and weight. The problem is that the weights in the table are formatted like Up to 2 kg, 2.01-3 kg, 3.01-5 kg and so on, while the weights I am looking for are plain numbers like 10.5 and 13.5. How can I map the location-weight tuples to the rates in the lookup table?
Spreadsheet here

A: I am assuming that you want to obtain something like this:

where you input a location in the A9 cell and a Weight in the B9 cell and it automatically puts the correct rate in the C9 cell. This can be achieved with the following formula (in the C9 cell):
=ARRAYFORMULA(VLOOKUP(A9,A1:G5,HLOOKUP(B9,{A1:G1;COLUMN(A1:G1)},2,0),0))

which mixes VLOOKUP (you can read more about it here) to fetch the correct Location Code with HLOOKUP (you can read more about it here) to fetch the correct Weight.

A: This can be done very simply by just nesting one FILTER inside another; as per the answer given by Oriel Castander you could use this formula in cell C9 instead:
=filter(filter(B2:G5,A2:A5=A9),B1:G1=B9)


Q: What is the link between proj4js and proj Question
I am simply wondering, what is the relationship between the web oriented proj4js and the PROJ C++ well known library (on which for example GDAL/OGR relies)?
Is there any link between these two libraries?
It's written on the proj4js web page that it is:

Originally a port of PROJ.4 and GCTCP C it is a part of the MetaCRS group of projects.

But what is the current situation?
How could I check what version of PROJ does proj4js rely on?
Sources repositories of each of these projets:
https://github.com/proj4js/proj4js
https://github.com/OSGeo/PROJ

A: The first one "proj4js" is an adaptation from the second but not a port (same API in a different programming language)
The second PROJ (C++) is used directly or by program like PostGIS or GDAL to manage projections
Both take as an input mostly the same definitions for projection. You can confirm it with "Export" section from website epsg.io (an example https://epsg.io/2154)
If you want a literal JavaScript port of PROJ for JavaScript, you should look at https://github.com/mbloch/mapshaper-proj instead. It can be useful to get latest projections like "eqearth" or other not supported in proj4js (see https://proj.org/operations/projections/index.html for a list).


Q: Cordova iOs Google Maps map Blank on Appstore i have created an iPhone App with cordova and the google maps Plugin for Cordova (https://github.com/wf9a5m75/phonegap-googlemaps-plugin). I entered the API Key for Ios and on the Emulator it works great. Also when i test it on my iPhone it works. So i submitted the app to the AppStore and after it gets reviewed i downloaded it from the Appstore but the Map is blank. There are no Control Elements like when the API Key is wrong. Now my question is what i should do now?
I tried:
<access origin="*" />

*

*Changing Bundle Identifier

*Check API Key

*Take the IPA and installed it manually on a iPhone/iPad (the Map works)

So i think the Probleme must came from Apple or do i see that wrong?
Thanks in advance

A: The phonegap-googlemaps-plugin is not subjected by <access origin="*" />, because the Google Maps SDK for iOS connects to the internet directly.
Typically the bundle identifier and the API key are mismatch.
Google Maps iOS SDK Integration not loading maps
Is there any error message in Xcode?


Q: Upper bound for the error of the gaussian quadrature$\int_{0}^{1} \log (1+\operatorname{sin} x) \mathrm{d} x$ I'm given the integral $\mathrm{I}=\int_{0}^{1} \log (1+\operatorname{sin} x) \mathrm{d} x$. Through the formula of Gaussian quadrature for 3 points, I can find an approximation to this integral. The question I'm asked is to show that
$$
2 \sup _{x \in[0,1]}|\log (1+\operatorname{sin} x)-P(x)|
$$
is an upper bound for the error of the Gaussian quadrature, knowing that $P(x)$ is the polynomial with degree $\leq 5$ that approximates $\log (1+\operatorname{sin} x)$ through least squares.
I don't even know where to start... Should I try to compute $P(x)$ and find the supremum? How would I show that it is an upper bound for the error?


Q: Python: Compare files with similar names (recursively) With the help of these guys, I was able to produce the following code, which reads in two files, (i.e., SA1.WRD and SA1.PHN), merges them, and compares the results against a sub-list of words excised from a dictionary:

    import sys
    import os
    import re
    import itertools
#generator function to merge sound and word files
def takeuntil(iterable, stop):
    for x in iterable:
        yield x
        if x[1] == stop:
            break

#open a dictionary file and create subset of words
class_defintion = re.compile('([1-2] [lnr] t en|[1-2] t en)')
with open('TIMITDIC.TXT') as w_list:
    entries = (line.split(' ', 1) for line in w_list)
    comp_set = [ x[0] for x in entries if class_defintion.search(x[1]) ]

#open word and sound files
total_words = 0
with open(sys.argv[1]) as unsplit_words, open(sys.argv[2]) as unsplit_sounds:
    sounds = (line.split() for line in unsplit_sounds)
    words = (line.split() for line in unsplit_words)
    output = [
    (word, " ".join(sound for _, _, sound in
        takeuntil(sounds, stop)))
    for start, stop, word in words
]
for x in output:
    total_words += 1

#extract words from above into list of words in dictionary set
glottal_environments = [ x for x in output if x[0] in comp_set ]

I'm trying to modify the part after  #open a dictionary files to run on a large directory with several subdirectories.  Each subdirectory contains .txt files, .wav files, .wrd, and .phn files.  I want to only open .wrd and .phn files, and I'd like to be able to open them two at a time, and only if the base file name matches, i.e, SA1.WRD and SA1.PHN, not SA1.WRD and SI997.PHN.
My immediate guess was to do something like this:
for root, dir, files in os.walk(sys.argv[1]):
    words = [f for f in files if f.endswith('.WRD')]
    phones = [f for f in files if f.endswith('.PHN')]
    phones.sort()
    words.sort()
    files = zip(words, phones)

Which returns: [('SA1.WRD', 'SA1.PHN'), ('SA2.WRD', 'SA2.PHN'), ('SI997.WRD', 'SI997.PHN')]
My first question is whether I am on the right track, and if so, my second question is how I can go about treating each of these items in these tuples as filenames to read.
Thanks for any help you offer.
EDIT:
I figured I can put the block of code into a for loop:
for f in files:
        #OPEN THE WORD AND PHONE FILES, COMAPRE THEM (TAKE A WORD COUNT)
        total_words = 0
        with open(f[0]) as unsplit_words, open(f[1]) as unsplit_sounds:

        ...

However, this causes an IOError, presumably due to the single-quotes around each item in each tuple.
Update
I modified my original script to include os.path.join(root, f) as noted below.  The script now walks through all files in the directory tree, but it only processes the last two it finds.  Here is the output of print files:
[]
[('test/test1/SI997.WRD', 'test/test1/SI997.PHN')]
[('test/test2/SI997.WRD', 'test/test2/SI997.PHN')]

A: I have tested different parts in relation to the filesystem but it's easier for you to confirm on the actual files to confirm it works on your data.
EDIT to allow for inclusion of pathnames
import sys
import os
import os.path
import re
import itertools

#generator function to merge sound and word files
def takeuntil(iterable, stop):
    for x in iterable:
        yield x
        if x[1] == stop:
            break

def process_words_and_sounds(word_file, sound_file):
    #open word and sound files
    total_words = 0
    with open(word_file) as unsplit_words, open(sound_file) as unsplit_sounds:
        sounds = (line.split() for line in unsplit_sounds)
        words = (line.split() for line in unsplit_words)
        output = [
            (word, " ".join(sound for _, _, sound in
                            takeuntil(sounds, stop)))
            for start, stop, word in words
            ]
        for x in output:
            total_words += 1
    return total_words, output

for root, dir, files in os.walk(sys.argv[1]):
    words = [ os.path.join( root, f ) for f in files if f.endswith('.WRD')]
    phones = [ os.path.join( root, f ) for f in files if f.endswith('.PHN')]
    phones.sort()
    words.sort()
    files = zip(words, phones)
    # print files

output = []
total_words = 0
for word_sounds in files:
    word_file, sound_file = word_sounds
    word_count, output_subset = process_words_and_sounds(word_file, sound_file)
    total_words += word_count
    output.extend( output_subset )

#open a dictionary file and create subset of words
class_defintion = re.compile('([1-2] [lnr] t en|[1-2] t en)')
with open('TIMITDIC.TXT') as w_list:
    entries = (line.split(' ', 1) for line in w_list)
    comp_set = [ x[0] for x in entries if class_defintion.search(x[1]) ]

#extract words from above into list of words in dictionary set
glottal_environments = [ x for x in output if x[0] in comp_set ]


Q: Error with gem install sqlite3 on MacOS Monterey with Ruby 3.0.2 on Apple Silicon M1 I’m getting errors when I try to gem install sqlite3 under a fresh rbenv installation of Ruby 3.0.2. The sqlite3 gem installs successfully under Ruby 2.7.4. What is the fix for this?
I’m using MacOS Monterey on an Apple Silicon M1 machine.
➜  ~ > rbenv shell 3.0.2
➜  ~ > gem install sqlite3
Fetching sqlite3-1.4.2.gem
Building native extensions. This could take a while…
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /Users/brian/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/ext/sqlite3
/Users/brian/.rbenv/versions/3.0.2/bin/ruby -I /Users/brian/.rbenv/versions/3.0.2/lib/ruby/3.0.0 -r ./siteconf20211119-57074-7hi3f4.rb extconf.rb
checking for sqlite3.h… yes
checking for pthread_create() in -lpthread… yes
checking for -ldl… yes
checking for sqlite3_libversion_number() in -lsqlite3… yes
checking for rb_proc_arity()… yes
checking for rb_integer_pack()… yes
checking for sqlite3_initialize()… yes
checking for sqlite3_backup_init()… yes
checking for sqlite3_column_database_name()… yes
checking for sqlite3_enable_load_extension()… yes
checking for sqlite3_load_extension()… yes
checking for sqlite3_open_v2()… yes
checking for sqlite3_prepare_v2()… yes
checking for sqlite3_int64 in sqlite3.h… yes
checking for sqlite3_uint64 in sqlite3.h… yes
creating Makefile

current directory: /Users/brian/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/ext/sqlite3
make DESTDIR\= clean

current directory: /Users/brian/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/ext/sqlite3
make DESTDIR\=
compiling aggregator.c
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/defines.h:73:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/backward/2/attributes.h:43:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/pure.h:25:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/assert.h:132:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
RBIMPL_ATTR_NORETURN()
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/noreturn.h:29:33: note: expanded from macro 'RBIMPL_ATTR_NORETURN'
# define RBIMPL_ATTR_NORETURN() __declspec(noreturn)
                                ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:24:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/anyargs.h:77:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/intern/vm.h:64:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
RBIMPL_ATTR_NORETURN()
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/noreturn.h:29:33: note: expanded from macro 'RBIMPL_ATTR_NORETURN'
# define RBIMPL_ATTR_NORETURN() __declspec(noreturn)
                                ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/int.h:26:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/long.h:70:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
RBIMPL_ATTR_NORETURN()
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/noreturn.h:29:33: note: expanded from macro 'RBIMPL_ATTR_NORETURN'
# define RBIMPL_ATTR_NORETURN() __declspec(noreturn)
                                ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:28:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:46:14: error: expected parameter declarator
RUBY_ALIGNAS(SIZEOF_VALUE)
             ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/value.h:41:23: note: expanded from macro 'SIZEOF_VALUE'
# define SIZEOF_VALUE SIZEOF_LONG
                      ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/arm64-darwin21/ruby/config.h:61:21: note: expanded from macro 'SIZEOF_LONG'
#define SIZEOF_LONG 8
                    ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:28:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:46:14: error: expected ')'
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/value.h:41:23: note: expanded from macro 'SIZEOF_VALUE'
# define SIZEOF_VALUE SIZEOF_LONG
                      ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/arm64-darwin21/ruby/config.h:61:21: note: expanded from macro 'SIZEOF_LONG'
#define SIZEOF_LONG 8
                    ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:46:1: note: to match this '('
RUBY_ALIGNAS(SIZEOF_VALUE)
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/backward/2/stdalign.h:27:22: note: expanded from macro 'RUBY_ALIGNAS'
#define RUBY_ALIGNAS RBIMPL_ALIGNAS
                     ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/stdalign.h:66:44: note: expanded from macro 'RBIMPL_ALIGNAS'
# define RBIMPL_ALIGNAS(_) __declspec(align(_))
                                           ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:28:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:47:1: error: expected function body after function declarator
RBasic {
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:82:23: error: incomplete definition of type 'struct RBasic'
    return RBASIC(obj)->klass;
           ~~~~~~~~~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:82:12: note: forward declaration of 'struct RBasic'
    return RBASIC(obj)->klass;
           ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:50: note: expanded from macro 'RBASIC'
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                                                 ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:30:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:35:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/value_type.h:157:28: error: incomplete definition of type 'struct RBasic'
    VALUE ret = RBASIC(obj)->flags & RUBY_T_MASK;
                ~~~~~~~~~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/value_type.h:157:17: note: forward declaration of 'struct RBasic'
    VALUE ret = RBASIC(obj)->flags & RUBY_T_MASK;
                ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:50: note: expanded from macro 'RBASIC'
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                                                 ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:30:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:237:23: error: incomplete definition of type 'struct RBasic'
    return RBASIC(obj)->flags & flags;
           ~~~~~~~~~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:237:12: note: forward declaration of 'struct RBasic'
    return RBASIC(obj)->flags & flags;
           ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:50: note: expanded from macro ‘RBASIC’
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                                                 ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:30:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:285:1: error: ‘__declspec’ attributes are not enabled; use ‘-fdeclspec’ or ‘-fms-extensions’ to enable support for __declspec attributes
RBIMPL_ATTR_NOALIAS()
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/noalias.h:53:32: note: expanded from macro ‘RBIMPL_ATTR_NOALIAS’
# define RBIMPL_ATTR_NOALIAS() __declspec(noalias)
                               ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:30:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:288:30: warning: declaration of ‘struct RBasic’ will not be visible outside of this function [-Wvisibility]
rbimpl_fl_set_raw_raw(struct RBasic *obj, VALUE flags)
                             ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:290:8: error: incomplete definition of type 'struct RBasic'
    obj->flags |= flags;
    ~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:288:30: note: forward declaration of ‘struct RBasic’
rbimpl_fl_set_raw_raw(struct RBasic *obj, VALUE flags)
                             ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:298:27: warning: incompatible pointer types passing ‘struct RBasic *’ to parameter of type ‘struct RBasic *’ [-Wincompatible-pointer-types]
    rbimpl_fl_set_raw_raw(RBASIC(obj), flags);
                          ^~~~~~~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:30: note: expanded from macro ‘RBASIC’
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/cast.h:33:28: note: expanded from macro ‘RBIMPL_CAST’
# define RBIMPL_CAST(expr) (expr)
                           ^~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:288:38: note: passing argument to parameter ‘obj’ here
rbimpl_fl_set_raw_raw(struct RBasic *obj, VALUE flags)
                                     ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:310:1: error: ‘__declspec’ attributes are not enabled; use ‘-fdeclspec’ or ‘-fms-extensions’ to enable support for __declspec attributes
RBIMPL_ATTR_NOALIAS()
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/noalias.h:53:32: note: expanded from macro ‘RBIMPL_ATTR_NOALIAS’
# define RBIMPL_ATTR_NOALIAS() __declspec(noalias)
                               ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:30:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:313:32: warning: declaration of ‘struct RBasic’ will not be visible outside of this function [-Wvisibility]
rbimpl_fl_unset_raw_raw(struct RBasic *obj, VALUE flags)
                               ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:315:8: error: incomplete definition of type 'struct RBasic'
    obj->flags &= ~flags;
    ~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:313:32: note: forward declaration of ‘struct RBasic’
rbimpl_fl_unset_raw_raw(struct RBasic *obj, VALUE flags)
                               ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:323:29: warning: incompatible pointer types passing ‘struct RBasic *’ to parameter of type ‘struct RBasic *’ [-Wincompatible-pointer-types]
    rbimpl_fl_unset_raw_raw(RBASIC(obj), flags);
                            ^~~~~~~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:30: note: expanded from macro ‘RBASIC’
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/cast.h:33:28: note: expanded from macro ‘RBIMPL_CAST’
# define RBIMPL_CAST(expr) (expr)
                           ^~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:313:40: note: passing argument to parameter ‘obj’ here
rbimpl_fl_unset_raw_raw(struct RBasic *obj, VALUE flags)
                                       ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:335:1: error: ‘__declspec’ attributes are not enabled; use ‘-fdeclspec’ or ‘-fms-extensions’ to enable support for __declspec attributes
RBIMPL_ATTR_NOALIAS()
^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/attr/noalias.h:53:32: note: expanded from macro ‘RBIMPL_ATTR_NOALIAS’
# define RBIMPL_ATTR_NOALIAS() __declspec(noalias)
                               ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:30:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:338:34: warning: declaration of ‘struct RBasic’ will not be visible outside of this function [-Wvisibility]
rbimpl_fl_reverse_raw_raw(struct RBasic *obj, VALUE flags)
                                 ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:340:8: error: incomplete definition of type 'struct RBasic'
    obj->flags ^= flags;
    ~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:338:34: note: forward declaration of ‘struct RBasic’
rbimpl_fl_reverse_raw_raw(struct RBasic *obj, VALUE flags)
                                 ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:348:31: warning: incompatible pointer types passing ‘struct RBasic *’ to parameter of type ‘struct RBasic *’ [-Wincompatible-pointer-types]
    rbimpl_fl_reverse_raw_raw(RBASIC(obj), flags);
                              ^~~~~~~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:30: note: expanded from macro 'RBASIC'
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/cast.h:33:28: note: expanded from macro 'RBIMPL_CAST'
# define RBIMPL_CAST(expr) (expr)
                           ^~~~~~
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:338:42: note: passing argument to parameter 'obj' here
rbimpl_fl_reverse_raw_raw(struct RBasic *obj, VALUE flags)
                                         ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:465:43: error: incomplete definition of type 'struct RBasic'
        if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & RUBY_FL_SINGLETON)) {
                                 ~~~~~~~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/fl_type.h:465:34: note: forward declaration of 'struct RBasic'
        if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & RUBY_FL_SINGLETON)) {
                                 ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rbasic.h:34:50: note: expanded from macro 'RBASIC'
#define RBASIC(obj)          RBIMPL_CAST((struct RBasic *)(obj))
                                                 ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:25:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic.h:23:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/arithmetic/char.h:29:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:74:19: error: field has incomplete type 'struct RBasic'
    struct RBasic basic;
                  ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:74:12: note: forward declaration of 'struct RBasic'
    struct RBasic basic;
           ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:109:26: error: incomplete definition of type 'struct RBasic'
    VALUE f = RBASIC(str)->flags;
              ~~~~~~~~~~~^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:74:12: note: forward declaration of ‘struct RBasic’
    struct RBasic basic;
           ^
In file included from aggregator.c:1:
In file included from ./aggregator.h:4:
In file included from ./sqlite3_ruby.h:4:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby.h:38:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/ruby.h:26:
In file included from /Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core.h:23:
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rarray.h:88:19: error: field has incomplete type ‘struct RBasic’
    struct RBasic basic;
                  ^
/Users/brian/.rbenv/versions/3.0.2/include/ruby-3.0.0/ruby/internal/core/rstring.h:74:12: note: forward declaration of ‘struct RBasic’
    struct RBasic basic;
           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
6 warnings and 20 errors generated.
make: *** [aggregator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/brian/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2 for inspection.
Results logged to /Users/brian/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/extensions/arm64-darwin-21/3.0.0/sqlite3-1.4.2/gem_make.out

➜  ~ >

A: I figured out the answer. It works if I prepend the gem install command with CC='clang -fdeclspec'.
Like this:
CC='clang -fdeclspec' gem install sqlite3


Q: D3.js Brush controls with Ordinal Crossfilter Scales I'm aiming to subset my choropleth like this wonderful example. I've reviewed the API documentation and Mike's Ordinal Brushing example.
Unfortunately,  I'm still not getting my thick head around how brushes are supposed to work.
The examples are sophisticated and somewhat inaccessible for newcomers (lots of turnery operators and arrays of chart objects etc).
I've chosen not to use dc.js due to lack of support for things I'll have to deal with later. Nice work though and props to Nick Qi Zhu.
Can someone pls review my (native d3) approach and show me what I'm doing wrong?
I've setup my bar chart which renders fine. Basically a count of values in a normal distribution.
// Setup Crossfilter dimensions and groups
var nation      = crossfilter(MSPB),
    byScr       = nation.dimension(function(d){ return d.score; }),
    byScrGrp    = byScr.group().reduceCount(),
    byHosp      = nation.dimension(function(d){ return d.FIPS; });

// Histogram X-Axis ordinal scale
var x = d3.scale.ordinal()
        .domain(d3.range(0,2,0.1))
        .rangeBands([0, width, 0.5, 0.5 ]);

// Histogram Y-Axis linear scale
var y = d3.scale.linear()
        .domain([0, d3.max(byScrGrp.all(), function(d){ return d.value; })])
        .range([height/2, 0]);

// Histogram SVG containiner
var svg = d3.select("#histogram").append("svg:svg")
        .attr("width", width + margin.left + margin.right)
        .attr("height", height/2 + margin.top + margin.bottom)
        .append("g")
        .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

    // Histogram bars
    svg.selectAll("rect")
        .data(byScrGrp.all())
        .enter().append("rect")
        .attr("x", function(d,i){ return i * (width / byScrGrp.size() ); })
        .attr("width", width / byScrGrp.size() - barPadding )
        .attr("y", function(d){ return  y(d.value) ; })
        .attr("height", function(d){ return ((height/2) -y(d.value)); })
        .attr("fill", function(d){ return color(d.key); })
        .on("mouseover", function(d){ d3.select(this).attr("fill", "teal"); })
        .on("mouseout", function(d) { d3.select(this).attr("fill", function(d){return color(d.key);}) } );

Immediately after, I try to add my brush controls like this. Initially I just want to get the drag selection working on the bar chart. I'll worry about getting xAxis extent values for filtering the choropleth later.
 var brush = d3.svg.brush()
            .x(x)
            .on("brushstart", brushstart)
            .on("brush", brushmove)
            .on("brushend", brushend)

var brushg = svg.append("g")
            .attr("class", "brush")
            .call(brush)

    brushg.selectAll("rect")
                .attr("height", height/2)
                .attr("width", width);

function brushstart() {
  svg.classed("selecting", true);
}

function brushmove() {
  var s = brush.extent();
  brushg.classed("selected", function(d) { return s[0] <= (d = x(d)) && d <= s[1]; });
}

function brushend() {
  svg.classed("selecting", !d3.event.target.empty());
}

I'm seeing the crosshair drag handles but not seeing what I'd expect and certainly not getting the desired effect.
It's slow on this webserver but the full js file is here and partially working example here.
EDIT: I've tried to create a JSFiddle here.
Any pointers would be much appreciated.
Thanks

A: Hard to say without experimenting (any chance of creating a JSfiddle or similar?). I suspect the issue is that you are setting the width of all the rects in the brush. You only need to set the height, I believe. This is probably what is causing your extents to go all crazy.
Once you get that straightened out, you'll need to filter your Crossfilter dimension based on the brush extent.
Also, Crossfilter's group.reduceCount function doesn't take an argument, and if it is possible you are missing data you need to make sure to test/cast your data in your dimension accessors to make sure they always return naturally ordered numbers or strings.


Q: HazelCast - How to insert records through a Map to a table with auto sequence field as PK I am using HazelCast to do read/write operations on MS SQL server database.
I have a database table whose primary key is an auto increment column.
I read existing data in this table to a Map when my application starts.
The Map has an underlying MapStore implementation.
The key of the map is the auto increment column value. The value of the map is an object containing few fields from the table.
User can insert records to this table through the HazelCast layer.
This insert is performed in a Transaction (TransactionalMap is obtained from HazelCast).
It is at this place i face a problem as i do not have the primary key value (auto increment value) to set to the TransactionalMap instance.
I have the insert to database table logic in the MapStore's store() method and the store() method is called only after commit is called on the Transaction.
I am not getting how to first set the key value (auto increment value) to the map. Auto increment value can be obtained post the insert to the table.
Ideas/Points are most welcome.
Thanks,
s.r.guruprasad

A: You can implement PostProcessingMapStore interface on your MapStore which enables the ability to update the stored entry inside the store() method. You can obtain the auto-generated fields from the database then you can reflect those changes to your entry.
See Post Processing documentation : http://docs.hazelcast.org/docs/latest-dev/manual/html-single/index.html#post-processing-objects-in-map-store

A: The only way I can see to do what you ask is to have your code write a demo record into the database and then read it back before into Hz and making MapStore do an update rather than insert.
Of course this would be slow and cumbersome.
The best solution would be to turn off the autoincrement, but what you could also do is use a different field as the cache key, say have a member called cacheKey and store that in your database record, when you do an insert in MapStore you just need insert where databaserecord.cachekey == cacheKey.


Q: Please explain '%' usage in python I'm learning multithreading in python and I was reading through this answer. I understand most of the code however there is this one line which I simply don't understand and I don't know how to search for it on Google as the '%' sign keeps returning modulo.
req.headers['Range'] = 'bytes=%s-%s' % (start, start+chunk_size)

I thought that req.headers['Range'] would retrieve some 'range' element from an array however here they are assigning it a value of 'bytes=%s-%s' % (start, start+chunk_size). I really just don't understand what is going on in this line. Things like 'bytes=%s-%s' I am assuming is some sort of python syntax which I am unaware of. If you could explain each term in this line that would be very much appreciated.

A: In python there are multiple ways to format strings. using %s inside a string and then a % after the string followed by a tuple (or a single value), allows you to create a new string:
x = 5
y = 8
'my favourite number is %s, but I hate the number %s' % (x, y)

results in:
'my favourite number is 5, but I hate the number 8'

I think they call it C-type string formatting. For more information, you can check out this page.
In my opinion, it is easier to format string using f'strings, or .format(). Check out this page too