Im trying to get links from a TXT file, but it ends with 0 results

Question: So I have a txt file that contains several links along with other text, More specifically a list of twitter like data, (tweets that I have liked), And im trying to compile the image links specifically (t.co links) into a single txt file. So I made this script.
<code>
FileObject = open(r"like.txt","r")
word = str(FileObject)
link=[]
result = re.search('https://t.co', word)
while True:
        try:
            result_string = result.group(0)
            link.append(result_string)
            word= word.replace(result_string, "")
            result = re.search('https://t.co', word)
            FileObject2 = open(r"list.txt","r+")
            if link(None):
                print("No Image URLS Found")
            else:
                FileObject2.write(link + "\n")
                FileObject2.close("list.txt")
                result = re.search('https://t.co', word)
        except: break
</code>
However upon running this, Nothing is added to list.txt. Please help.
Heres a couple of lines from the text file.
<code>  "like" :
      "tweetId" : "1594749508147191808"
      "fullText" : "@tragicbirdapp https://t(dot)co/LTEe5qrv0B"
      "expandedUrl" : "https://twitter.com/i/web/status/1594749508147191808"

    "like" :
      "tweetId" : "1594880996431781890"
      "fullText" : "New Drawing https://t(dot)co/kLziQSpbrT"
      "expandedUrl" : "https://twitter.com/i/web/status/1594880996431781890"
     ```
</code>
Comment: Did you try `print(word)`? It's not the contents of the file. Use `fileObject.read()`
Comment: `re.search()` will only return the first match. Use `re.findall()` to get all the matches.
Comment: Your use of `re.search()` won't return the whole URL, it will just return the part that matches the regexp. You need a pattern that matches the rest of the URL.
Comment: `word = str(FileObject)` Calling str() on a file object does _not_ give you the contents of the file...
Comment: Your "like.txt" file object is still open when you open a second one.  Don't do that.
Comment: @Barmar unfortunately there IS no pattern for these links, other than all of them end in and start with "
Comment: We can't read your mind, and your code is mostly nonsense.  Please show us what your file looks like, and what you are expecting the output to be.
Comment: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
Comment: @TimRoberts I added an example of the TXT file im pulling from. I explained the output already.
Comment: That's not a text file, that's a JSON.  Don't parse this with regular expressions.  Use `data = json.load(open("list.txt"))`, then go through the list items with a `for` loop and fetch `row["fullText"]`.
Answer: try this for the file reading:
https://www.tutorialkart.com/python/python-read-file-as-string/
<code>#open text file in read mode
text_file = open("D:/data.txt", "r")

#read whole file to a string
word = text_file.read()
</code>
Comment: You will also need to find a pattern that matches the links, but without an example of the text file it is difficult to know what that pattern may be.


play sound in someone else's session from command line

Question: I have tested playing sound via ssh console and it works with this: https://superuser.com/questions/276596/play-mp3-or-wav-file-via-linux-command-line
I am wondering how to do the same in someone else's session.
Ex.: my son is logged in computer full awake while he sleeps and I would like to play him a army wake up call trumpet so he turns the laptop off. I'm the one paying the electrical bill.
Anyone has an idea. I am stumped!
Answer: make sure the target computer is on, or you are able wake it from the LAN, log in via SSH, and run the command. You might have to scp those executables necessary to invoke the command.
Or, show him how laptops have sleep settings.
Comment: LOL. Thanks. He's got an anvil for a brain. He knows all that already. It so happens that the above link did work... Just had to unmute the laptop first. He must have been looking at undressed ladies and didn't want to wake the house... Unmute... 100% volume... Playlist go! then shutdown. That's the lesson from tonight on. It's scripted and cron'd. If the laptop's off... no problem. If CPU is unused for a while... it runs every minute until it's turned off or the CPU gets used again!
Answer: Log in to his computer by ssh. In his computer, do the following commands.
<code>sudo apt-get update
sudo apt-get install festival
echo "Wake up, anvil brain. Turn off the computer. Now!" | festival --tts
</code>
Have fun!


How to make the view the same for all platforms

Question: When I try to make a listview with a custom layout it looks completely different on UWP than Android. How can I make them look the same on all platforms without making a Page per platform?
I try to let my app looks like the wireframe.
I try to visualize an object as a viewcell with a background image and two labels.
I'm currently developing an app for Android and UWP using Xamarin with .NET standard as code sharing strategy.
The idea of this project is to make every view/business logic in the shared project, (the upper project file) since the app won't use any platform specific features.
Here is my XAML code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="inleiding.Views.SubList"
             Title="Your pokélist"
              NavigationPage.BackButtonTitle="go back"
             NavigationPage.HasBackButton="True"
             NavigationPage.HasNavigationBar="True"
             >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <ListView x:Name="lvwPok" ItemSelected="lvwPok_ItemSelected">

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>

                            <RelativeLayout>
                                <Image  VerticalOptions="FillAndExpand"
                                 HorizontalOptions="FillAndExpand"
                                 Source = "{Binding Pic}"></Image>

                                <Grid
                                     VerticalOptions="CenterAndExpand"
                                    HorizontalOptions="CenterAndExpand"
                                    BackgroundColor="Transparent"
                                    >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="20"/>
                                    </Grid.ColumnDefinitions>
                                    <Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" WidthRequest="100" HeightRequest="100" Source = "{Binding ImgPok}">
                                    </Image>

                                </Grid>

                            </RelativeLayout>

                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>

        </ListView>
    </Grid>
</ContentPage>

(Pastebin link)

I'm out of ideas.
Answer: You will need to add OnPlatform support in your Xaml

Within the tags, include an OnPlatform tag.
OnPlatform is a generic class. You need to specify the generic type
  argument, in the below exmaple Thickness, which is the type of Padding
  property. Fortunately, there's a XAML attribute specifically to define
  generic arguments called x:TypeArguments. This should match the type
  of the property you're setting:

Exmaple
<StackLayout.Padding>
  <OnPlatform x:TypeArguments="Thickness">
    <On Platform="Android" Value="0, 0, 0, 0"/>
    <On Platform="WinPhone" Value="0, 0, 0, 0"/>
    <On Platform="iOS" Value="0, 20, 0, 0"/>
  </OnPlatform>
</StackLayout.Padding>

Additional Resources
Part 2. Essential XAML Syntax - Xamarin
Answer: Your problem is not in the xaml but in image scaling. Android and UWP handle image scaling very differently, if you want a uniform look you need to provide correctly scaled images to UWP and provide Android with the correponding sizes.
Take a look here: UWP, how to handle images and scaling?
Answer: First of all, you have multiple questions in one.
The cut off in android: try setting HasUnevenRows to true (a property on the listview)
For the rounded corner you have to go for a Custom Renderer, which leads to you having to create rounded borders the native elements representing the gras.
It's a Xamarin.Forms.Image right? So for android, you would have to use the ImageRenderer or the (AppCompat.)ViewRenderer.
I could only give you a more elaborate example for android for rounded corners, if you can't find help for this on the net.


addthis_widget.js throwing Cannot read property '_pmh' of null error on Android and Chrome

Question: I am using a JavaScript error logging tool to log any JavaScript errors on my mobile site and I am seeing a large number (22,000 in under a month) of this error:
Uncaught TypeError: Cannot read property '_pmh' of null
I can see from the addthis_widget.js code that it is originating from that script.
I can also tell that it only affects mobile Android and Google Chrome browsers, these in particular:
Android 4, Android 4.1, Android 4.2, Chrome 11, Chrome 18, Chrome 25, Chrome 26, Chrome 27, Chrome Mobile 18, Chrome Mobile 25, Chrome Mobile 26
I am using the following external JavaScript include:
http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b6adff375a64db9
and have the following configuration object set:

Is there anything I can do to prevent this error from occuring so many times on these browsers?
Answer: I have located the cause of this issue and it is down the following code.
if (window.addthis) {
   window.addthis = null;
   window._adr = null;
   window._atc = null;
   window._atd = null;
   window._ate = null;
   window._atr = null;
   window._atw = null;
}

This was an attempt to cleanup the objects lying around when moving between pages dynamically to prevent memory issues.
addThis now provide support for this problem, their support department sent me the following link:
http://www.addthis.com/blog/2013/05/07/a-brief-history-of-using-addthis-dynamically/#.Uklx4RCKyas
and the following explanation/information:

Along with other information from my peers and such, I've come up with
  the proper code which should be executed when moving from virtual page
  to virtual page such as in your mobile application. Rather than
  nulling any of the AddThis related objects, they must be left alone.
When the page URL or Title (or any other AddThis configuration option)
  that you want to be used by our buttons changes, you should execute
  our method:
addthis.update(type, key, value)
It takes the three parameters: type, key, value.
Type is either "share" or "config". The key is the same key you would
  set according to our API documentation. What you likely need to know
  are just the two keys: "url" and "title". The value is of course the
  value you want those options to have.
After you have updated all of the options you need to update using
  that method, you need to invoke this method:
addthis.toolbox(cssSelector)
The cssSelector is usually going to be ".addthis_toolbox" but if for
  some reason you don't want to refresh all of your toolboxes, you can
  be more specific about it.
Once you have made those changes to your code, I believe that our
  tools will work properly for you and that there will be no more "null
  object" related javascript errors.
You can look at this JSFiddle to see an example of dynamically
  changing content: http://jsfiddle.net/j5addthis/r6Utv/
Answer: I'm having the same issue, but it appears that there was, at one point, a fix to your specific case above by simply upgrading the script that you're using from addthis to version 3.0 by changing this:
http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b6adff375a64db9

To this:
http://s7.addthis.com/js/300/addthis_widget.js#username=xa-4b6adff375a64db9

Read more here: http://support.addthis.com/customer/portal/questions/1021465-addthis-widget-js-throwing-cannot-read-property-pmh-of-null-error-on-android-and-chrome
Note though, as I mentioned above, my issue continues to persist even with version 3.0 despite the AddThis help desk stating that should work.
Comment: Hi Karan, you will probably notice that the addThis support link originated from myself (crmpicco). I did indeed update from 250 to 300, however the problem still persists sadly. I have followed up with a support request to addThis but they've gone quiet. It seems to occur more often on mobile devices, but it's not localised to one OS or device.


Why does sorting array of enums with Swift 5 give different results?

Question: I don't know whether it is a bug or a feature but sorting array of enums give different result with each run. Here is a basic code to test it.
enum Tag: String {
    case bold, italic, underline
}

extension Tag: Comparable {
    static func <(lhs: Tag, rhs: Tag) -> Bool {
        return lhs.hashValue < rhs.hashValue
    }
}

let tags:[Tag] = [.bold, .italic, .underline].sorted()
print(tags.map {$0.rawValue})

Comment: @VatsalManot Right. I wasn't paying attention. I'll remove my comment.
Comment: @Meanteacher The answers here are misleading: `hashValue` is based on a function. Meaning for a given value, the hashValue of it would be the same. Unless you store it and then build it again later at a different time. From the shared link it says Random seeding" means that hashValue properties will return **different values on each execution of a Swift program.** ie it doesn't change 'during' an Xcode build. Aside from that: it's incorrect compare enums based on their String rawvalues. How do you compare "john", "Peter" and "TJ"? The OP hasn't state how he wants them to be compared...
Answer: The simple answer:
In your example, you are comparing using the hashValue of a String. Swift 5's hashing algorithms differ from that of Swift 4.
The answer you're looking for:
Don't sort strings (or any type for that matter) based on their hashes, it's not what you're looking for. What you're looking for is this.
The implementation you want is probably this:
extension Tag: Comparable {
    static func <(lhs: Tag, rhs: Tag) -> Bool {
        return lhs.rawValue < rhs.rawValue
    }
}

rawValue being the raw String value of the enum.
A hash value is the product of a hash function, which has absolutely nothing to do with sorting.
Bonus info:
For those astute observers wondering why the hash values are different every Swift run, here is the breakdown.
Comment: @Alex Swift's standard library hashing functions now use a random seed per program execution (as discussed [here](https://forums.swift.org/t/psa-the-stdlib-now-uses-randomly-seeded-hash-values/10789)).
Comment: It would be neat to know why the hashes are different each time, is this a collision?
Comment: "The implementation you want is probably this:" Why don't you ask him? Normally  you don't want to compare "Alex" vs. "TJ".
Answer: Pretty sure it's because of this:

Hash values are not guaranteed to be equal across different executions
  of your program. Do not save hash values to use during a future
  execution.

If you change your Comparison method to:
return lhs.rawValue < rhs.rawValue

that should work.
Comment: `hashValue` is based on a function. Meaning for a given value, the hashValue of it would be the same. Unless you store it and then build it again later at a different time. From the shared link it says Random seeding" means that hashValue properties will return **different values on each execution of a Swift program.** ie it doesn't change 'during' an Xcode build. Aside from that: it's incorrect compare enums based on their String rawvalues. How do you compare "john", "Peter" and "TJ"? The OP hasn't state how he wants them to be compared...
Comment: @Honey I was looking for deterministic order. I have learned that hashValue is not deterministic. This answer is sufficient for my use case.
Comment: @Honey can you remove that -1 for me, bud?
Comment: @leahyjwilliam I gave you +1 and accepted your answer. I don't know who gave you the -1.


Where should I connect the green ground wire in main panel next to meter?

Question: I am wondering what would be the correct location to connect the unconnected green ground wire in main panel next to meter. The detached garage has it's own ground rod. It is being fed by the double pole 50 amp breaker in main panel next to meter. I attached photos. The bare aluminum cable in main connects to ground bus bar in breaker box located inside house. The ground rod under meter connects to inside meter box only.
The hanging #6 green wire and 3 other black #6 wires run 60ft underground in conduit to detached garage sub panel. Two black #6 are on each pole of double 50 amp breaker and other black #6 is on neutral bar of main box next to meter.
Comment: One of the best styled subpanel questions I've seen in an age.  Did the research, shows work, asks one question.
Answer: Fit a ground bar to the main panel, land it there
While, since you're working in a main panel here, you could commingle neutrals and grounds by landing your new ground wire on one of the neutral bars, it's cleaner to avoid that altogether and install a separate ground bar into the main panel instead for the ground wires.  Since you have a Square-D main panel, the correct part for your situation is a PK12GTA or PK15GTA -- you should be able to find it at a local electrical supply house or order it online for about $10.  Simply mount it to the main panel's cabinet in the holes provided, with the meter pulled for the duration (there should be a set top left or top right -- if not, the install instructions give guidance on drilling a set of mounting holes), then attach the ground wire to the newly fitted ground bar.  Once that's done, have the electric company turn the power back on, and enjoy your new subpanel!
(The previous installer committed a bit of a no-no by using a black wire for a neutral and phase-taping it instead of using a white wire, but that can be rectified down the road if it ever becomes an issue.  I would suggest phase taping it white at this point, at a minimum, to avoid needless confusion due to the previous installer's non-standard phase-taping scheme.)
Comment: Yeah, in conduit you're not allowed to phase-mark wires to change their purpose among hot/neutral/ground, unless they are #4 or larger.  You can,t even mark a white wire hot in a switch loop.  A good reason to go #4Al in an application like this.
Comment: @ThreePhaseEel, So neutral and ground should not be bonded in the inside panel, right?
Comment: @JimStewart -- correct
Comment: @MKlein -- that metal conduit will bond the meter pan and main panel together, yes, provided the proper bonding-type locknuts were used.  BTW: we show our thanks here by upvoting and/or accepting answers that help us out :)
Comment: Thanks for your help. The tape was my fault. I used it to help me identify wires after pulling through conduit. They didn't have #6 white in stock. So I can fix by wrapping neutral wire with white electrical tape, correct?
Comment: So is removing the meter for safety or to connect ground bar to the copper ground in meter box with a copper ground wire? After installing ground bar and connecting green wire will any other wires need to be connected to ground bar?
Comment: Could the OP remove one of the ground bars from the subpanel and install it in the main panel? There is no need for two ground bars in the subpanel, right?
Comment: @MKlein the white electrical tape isn't Code, but it's an improvement over the current situation.  Having the power company cut power (since you have a smart meter, they likely can do this from the comfort of their office) is for safety's sake since you're working in the main panel, especially since your panel lacks service barriers over the incoming hot wires.
Comment: @JimStewart -- he could, but it comes at a cost in neatness if you will
Comment: @ThreePhaseEel, won't switching off that main breaker depower the busses to the lugs which go to the inside panel (and to the garage subpanel)? So the inside panel with all the branch circuit breakers is technically a subpanel, right? Presumably the inside panel will not have a main disconnection breaker, or will it? I have seen a panel like this (done by a really high quality builder in Gulfport MS) with no main disconnection breaker in the *inside* panel. I was stunned. Most people expect to be able to turn off their power with one flip at what they would consider the main panel.
Comment: @JimStewart -- the inside panel is a subpanel in this case, yes.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/87461/discussion-between-jim-stewart-and-threephaseeel).
Comment: His neutral and ground are already commingled.  (In my area, it's required by code to comingle at the meter.)  Unless I'm missing something, all he has to do is connect his green to the neutral bar on the left and he's as well connected as everything else in his house without adding a new grounding spike.
Comment: @JBH -- he can commingle N and G in the main if he wishes -- I simply favor not doing that as I consider commingled N/G a sign of a not-so-neat-and-tidy installation.  Also, your area forbids separate-but-bonded N/G bars in main panels?!
Comment: Again, thanks for all the great information. I am attaching all updated photos plus a look at the panel inside the house. Green wire is now connected to the Square D ground bar attached with two screws to main panel. So if lightning strikes is main panel ground to meter via the metal conduit connecting them together?


How to import an existing Aurora MySQL cluster in a AWS CDK project/stack?

Question: Is there a way to import an existing RDS aurora mysql cluster into a stack - that is NOT a serverless rds cluster?
I need to add some permissions and s3 bucket import property to  an existing cluster.
Answer: CDK has nothing to do with serverless - it can set up (almost) any resource in AWS, serverless or not.
so while it depends on your language, you'd use something like: (python)
<code>from aws_cdk import aws_rds as rds
 ....[in your stack init]
my_existing_rds = rds.DatabaseCluster.from_database_cluster_attributes(
    self, "ExistingRDS",
    cluster_identifier = "the cluster identifier"
)
</code>
as defined here: https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_rds/DatabaseCluster.html#aws_cdk.aws_rds.DatabaseCluster.from_database_cluster_attributes
Be aware. importing existing resources using the from* static methods of various resource constructs does not always give you access to updating all of their properties!!! For instance, importing a domain name with from_arn does NOT Give you the ability to get its host_zone! The import objects are useful, but ultimately not the preferred method of dealing with resources in CDK. (generally however, in response to your question, Role's are accessible)
Comment: Thanks @lynkfox - The documentation wasn't too clear on how to get there. I was able to get an instance to the existing RDS cluster with this:

`rds_cluster = rds.DatabaseCluster.from_database_cluster_attributes(
            self, "datamart_rds_cluster", cluster_identifier="my-beloved-cluster-01")
`
Comment: @YoCollabStackoverFlow good catch, my fault for not remembering that construct in the code. Ive updated the answer just in case


Formik form no validated using Yup on test environment with jest

Question: I'm trying to test if validation is raised when a required field is empty. In my example, I have an email input, which I set to empty, and when I simulate submit action, the onSubmit function is executed when in reality it shouldn't. I'm using validationSchema property using Yup to validate my form. I've added console.log() inside my submit function which is displayed in debug mode (and it shouldn't).
This is working in dev environment (validations raised, onSubmit function no executed) but for some reason, it doesn't work in test env.
It's worth mentioning that I'm full mounting the component to test it using Enzyme.
Thanks in advance.
I've tried with .update to check if at least the view is updated after simulating the action, but it still invokes the submit function.
Here's my code:
form.js
  render() {
    const { intl } = this.props;

    return (

        <Formik
          initialValues={{ email: '', password: '', passwordConfirmation: '' }}
          onSubmit={this.submitForm}
          validationSchema={SignUpSchema}
          render={ formProps => (
            <Form>

{formProps.errors.general}

              <FormControl margin="normal" fullWidth>
                <Field
                  type="text"
                  name="email"
                  component={TextField}
                  className='signupForm__input'
                  label={intl.formatMessage(messages.email)}
                />
              </FormControl>

              <FormControl margin="normal" fullWidth>
                <Field
                  type="password"
                  name="password"
                  component={TextField}
                  className='signupForm__input'
                  label={intl.formatMessage(messages.password)}
                  fullWidth
                />
              </FormControl>

              <FormControl margin="normal" fullWidth>
                <Field
                  type="password"
                  name="passwordConfirmation"
                  component={TextField}
                  className='signupForm__input'
                  label={intl.formatMessage(messages.passConfirmation)}
                  fullWidth
                />
              </FormControl>

              <Button
                type="submit"
                fullWidth
                variant="contained"
                className='signupForm__button'
                disabled={formProps.isSubmitting}
              >
                <FormattedMessage id="login.form.submit" />
              </Button>

              {formProps.isSubmitting && <Loading />}
            </Form>
           )
         }
        />

    );
  }

test.js

  describe('submit with blank password', () => {
    beforeEach(() => {
      subject = mount(withStore(<SignUpPage />, store));
      // load invalid data to the form
      email.simulate('change', { target: { name: 'email', value: 'email@example.com' } });
      password.simulate('change', { target: { name: 'password', value: '' } });
      passwordConfirmation.simulate('change', { target: { name: 'passwordConfirmation', value: 'password' } });
      form.simulate('submit');
    });

    it('should display an error in the password field', () => {
      subject.update();
      const passwordInput = subject.find('TextField').at(1);
      expect(passwordInput.props().error).toBeTruthy();
    });
  });

Answer: Though Formik's handleSubmit is a sync function, validation with yup functions are called asynchronously.
The following worked for me.
 test("Formik validation", async () => {
    const tree = mount(<YourForm />);
    // Submit the form and wait for everything to resolve.
    tree.simulate('submit', {
       // Formik calls e.preventDefault() internally
       preventDefault: () => { }
    });
    await new Promise(resolve => setImmediate(resolve));
    tree.update();
    expect(yourPasswordInput.props().error).toBeTruthy();
});


"Walk/Don't Walk" street sign wired into bathroom light

Question: I have a game room type area that has it's own bathroom.  Above the door to the bathroom I would like to place one of those "Walk/Don't Walk" street signs.  I would like the "Don't Walk" to be wired so that it comes on with the light in the bathroom.  I would like the "Walk" to come on when the light in the bathroom goes off.  I was thinking a two way switch could do this ... but now I'm thinking that it wouldn't work.  Do you know which kind of switch I would need?
Comment: I don't know if you already have the light or just plan to get one, but make sure you verify that it will take "regular" household voltage (110V or 220V, depending on your location). I don't know anything about traffic lights but street lights can have quite high voltages.
Comment: 120 VAC printed on back.  I have verified that each side of the light works with household current.  Instead of one lamp for each side, each side has a lot of tiny LED bulbs.
Answer: A 2 ways switch should totally do it:

wire the common of the switch with the line cable
wire one of the switch ways to the bathroom light and the don't walk light
wire the other switch way to the walk light
wire all lights second wire to the neutral cable
if your walk/don't walk sign has a metal frame, wire it to the protective earth cable

Just ensure that:

the bathroom light and don't walk light are connected in parallel, not in series
your 2 ways switch is graded for the sum of your two lights (look at the number of watts on the bulbs)

You may want to add a second switch somewhere so the walk sign won't stay on 24/7 while the gaming room is empty (perhaps wiring everything to the main light switch off the gaming room?)
EDIT: I should add that, since it implies live electric current, YOU SHOULD HAVE A FULLY QUALIFIED PROFESSIONAL CHECKING YOUR DESIGN BEFORE YOU DO ANYTHING, and CHECKING WHAT YOU'VE DONE BEFORE ANY CONNECTION TO YOUR POWER GRID! (depending where you live, this may be mandatory by law; if it's not, you should still do it)
Or in other words, you do as you want, but I'm not responsible if anything goes wrong after you followed instruction from "some guy on the internet".


How to get .Net build macros in NANT build file?

Question: I tried to make my .Net project to run a post-build script. This script is to trigger a NANT build. So, in the Build Events, I wrote the following line:
"%ProgramFiles%\Nant\bin\NAnt.exe" build -buildfile:"$(ProjectDir)assets.build"
exit 0

However, for some reason, the build works fine when I run the "nant build" directly in the command line. It pops errors when it runs in the post script. The problem is related to the paths. I am thinking to pass the Net macros into NANT build as a property through the command line. Something like:
"%ProgramFiles%\Nant\bin\NAnt.exe" build -buildfile:"$(ProjectDir)assets.build" -D:testpath="$(ProjectDir)"

It still is not working.
Any advice?
Comment: Can you post the error you are seeing?
Answer: It probably has something to do with the "current" working directory.
Does the nant build script try to access any other files or external references, using relative paths for example?
If so, you may want to use the project::get-base-directory() nant function to build your paths instead.


Show $X$ is a Stationary Process

Question: Assume $\{Y_n : n \in \mathbb{Z_+} \}$ are iid with $P(Y_0=0)=P(Y_0=1)=0.5$. Let $X_n=Y_n+Y_{n+1}$ for all $n \in \mathbb{Z_+}$.
Show $X$ is a stationary process.
I've showed that $X$ is not $(F_n^X)$-Markov Chain by showing that $P(X_2=2 |F_1^X)$ is not equal to $\phi(X_1)$ for any $\phi: \{0,1,2 \} \rightarrow [0,1]$ for the first part of the question.
Now to show that it is not a stationary process, I want to show that $P((X_0,X_1,...) \in B) \neq P((X_1,X_2,...) \in B) $. I've tried to use the definition of $X$. But I couldn't get anywhere after that.
Please help.
Thank you!
Answer: $$
X_{t+i}=x_i\ \text{ for }\ i=0,1,\dots,n\ .
$$
if and only if
$$
Y_{t+i}=\sum_{j=0}^{i-1}(-1)^{i-j-1}x_j+(-1)^iY_t\ \text{ for }\ i=1,2,\dots,n+1
$$
Therefore, if $\ y_i=\sum_\limits{j=0}^{i-1}(-1)^{i+j-1}x_j\ $, then
\begin{align}
P\left(\bigcap_{i=0}^n\left\{X_{t+i}=x_i\right\}\right)&= P\left(\bigcap_{i=1}^{n+1}\left\{Y_{t+i}=y_i+(-1)^iY_t\right\}\right)\\
&= \frac{1}{2}P\left(\bigcap_{i=1}^{n+1}\left\{Y_{t+i}=y_i\right\} \,\big|Y_t=0\right)\\
&\ \ + \frac{1}{2}P\left(\bigcap_{i=1}^{n+1}\left\{Y_{t+i}=y_i +(-1)^i\right\} \,\big|Y_t=1\right)\\
&=\cases{\frac{1}{2^{n+1}}&if $\ y_i, y_i+(-1)^i\in\{0,1\}$\\
&for $\ i=1,2\dots,n+1$\\
\frac{1}{2^{n+2}}&if $\ y_i\in\{0,1\}\ $for $\ i=1,2\dots,n+1$\\
&but $\ y_k+(-1)^k\not\in\{0,1\}\ $for\\
&some $\ k\in\{1,2,\dots,n+1\}$\\
\frac{1}{2^{n+2}}&if $\ y_k\not\in\{0,1\}\ $for some $\ k\in\{1,2,\dots,n+1\}\ $\\
&but $\ y_i+(-1)^i\in\{0,1\}\ $\\
&for $\ i=1,2,\dots,n+1\ $\\
0&otherwise.}
\end{align}
Since this is independent of $\ t\ $, it follows that $\ \left\{X_i\right\}_{i=0}^\infty\ $ is stationary.
Comment: Could you elaborate?
Comment: On the equvalence, or on how to proceed therefrom?
Comment: To proceed therefrom. I'm not immediately seeing this equivalence's relevance to the definition of stationarity.
Comment: I have added a sketch of the argument for stationarity.
Comment: Ah, I see, thank you

Show $X$ is a Stationary Process


Why does yubikey-personalization claim the zeroth USB interface?

Question: I'm looking at the _ykusb_write() function from the Yubikey-Personalization package and the first line of code executed is
int rc = usb_claim_interface((usb_dev_handle *)dev, 0);

Why is the zeroth USB interface claimed? From what I can tell from the lsusb output (see below) that interface is an HID and not the smartcard itself. I would had expected the 2nd interface to be claimed instead, but I do not understand this part of Yubikey very well. Where is it documented? Thank you for your help.
bNumInterfaces          3
Interface Descriptor:
  bInterfaceNumber        0
  bInterfaceClass         3 Human Interface Device
  bInterfaceSubClass      1 Boot Interface Subclass
  bInterfaceProtocol      1 Keyboard
  iInterface              0
Interface Descriptor:
  bInterfaceNumber        1
  bInterfaceClass         3 Human Interface Device
  bInterfaceSubClass      0
  bInterfaceProtocol      0
  iInterface              0
Interface Descriptor:
  bInterfaceNumber        2
  bInterfaceClass        11 Chip/SmartCard
  bInterfaceSubClass      0
  bInterfaceProtocol      0
  iInterface              0
  ChipCard Interface Descriptor:

Answer: The YubiKey Personalization package referenced dates back to the YubiKey 1/2 models, which did not have CCID/Smart card support. The YubiKey 1/2 devices could only be communicated to via the HID keyboard interface, and identified to host devices as a USB keyboard. As such, the package attempts to connect to a YubiKey as if it was a keyboard.
The YubiKey Personalization package does not communicate over CCID/Smart card, but instead uses the HID keyboard interface. Yubico maintains this project as modern devices which support the touch-triggered OTP functions also can be programmed over the HID keyboard interface, and as such it remains useful for specific cases.


"show desktop" with "hot corners" not working!

Question: The function SHOW DESKTOP when moving mouse to the HOT CORNERS in ubuntu 13.04 worked.
After updating to 13.10, SHOW DESKTOP/HOT CORNERS only works until rebooting or setsid unity, after which it doesn't work.
I thought that something was wrong in the update to 13.10, so I made a clean install of ubuntu 14.04 to find out that the same issue exists.
What can I do to make SHOW DESKTOP/HOT CORNERS work again?
I have already tried to reset compiz and unity, and I did fresh install.
Comment: For future visitors to this page: The fixes proposed below apparently cause [another bug](https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/1311323). Also worth noting that Ubuntu's default keyboard shortcut for "Show desktop"
 is `Control-Super-D` (super is the usually the "Windows" key next to Alt)
Answer: I was able to solve the problem by brute force.
Moving every single option in CompizConfig Settings Manager I did find that when Unity was disabled then Show Desktop works as expected with the HOT CORNERS.
So i click every single checkmark in Ubuntu Unity Plugin to finally find that Show Live Previews of Windows in the Switcher was the one to blame. (After unchecking it hot corners works as expected.
Comment: disabling this one could cause bug. https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/1311323
Answer: A temporary solution until the bug has been fixed, could be to use xdotool.

install:
sudo apt-get install xdotool

in compiz config manager, under General Settings, insert a command line
xdotool key super+d

in edge bindings, configure the hot corner

Works for me. Ubuntu 14.04
Comment: Also, after having reinstalled 14.04, I decided to run with Nouveau instead of nVidia drivers and it seems less buggy now, although it could be other factors as well. I had a lot of graphics-related bugs and black screens before, which are now gone. (I have a laptop with nVidia 650M card)
Comment: This solution works on Ubuntu 16.04.2 LTS.
Comment: this only made my keyboard type the letter 'd' when going to the assigned corner.
Comment: @KalamalkaKid, Check your Compiz settings: Open CompizConfig > Ubuntu Unity Plugin > General;    there is a setting called "Show Desktop" which should be mapped to "d"
Comment: This is the only solution I found
Answer:
Open CompizConfig Settings Manager
Under CATEGORY choose Desktop
You will see "Ubuntu Unity Plugin"
On the rightmost tab called "Switcher" uncheck SHOW LIVE PREVIEWS OF WINDOWS IN THE SWITCHER  as Ivanyosan suggests above
Comment: this didtn work in 14.04
Comment: This worked in Ubuntu 14.04.5 64-bit as of now.
Answer: Ubuntu 14.04 is currently still in development - it will not be available properly until April 2014. You don't need to upgrade to it yet :-).
Anyway, using unity-tweak-tool, set this...

..and you should be able to show & hide the desktop by placing the mouse in the lower-right corner - it works very nicely in 13.10.
Comment: i wonder why it works the first time only. (in my case)
Comment: yeah, it is supposed to work like that, but in my case it doesnt.
show wall and show windows work but show desktop doesnt. It's very strange.
Comment: Even for me. Show desktop works only for first time! Any updates?
Comment: Actually... Most of the time it seems to work, but half the time it doesn't... All the others also work perfectly all the time...
Comment: Currently, this functionality doesn't work with Unity Tweak Tool in ubuntu 14.04. It has been reported as a [bug](https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/1305438).
Answer: Unfortunately these fixes work on some computers and not on others.  I personally haven't found any change when unticking the Compiz Untiy Plugin under "Switcher" tab.  It doesn't seem to make a difference.  So the problem still remains on one of my older desktop computers that no method above would work.  So I tried a different approach and it seems to work on every computer and is very consistent.  Here is what I did.
First make a bash script.  To do this create a "New Document" from your right click menu and choose "Empty Document".  In this new document paste this:
#!/bin/sh
sleep 3
compiz --replace

Now save this file as "compiz-start".  Make sure to set its permissions to "Allow executing file as program" ticked and move this file to /usr/bin/.  You may also want to change to ownership to ROOT if you haven't already.
Now create a .desktop file to trigger this script.  First right click and choose "New Document" then "Empty Document".  Open this file and paste the follow text into it:
[Desktop Entry]
Type=Application
Exec=compiz-start
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=compiz-trigger-start.desktop
Name=compiz on start
Comment[en_US]=compiz on startup
Comment=compiz on startup

Save this file. It should save automatically as "compiz-trigger-start.desktop".  Move this .desktop file to either your home autostart folder ~/.config/autostart (which will only work for the user) or place it into /etc/xdg/autostart which should make this fix work for all users of the system (or future new users).
This has worked for me on all computers that it was tested on...even the one that previously nothing had worked.  You can tell that it works because just after the Desktop loads and the Unity bar shows up; the screen will reload itself...which is Compiz restarting.  The "sleep 3" is critical to this working.
I hope that help you guys fix this "hot corners", "Show Desktop", "Spread Windows".
Chris
Comment: to avoid breaking Yakuake, I had to do this: `metacity --replace` `sleep 3` `compiz --replace`
Comment: this second part doesn't make sense to me. How is it connected to the first script in anyway? Why wound't we just add compiz in the startmenu programs instead of creating a .deskto file? Also, the command 'compiz-start' is not recognized in Ubuntu 14.04 =)
Answer: To make "Toggle Desktop" work for example with unity-tweak-tool here the solution:

Uncheck "Show live previews of windows in the Switcher" under the tab
  "Switcher" of the Ubuntu Unity Plugin

You'll find the Ubuntu Unity Plugin under the CompizConfig Setting Manager.
Type ccsm in the Terminal.
Found the solution here.
Answer: I did uncheck SHOW LIVE PREVIEWS OF WINDOWS IN THE SWITCHER as Ivanyosan said. But it still doesn't work for me.
  After unchecking the whole Ubuntu unity plugin and then check it again, CCSM will show a lot of warring that other plugins have same function as the Ubuntu unity plugin does. Then choose to use Ubuntu unity plugin instead of other plugins. That works for me on ubuntu 1404.
Comment: Please restructure your post to help answer the OP in clear terms.


Can't set data to an array in prepareForSegue

Question: I'm using Objective-C, I want to copy an array for another view controller and push it. Here is my code:
<code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"comment"]){
        commentViewController *vc = segue.destinationViewController;
        vc.comments = [[NSArray alloc]initWithArray:comments];
    }
}
</code>
But it doesn't work. I got this in Xcode:
2015-12-06 16:27:45.802 net[1244:29117] -[UIViewController setComments:]: unrecognized selector sent to instance 0x7ff8d34eb720
2015-12-06 16:27:45.807 net[1244:29117] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setComments:]: unrecognized selector sent to instance 0x7ff8d34eb720'
Someone can help me?
Comment: Check your storyboard.  It looks like the class for this view controller is UIViewController instead of your subclass.
Answer: Select your destination view controller in the storyboard. And in the identity inspector make sure that your destination vc is your custom class as seen in the pic.


chrome does not render gif background image

Question: Currently running chrome 14, and it fails to render a spinning gif graphic on my login page.
Here is what the page looks like in chrome:

Here is what it looks like on all other browers:

To reproduce:
http://trunk.test.openmile.com/login/#null
Enter a valid email and password and hit 'login', then when the black progress indicator appears, hit STOP so that the browser doesnt have a chance to give you a login error.
Notice that the background is not displayed in chrome. Interestingly, if you inspect the element, and add 1px to the background image position, the image will become visible.
Smells like a chrome bug to me, but is there a workaround?
edit:
Another really strange thing is: if i put an alert at the end of the function that shows this processing div, after the alert, the background-image becomes visible.
Answer: I can reproduce your problem, but if I manually trigger the popup in the console, I see the spinner just fine:
> OM.processing($('div.portlet.login form'));

So here's my guess - your spinner hasn't been preloaded, and you're opening the window while you wait for an AJAX request. For whatever reason, other browsers will load the image while the AJAX request is pending, but Chrome won't. To test this, I tried this in the console:
> var img = $('');

then tried to log in normally - and I saw the spinner.
So I think if you preload your spinner image, maybe with the code above, and it should work properly.
Comment: If you want to keep it CSS dependent you might want to use this `var bg = $(this).css('background-image');
        bg = bg.replace('url(','').replace(')','');
        var forceChromeToLoadImage = $('');` see http://stackoverflow.com/questions/8809876/can-i-get-divs-background-image-url
Answer: I bumped into issues when using nrabinowitz's answer.
So I ended up including the relevant image somewhere in the page with 0 dimensions.
HTML:
<input class="button" id="myButton" type="submit" name="searchButton" />
...

Javascript:
/*
  Hack for Chrome issue with GIF bg images
    [1] gets the bg url from the CSS
    [2] Extract the path: by removing opening string "url(" and closing character ")" that surround it
    [3] Sets the relevant image tag with our GIF image's path
*/
$('#myButton').click( function() {
    var bg = $(this).css('background-image');   // [1]
    bg = bg.replace('url(','').replace(')',''); // [2]
    $('.loaderHackForChrome').att('src', bg);   // [3]
});

source: http://chromespot.com/forum/google-chrome-troubleshooting/4336-background-image-doesnt-load.html
EDIT: this issue may have been fixed now in 2016


how to upload at new name and section

Question: I have a problem that made me lose my temper really I have the following code
OK ?
$sections = array("Other","Romance","Horror","Sucid","Dance","Comedy");

$vedioname = $_POST['vedionamet'];

$path = $_POST['selectsection'];

$finalpath =realpath(dirname(__FILE__)."/Uploads/".$path);

$vedname= $_FILES['vedio']['name'];

$temp=$_FILES['vedio']['tmp_name'];

$type = $_FILES["vedio"]['type'];

$size = $_FILES['vedio']['size'];

$errors = $_FILES['vedio']['error'];

if($_POST['uploadsub']){

move_uploaded_file($temp,$finalpath.$vedioname);

echo "Done Uploaded".$type;

}else
{
 echo "$error";
}

The first problem is supposed to be the process of uploading the file to file uploads
The file is not even uploaded to the same file as the page
Second, the goal is to write the name of the file uploaded within the text, but what is happening in reverse exactly that
So how to make the upload process successful
Inside the uploads / value received from the form section
And the new name of the received value of the form
    <form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">

    Vedio Name:
        <input id="name" type="text" name="vedionamet" value="vedio">

        Select Section :
        <select name="selectsection" id="section" >

            <?php
            foreach($sections as $pathat){
                echo "<option value='$pathat'>" . "$pathat" . "</option>";

            };
            ?>
        </select>

        Select Vedio :
        <input id="upload" type="file" name="vedio">

        <input id="subb" type="submit" name="uploadsub" value="Upload">
        </

Answer: For the HTML part, you may change the action to "#" if you want to use a same page to handle the upload request.
For the PHP part, you may try the following codes, it works on my computer. Please also make sure that you have already established these sub video folders in Uploads folder
<?php
$sections = array("Other","Romance","Horror","Sucid","Dance","Comedy");
//add one condition to avoid warning when the page first loads
if(isset($_POST["selectsection"])){

    $vedioname = $_POST['vedionamet'];

    $path = $_POST['selectsection'];

    //Use this to get the path
    $finalpath = realpath(dirname(getcwd())) . '\\Uploads\\' . $path. '\\';

    $vedname= $_FILES['vedio']['name'];

    $temp=$_FILES['vedio']['tmp_name'];

    //Use this to get the extension of file name
    $type = pathinfo($vedname, PATHINFO_EXTENSION);

    $size = $_FILES['vedio']['size'];

    $errors = $_FILES['vedio']['error'];

    if($_POST['uploadsub']){

    move_uploaded_file($temp,$finalpath.$vedioname.".".$type);

    echo "Done Uploaded".$type;

    }else
    {
    echo "$error";
    }
}

?>

how to upload at new name and section


What is the best way to join toe kick boards?

Question: We got out cabinets installed and the only thing missing are the toe kicks.
Sounds like something "simple" however, both of our runs are longer then a single toe kick board.
The board they provided is really thin, about 1/4".
I'm wondering how people join these together.
Since they are too thin it doesn't look like a 45% cut - for overlapping - is an option.
Just having them side by side will leave a very noticeable line in between them specially because they are white.
Is there a magic to make it (almost) seamless?
Or... maybe the "very noticeable" joint was always there before in the old cabinets and I just never noticed it?
My other concern:
Is 1/4" too thin? Should this be used more like a skin for a thicker unfinished toe kick such as a 1/2 plywood board?
Comment: That looks a _lot_ like drywall in your second picture, is that what it is? Drywall doesn't seem to me to be the appropriate material for a toe kick (since it's fairly fragile and an actual toe-kick would crack it). I would think you'd want some 1x wood trim material for down there. If you do go with the drywall, you would hide that very noticeable gap with joint compound and tape, but that's going to be a very difficult joint to finish. Also, there's no real way to do a lap joint (your 45° overlap) with drywall.
Comment: @FreeMan this is not drywall, this is the finished 1/4" toe kicks they gave us.
Answer: Don't join Them
Well the best option is to only have one kickboard.   Looking at yours I would just throw them away.   For kickboards I use 1x and I use either pine or Azek.   That is the area of the kitchen that has the most chance for water damage so don't use plywood or something like that.   MDF would be your worst choice (isn't it the worst choice for almost anything).
If you do... do it with style
The other option and just used this for the toekick on a rather big island is a rosette.  If you center this it becomes a design element not a stop-gap solution.   I used something very similar to this - link.   Note that rosettes are often thick... So you may have to plane the back.   I usually put the toekicks next to the rosette.   You will not be able to do that if the boards you have are as thin as you described.
Also my suggestions are based on the other materials being used...  Your cabinets look really nice.   Throw those toe kicks away and go with a long piece of pine or azek (any pvc 1x6).  If you need to rip the 1x6 put the ripped edge on the top - no one will ever see it.
Answer: I would simply cut the toe kick so that the butt joins occur where two cabinets join.
Then, I would find an appropriate piece of moulding to cover the joins.
The simplest solution is cheap plastic t-moulding (check in flooring)  like this:
However, you can check around the flooring department for t-shaped transition mouldings that suit your needs (may be expensive)  or in millwork, for something else suitable.
But, if you're going to the the store, you might as well look in millwork for something to use instead of the provided material that comes in 16 ft lengths.
Answer: I typically build my own kicks for lower cabinets and the front is solid so fastening the 1/4" or thinner material to the solid blocking isn't an issue.
I have seen systems with legs for the lowers and then you clip the finished kick to that.  I agree that 1/4" thick material is too thin, one kick to the kick and it will crack.  In your case with a tile floor probably your plan of 1/2" plywood as a backer is going to be the best plan.  I'd keep the plywood slightly off the finished floor in case water gets on the floor (this should help avoid it wicking into the 1/2" plywood).  No one is going to see the joins on the kick so I wouldn't bother with anything beyond a butt join when attaching the 1/4" to the 1/2" ply.  You could probably just silicon the 1/4" material to the 1/2" ply to avoid nail holes.  How long are your cabinet runs, you can get 10' material easily so if the join bugs you enough just source some new white 1/4" mdf or hardboard.
Comment: A quick bead of white painter's caulk will also cover that joint nicely.
Answer: I'm on board with upgrading to a pre primed pine or something similar.  it will hold up better.  If you do, i would make a 45 degree cut, and join the 2 pieces with CA glue and activator.  careful, the glue dries instantly and permanently so you only get one shot to attach them.


Upstart Job (.conf) Fails to Install

Question: I have a simple package (.deb) wherein the main goal is to create an Upstart job. Call it Foo. It fails to create the job file /etc/init/Foo.conf.
Package Definition
I have created the package source using dh_make --createorig and added Foo.upstart to the debian directory. I build the package with debuild -us -uc.
Installation
sudo dpkg -i Foo_1.0-1_all.deb
When I install the package on one machine it goes fine, but another it fails. (Foo.conf is added to /etc/init and the service is started).  That is, Foo.conf is not added to /etc/init. The backwards-compatibility Foo script (symbolic link to upstart-job) does get added to /etc/init.d, and doc files are added to /usr/share/doc/Foo. But, /etc/init/Foo.conf is missing.
EDIT
Originally I believed the problem was due to architecture. That was simply because I had a working install on amd64, but the problem occurred on an i386 machine. I neglected to realize that I had previously done manual installation & removal on the i386 machine which dpkg avoided interfering with.
Comment: i've not done this in a long time, but are you doing this? `dpkg --add-architecture i386` ??
Comment: I have not tried that. However, reading the docs it seems that might be for the reverse problem: if I had an i386 package that I wanted to install on an amd64 machine. In my case, I can create an i386 package on the i386 machine. It is a non-binary package so seems like there should be no issue.
Answer: Troubleshooting
When a package fails to install you can troubleshoot by using the Debug switch. It takes a bitfield to determine the level and subject-matter. A value of D=7777 will show everything. For this problem we know we are specifically interested in conf files so we can use D=220.
sudo dpkg -D=220 -i Foo_1.0-1_all.deb
Your output may show something like the following:
D000200: conffderef in='/etc/init/Foo.conf' current working='/etc/init/Foo.conf'
D000200: conffderef nonexistent
D000020: deferred_configure '/etc/init/Foo.conf' (= '/etc/init/Foo.conf') useredited=1 distedited=0 what=2002

The key clue is useredited=1. By default dpkg will not replace user-edited configuration files. Manually deleting a .conf file counts as editing it, so it may come as a surprise that dpkg will not replace the missing file. It may be doubly-surprising for those experienced with installing services on other operating systems that an Upstart Job is treated as configuration.
Force missing conf installation
dpkg has a handful of force options. You can force the replacement of the missing .conf file as so:
sudo dpkg -i --force-confmiss Foo_1.0-1_all.deb
There are other force options for similar scenarios; check the manual page or use dpkg --force-help for details. These options should be used with care, especially for 3rd party packages.
Package Dev/Test Cycle
In the development of a .deb package (e.g. for an Upstart Job) you'll be installing and removing the package many times. You'll also possibly be tweaking the .conf file manually at times. By default dpkg -r (or apt-get remove) will not remove the .conf file. (So surprisingly the upstart job remains while associated binaries may be gone.) For this you must use the purge option. Therefore to test completely removing and reinstalling the upstart job, you can do the following:
sudo dpkg -i Foo_1.0-1_all.deb
# testing...
sudo apt-get purge Foo

And now that you know about the force and debug options you can apply those as needed.
References
See the thread Bug#1198: dpkg silently fails to install a file:

Removing the file counts as `editing' it, because for many
  configuration files the absence of a file is meaningful.

Manual page for dpkg

Upstart Job (.conf) Fails to Install


Weird smell from electrical disconnect box when appliance is on

Question: I have a 240v, 48amp (60 amp breaker, 6 awg NM-B wire) car charger outside that has a disconnect inline and last night I noticed a really weird smell in the room the wires to out to the charger from. I tracked it down using my nose to the disconnect box (or the wires leading to/from it) and at this point it was pulling 48 amps because the car was charging. I inspected the area and didn't notice any melting but since it was raining I didn't want to open the box outside to look in. I lowered the amps to 32 via the car and the smell appeared to dissipate and this morning the smell was gone. I also noticed a small humming sound from the disconnect outside at the same time.
It's a cheap disconnected:
https://www.homedepot.com/p/GE-60-Amp-240-Volt-Non-Fuse-Metallic-AC-Disconnect-TFN60RCP/100674085?cm_mmc=Shopping%7CG%7CBase%7CD27E%7C27-8_CIRCUIT_PROTECT._DEVICES%7CNA%7CPLA%7c71700000034238981%7c58700003943782709%7c92700031956831784&gclid=Cj0KCQiA28nfBRCDARIsANc5BFA1htTEn9RLX9o9ot_7y6wyo4sEOySek6WKOL1FbEizxiqgrYyPfHgaAqE_EALw_wcB&gclsrc=aw.ds
But it's rated to 60 amps. Maybe something is lose, what would cause a smell/buzz? What should I check first?
Answer: Both of the things you report - the smell and the hum - are very likely indications of a bad connection or bad contact in the disconnect.
Bad connections and bad contacts generate heat, the heat can damage the insulation of the wires, and even cause a fire.
I'd leave that disconnect off and if possible turn of the breaker for the circuit until it can be checked.  You'll probably wind up having the disconnect replaced, hopefully the wiring can be re-terminated without replacing it.
Comment: Yeah, when it was installed I remember thinking how flimsy the screw terminals looked in that disconnect box and how I should have just paid for the extra $10 for the better one.

Side question 1. Is the reason it generates heat is because there is less wire to carry the high current so more current is flowing through the wire generating heat?

Side question 2: Is this why torque specs are important when connecting wires?
Comment: @RyanDetzel - re 1. -  the heat comes from the resistance in the wire;  smaller wires have higher resistance than larger wires, and less surface area to dissipate the heat.  Bad connections have high resistance and heat is generated at the high resistance spot, which cal lead to galling, softening the wire so it doesn't make good contact, and the connection gets even worse.  re 2. - yes, the torque spec insures it's tight enough to make a good connection, given the terminals and wire and the components are all sized and rated for the load.
Answer: One thing I find with larger wire sizes even though you torqued the lugs the wire is probably still loose. When I tighten larger sized wires I take them to torque specified then back off and take them down again while watching the screw position if I get more of a turn I back off and tighten again. This allows the wires to shift and get a true torque. On larger wires I grab the wires after torquing and wiggle them this allows them to move around and then re torque. I would suspect your connections are loose as this is quite common if the above steps were not taken on larger stranded wire.
Answer: NEC Article 625.42 states that the equipment rating of an Electric Vehicle Charging System shall be rated continuous duty. So 48 x 1.25 = 60A and that is the top end of your circuit which you have installed to charge your vehicle. For me that is a little too close too maximum allowance of your circuit to make me feel comfortable with it.
Since your circuit is already installed, the best thing we can do with it is to use what is existing. I would shut off the supply breaker and then open your disconnect and look for anything that is damaged. Also it wouldn't hurt to check your connection at the breaker. Then if you need to replace the cheap (and yes it is cheap) AC disconnect and replace it with a minimum 60A standard NEMA 1 disconnect, maybe even a 100A, and maybe even a heavy duty.
If you were asking me as a contractor, I would stay with the #6 copper conductor (it is copper isn't it?). Install a 70A breaker which is allowed by NEC Article 240.6(A), and used a general duty NEMA 1 100A Disconnect at the charger. This would protect me and you of the problem you now have.
I understand if you do not want to change out your circuit, but I would also always run your charger at the 32A setting. Unless for some reason you need a quick charge. Also if you want to stay on the safe side you might invest in a infrared thermometer and check the heat output on the circuit after charging a while and see if any of the connections at the cord cap, disconnect and breaker are generating any unusual heat. Say no higher than 60C or 140F. It really wouldn't hurt to schedule a routine to check the heat output to make sure everything was operating correctly.
Stay safe and good luck.
Comment: Great info, thanks! I can drop the charger down to 40A, 36 or 32. Would 40 be okay for continuous use or should I drop it even further?
Comment: 40A would be fine.
Answer: I use the word "cheap" a lot to refer to the dreck found on Alibaba, Amazon Marketplace etc. I'm surprised to hear it associated with GE, one of the finest names in the industry.  But yeah, that $7 shutoff is pretty cheap, with its plastic-bodied pull tab for a shutoff. Clearly not meant for daily use.   Nonetheless, you don't have to wildly derate GE stuff like you do for cheap Cheese junk - if it says 60A it should be good for 60A (48A continuous).  You can run GE equipment on the brass.*
I would shut off power at the main panel, then pull that pull-tab.  If it is warped, or comes apart in your hand, then -- well, do this sometime you can afford to be without the charger for a day or two!
One thing the industry has learned through experience is that lug connections are sensitive to torque setting.  Recent Code changes now require everyone to use even torque screwdrivers for the little stuff. And a lot of elecricians resent this...  somehow a mechanic's beam foot-pound torque wrench is $30, but a screwdriver sized inch-pound torque wrench is $85.  So some electricians (and most handymen/homeowners) just don't use torque wrenches.
Given the amount of plastic in this thing, it wouldn't surprise me if the heat was coming from a loose connection at a lug, it's making a fairly considerable amount of heat, and that is traveling up the bus bars to scorch the plastic.   Thank God it's a metallic box!
It might be fixable by opening up the box, cleaning up wire ends and retorquing, and likely the torque required will be just within the working range of a mechanic's torque wrench, so ask your neighbors.  However if the box is damaged, this will be your opportunity to get the better box.
Just don't confuse "more features" with "better".  You don't need a circuit breaker at that location.  I would say a higher ampacity would be "better".

* "On the brass" is an old 1900 era streetcar term for "to the floor".  Meaning you have pushed the power controller onto the brass stop. Fair chance if you find a power controller in a museum, it'll have the familiar GE logo.
Comment: GE may have BEEN a fine name, but their quality has deteriorated a LOT lately, as evidenced by their being basically non-existent now. Be that as it may, this entire genre of devices, pull-out disconnects for AC units, is purposely designed to be as cheap as humanly possible, reflecting the state of the residential HVAC market. I don't care what brand you use, they are all built as cheaply as possible and are all subject to corrosion etc. 48A or not, if the connections are corroded, they will over heat.
Answer: That is also a "pull put" disconnect device, normally used for outdoor Air Conditioners. There are blades stabbing into sockets that make the connections, then there are fuse holders connected to those blades. That blade / socket / fuse clip scenario is notorious for getting corrosion that increases resistance and burns up. You get what you pay for...


Purchasing and resetting neuromods

Question: In Prey you can find Neuromods to purchase upgrades in a skill tree.
There are 3 categories: Scientist, Engineer and Security. All of these have a lot of perks and require multiple neuromods to purchase skills.
I have 2 questions about this ability system:

Are there enough neuromods in the game to purchase all the skills available?
Can I reset my neuromods (early) somehow if I accidentally purchased something wrong.
Answer:
No. You will unlock 3 more categories later, you can't find enough neuromods to get all skills. You will be able to craft neuromods later though.
Not as far as I know. I have not found any way to reset your skills.
Comment: Small note: according to the plot removing the neuromod results in loss of memory. But it is impossible to erase player memory, so removing neuromods is impossible in terms of gameplay mechanics.
Comment: While it's good to save up a few and plan your trek down the tree, don't be like me and horde them so that you end the game with 22 sitting in your inventory!

Purchasing and resetting neuromods


How to connect to Azure VM SQL Server Analysis Service Instance using a Developer Computer

Question: I need a way to connect to an SQL Server Analysis Service default instance on Microsoft Azure Virtual Machine from my developer computer at home. I understand that i can only connect to Analysis Service using Windows Authentication and i haven't been able to figure that out. However, i managed to connect to the SQL Server Database Engine using SQL Server Authentication.
This is how i have Azure environment is setup:

To setup my connection to SQL Server Database Engine using SQL Server Authentication, i created an Endpoint in Microsoft Azure Management Portal with port 1433 for private, and a random port for public. I have done the same process for Analysis Service on port 2383 but still no luck. Without this connection, i don't think i will be able to deploy BI Cubes.
Here is the Link to the blog that help with this.
How can i setup my Virtual Machine so that i will be able to connect to Analysis Service using SQL Management Studio and or Visual Studio 2013? Any help or suggestions will be appreciated.
Comment: I guess i will just have to develop my apps within Azure VMs, since i can have my VMs talk to each other using Active Directory, it doesn't look like i will get help to this.
Answer: Because Analysis Services works with AD accounts, as your developer machine is not on the same domain as the VM running Analysis Services, you will need to use the runas tool with the /netonly parameter to run the applications such as Visual Studio or SQL Mgmt Studio so that you can be authenticated correctly.
When I need to do this, I create a shortcut on my desktop with the command as follows:
runas /netonly /user:mydomain\myusername "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe"

or
runas /netonly /user:mydomain\myusername "C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe"

When you run the short cut you will get a command prompt that will ask you for the password for the account you are running as and then the program will open.
From there you can use it normally
Comment: Thank you for your solution! Do you know how to deploy solution using VS 2019? I get error: "The server could not be contacted."
Answer: You still can process cubes in your vm's ssas instance.

Step 1 : Build your Cube's project in your local system
Step 2 : open your project location and copy .sadatabase
Step 3 : create xmla script using analysis service deployment wizard
step 4 : open the script in ssms and execute


Can new construction recessed lights be installed in inaccessible ceilings?

Question: In California, does code allow me to install recessed lights in a ceiling which which be inaccessible once closed up? (Such as between floors)
I have seen it done many times but I was thinking that the can contains a junction box, but that box will be inaccessible once finished. Doesn't that create a code issue with an inaccessible junction?
Is there a specific code exception which allows it in this case? Or am I thinking about it incorrectly?
Answer: Yes -- the junction box of the recessed light must be accessible after installation per the design of the recessed light. The typical design I have seen to accomplish this is that the recessed light's "can" is attached to the recessed light's junction box by flexible cable. The "can" may then be pulled down after installation through the opening in the drywall to allow access to the junction box.
Here are some before and after pictures of a new construction recessed light I have left over from my remodel.
Comment: I have never realized that cans open like this. I'll check on mine and report back.
Comment: What do you know..  mine have a few screws which allow access to the jbox. I've put up dozens of these and never knew!


ActiveRecord how to update model with the count of a related 1 to n model

Question: I have two models with a 1 to n relation in between:

Book 1 <-> n Page

I do want to make a update statement on all Books (about 300'000). The Book model has a column interesting_pages_count, which need's to get summarized out of all Pages which interesting attribute is set to true.
Is this possible in one Statement?
Thanks,
Makrus
Answer: It is possible, at least in PostgreSQL:
UPDATE books SET interesting_pages_count = (
  SELECT count(*) FROM pages WHERE pages.book_id = books.id AND interesting = true
) FROM pages WHERE books.id = pages.book_id;

Answer: You could try with
Book.update_all({:field => value}, where_condition)
or with a plain SQL query.
Answer: Well, only one statement is really ambitious, but if you define this method on your Book model:
def count_interesting_pages
  self.pages.inject(0) { |result, page| result += 1 if page.interesting?}
end

Then you can do this:
Book.all.each {|b| b.update_attribute(:interesting_pages, count_interesting_pages)}


Getting contrast color to a given color in RGB or ARGB or HEX

Question: I am looking for a stable way to find a contrast/inverted/opposite color to a given one.
Application of this is to find best possible color for foreground to give background.
Comment: You could try the complementary colors. So if you have $c \in [0,1]^3$ then $(1,1,1) - c$. You can use luma to control luminance.
Answer: I read this in a magazine article probably 25 years ago. I don't recall the full derivation, but they said to take each component (red, green, and blue) and invert the high bit of the color. In a C-like programming language, you could do:
 component = (~component & 0x80) | (component & 0x7F);

This can be simplified to:
component ^= 0x80;

for  a single component or to:
component ^= 0x80808000;

if you want to do 4 components at once (and don't affect the alpha).
This assumes your components are 8-bit values. This avoids the problems you get with the middle values if you simply invert them. In that case 127 becomes 128, and vice-versa. But with the above solution, 127 becomes 255 and 128 becomes 0.
Comment: This is a great way, but as i get closer to 127 in R or G or B values, lower is the difference between colors
Comment: "component = 0x80 ^ component;" should do the trick more succinctly, with a trivial extension to all three components in parallel via 0x808080.
Comment: @Strader I don't understand what mean. The difference is a constant 128.
Comment: Found it to be better way to manually lower the alpha of background color for better contrast and calculate inverted one using full alpha


JQuery Mobile, alternating images breaks "Back" button

Question: For a JQuery Mobile site, I need an new image to load on page navigation. The image only displays on the homescreen.
So for example, you load m.smellyeggs.com which has image_A.png as the top banner. You select menu item 1, then press back and now image_B.jpg is showing as the top banner.
I was able to get it working using cookies. I get an array of potential images, then use cookies to traverse the array. This works on page reload, but any cache loading of a page (e.g. href="/" or using "Back" in mobile or the browser) would not call the javascript. Thus the image would not actually alternate.
<code>var images = new Array();
<% banner_mobile_uris( controller.conference ).each do |url| %>
  images.push( "<%= url %>" );
<% end %>

inc_banner_cookie();
load_banner();
</code>
To fix this, I use the following code, which deletes the image, forcing an image refresh whenever the homepage is loaded.
<code>$( 'a' ).live( 'click', function( ev ){
  var banner = $('#m_banner').load(htm_file);
  banner.empty().remove();
});
</code>
This code removes the "Back" button from any subsequent page navigation that occurs.
Well that's unacceptable! Any advice on a better approach? I'd rather not implement my own "Back" button unless that is absolutely necessary.
Thanks for reading (and hopefully helping ).
Comment: post the full code of your jquery mobile html, i have to see your structure
Answer: The answer lies in using pageinit to detect successful JQuery Mobile page loads...
<code>$(document).on('pageinit', function(){
    inc_banner_cookie();
    load_banner();
});
</code>
This will not disable the back button. And cause image reloads on any type of page navigation. Well almost any type...
As it turns out, this appraoch is fragile when AJAX redirects occur, and subsequent pageinits may not work. See my question concerning this issue.


Alternative to quantmod for bid/ask info

Question: Previously I used this to get closing bid/ask prices:
library("quantmod")
getQuote(Symbols = symbols,
           src = "yahoo",
           what=yahooQF(c("Bid","Ask", "Volume")))

Now I get the error:
Error in .yahooSession(TRUE) : unable to get yahoo crumb

> packageVersion('quantmod')
[1] '0.4.24'

Reading this it appears that Yahoo! is no longer an option with quantmod.
src = "av" doesn't return bid/ask info.
Neither does Tiingo
Is there a free solution for R users for less than ten quotes per day for bid/ask info?
Comment: also check this: https://github.com/joshuaulrich/quantmod/issues/393
Comment: looks like there is this: https://data.nasdaq.com/tools/r
Comment: As @Mark suggested "Yahoo unhappy about crumbs #393" got it working again.
Answer: quantmod is working again after running:
remotes::install_github("ethanbsmith/quantmod@fix_404_handle_getquote_gdpr_errors")

Source: ethanbsmith, Github
Comment: This has been merged to quantmod/main. No need to install from the fork.


Which side should an illustrative picture be in an online calculator? Why?

Question: I have designed two options, but would like to get to know which one would you prefer, and why?
Option 1:

Option 2:

On the basis of your answers and comments, I have made up a new wire. Answering the question: the picture is only an illustrative thing. The webpage uses illustrative photos of product, services, so this page would be kind of empty without a photo. The one on the wireframe is not the final either. - and maybe instead of the 4 radio buttons in the middle there could be a slider.
Option 3.
Answer: If the picture doesn't help them choose the options, it shouldn't be there at all...
If it does help (and the one above is a placeholder), then put it on the right as 'additional information' and clearly indicate which decisions it's aiming to help with. Split vertically with whitespace if necessary and align with the questions on the left so that any association is clear.
Answer: I prefer the 2nd with the text on the left. People read left to right and I feel the image on the right is just getting in my way, not so much with the 2nd version.
I'm guessing this is just a mockup but I'd defiately try and get a bit more whitespace between the radio buttons.
Also does that image need to be that big? do you even need it. Just feels like its getting in the way and not adding anything.
Comment: +1 for the fact that it's not just the image but the layout of the options that matters. Image and textual content need to work *together*
Answer: Option 1 is the correct one.
It is not question of preferences, but neuropsychology. Images are processed easier by right hemisphere, text by the left one. Optic nerves are crossed, so everything what's on the left side of perceived picture goes to the right hemisphere and what's on the right side goes to the left hemisphere.
To be brain-friendly in layout such as yours, you should keep image on the left.
It's widely accepted rule.
Comment: A source would be nice...
Comment: Quick study to proving my point: [Psychology of the consumer..](http://books.google.pl/books?id=SGUZdhF4pyAC&pg=PA166&lpg=PA166&dq=psychology+of+advertising+image+right+hemisphere&source=bl&ots=5KiRKD2_Pu&sig=RmbC4b1Ph_QyxTxSfhZ95UmmuQQ&hl=pl&ei=TF_nTs3UI4eXhQeOweW1Cg&sa=X&oi=book_result&ct=result&resnum=2&ved=0CCQQ6AEwAQ#v=onepage&q&f=false). There were recent revisions of those studies - I just can't find accurate link. Anyway if you're studying Cognitive Psychology, or HCI in Europe - can't miss it. It's also widely used in Advertising and Interaction Design.
Comment: Thanks, interesting read (and no, I'm not studying Cognitive Psychology or HCI ;-))
Answer: This depends on the relationship between the image and the calculator. Does the user need to view the image before using the calculator, or does the user need the image to add context?
If the image is a prerequisite to using the calculator, it should be on the left and large as in the first option.
If the image is additional information and not the first item to be viewed following the header, it should placed on the right (as in option 2) and be smaller (as in option 3).
If neither of the above are true, remove the image.


SQL Strategies for detecting what is causing a lock / long query

Question: I have a query against an Azure SQL database that occasionally results in the following:

If there aren't many users, this doesn't happen.  But if there are, this happens regularly - the query takes a very long time to complete and my DTU percentage is almost off the charts.
How do I determine what is causing this?
Some general info:

I'm using dapper as an ORM in some portions of the application
I'm using EF in other areas
When it hangs, it hangs for >30sec.  Rarely is 1s < time < 30s
The dapper query that hangs is below, where XXXX is a list of about 2,500 item IDs in both cases:
It seems like users with a small set of XXXX Ids don't EVER hit this issue.  The retrieval of XXXX is not ever an issue - but using a large XXXX seems to aggravate performance sometimes.
[User] is indexed on UserId (PK), and LastOnline

Code:
 select USERID, USERNAME, NICKNAME, BIRTHDATE, LASTONLINE
  from [User]
  where AccountDisabled <> 1 and Banned <> 1 and
     (ABOUTME <> '' OR ProvidedPhoto = 1) and
     USERID <> @userId  and ProvidedPhoto = 1  AND
     USERID IN (-1)  AND USERID NOT IN (-1)
     AND USERID NOT IN (XXXX) UNION ALL
          select * from (select USERID, USERNAME, NICKNAME, BIRTHDATE, LASTONLINE from [User] where
                AccountDisabled <> 1 and
                Banned <> 1 and (ABOUTME <> '' OR ProvidedPhoto = 1) and
                USERID <> @userId  and ProvidedPhoto = 1  AND USERID NOT IN (-1)
                AND USERID NOT IN (XXXX)  AND USERID NOT IN (-1)
                order by LastOnline asc offset 0 rows fetch next + 20 rows only)
     as dt

I'm a bit new to the world of performance forensics... any advice would be awesome.
Update - Execution Plan:
Comment: Does the mapper map to a stored procedure with parameters or does it generate sql on the fly?
Comment: It generates SQL - https://github.com/StackExchange/dapper-dot-net
Comment: As you already mentioned, it generates SQL, so, first, it is not pre-compiled as stored procedures are. Hence, it tends to take more time when compared to a stored procedure. Second, Could you please share Indexes of table [User], if any. Third, try replacing USERID NOT IN with NOT EXISTS. It should help.
Comment: @AkankshaSingh thanks.  User is indexed on PK UserId and LastOnline.
Comment: @AkankshaSingh I'm having trouble converting NOT IN with NOT EXISTS.  Bit of a SQL novice here.
Answer: Here are a few things you can try:

See if you can create a stored procedure to return your required list by passing @UserID as parameter. Call this stored procedure instead of generating query every-time.
Replace NOT IN with NOT EXISTS as below. First check if this helps. It very much depends on the values in USERID column.
SELECT USERID,USERNAME,NICKNAME,BIRTHDATE,LASTONLINE
FROM [User]
WHERE AccountDisabled <> 1
AND Banned <> 1
AND (
ABOUTME <> ''
OR ProvidedPhoto = 1
)
AND USERID <> @userId
AND ProvidedPhoto = 1
AND USERID IN (- 1)  --How will these two conditions ever be true together?
AND USERID NOT IN (- 1) --Be sure about your conditions
AND NOT EXISTS (SELECT USERID FROM [USER] U2 WHERE U1.USERID = U2.USERID)

UNION ALL

SELECT *
FROM (  SELECT USERID,USERNAME,NICKNAME,BIRTHDATE,LASTONLINE
FROM [User] U1
WHERE AccountDisabled <> 1
AND Banned <> 1
AND (
    ABOUTME <> ''
    OR ProvidedPhoto = 1
    )
AND USERID <> @userId
AND ProvidedPhoto = 1
AND USERID NOT IN (- 1)
AND NOT EXISTS (SELECT USERID FROM [USER] U2 WHERE U1.USERID = U2.USERID)
-- AND USERID NOT IN (- 1) WHY AGAIN??
ORDER BY LastOnline ASC offset 0 rows FETCH NEXT + 20 rows ONLY
) AS dt

You may also think of creating NON-CLUSTERED Indexes on the other columns you have in WHERE clause. Could you please show execution plan of the query as well? (How: In SQL Query editor, press CTRL+M and then execute your query. You will get an execution plan along with the results.)
Comment: Updated!  Thank you so much for this - trying now.  Also - I'm a bit confused - the XXXX was literally a list of Ids, like this: `USERID NOT IN
(9590, 10916, 11231, 9421.... 2,500 items... 2283, 4422)` - I don't see the mapping here.
Comment: If theses IDs are list, put them in a temp table before coming to this query. And then write the NOT EXISTS query over that temp table.


Silverlight Isolated Storage and Host Name Redirects

Question: I have a site that serves up a pretty substantial Silverlight RIA and it makes use of IsolatedStorage.  The SL app is served up from https://www.site.com/Application (MVC View that hosts the SL object tags, etc).  It is also served up from https://site.com/Application.  The problem inherent in this is that this will create two separate IsolatedStorage application because the two host names are seen as different.
My first thought was to just serve the XAP file from an absolute link instead of a relative one:
<code><param name="source" value="http://site.com/ClientBin/app.xap" />
</code>
But this seemed to cause weird problems when the page was served from www.site.com and the xap was served from site.com.
My next thought was to leave it a relative link, but always do a permanent redirect (301) from www.site.com/application -> site.com/application to ensure that it is always served from the same location.  Any thoughts or suggestions?  Has anyone seen this?
Answer: You get "wierd problems" because the host page is served from a different site than the XAP hence access to the HTMLPage and attempts to call Javascript will fail.
The use of 301 doesn't change these conditions so you still have problems.
You will need to decide which site you want the application to run from and perform a redirect on for the entire page.
Personally if I were to build a substantial RIA application I would only allow it run from one site "site.com".  I would create a "www.site.com" which redirects to the "site.com" that never actually serves any content just redirects.
Comment: to be clear the 301 was for the whole page not just the xap file - but  fundamentally I do like the whole site redirect as well.  Thank you.


Nothing works! jquery conflict magento

Question: I am trying to use jquery UI based transition sliders on my homepage. I tried different jquery plugins but I always get an error in the console : jQuery is not a function or some function error related to jQuery . Plugins i have tried are Lof JSliderNews 1.0,featured-content-slider, etc..
Even after following several posts on the web , iam not able to make the plugin work at all. Jquery part doesn't work. I have used carousels and other plugins with jquery.noConflict but this time nothing works!
Here's what iam doing:
jQuery.noConflict();

jQuery(document).ready(function(){
    jQuery("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
});

I also tried replacing all $ with jQuery in the included scripts but that too doesn't work in magento. Please help, i need to finish the project soon
Answer: Have you tried putting all the jQuery stuff into a function and map the window.jQuery variable as an argument? Like so:
(function($){
  //... do your jQuery thing here
})(jQuery);

BTW: "jQuery is not a function" might also be a hint that you forgot to load the jQuery library into your project.
Comment: I resolved it. It was just that jquery was being called twice!! Such a dumb one, couldn't figure it out earlier
Comment: oh... too easy to find the mistake I guess  ;-)
  Glad you found it
Comment: It doesnt work! The plugin loads now but jquery function still does not work. Here is what i get in console TypeError: jQuery.easing[jQuery.easing.def] is not a function . Is there something I need to change in magento itself?
Comment: same thing as above i guess :-)   Did you load the jquery easing plugin? As I'm not familiar with magneto, I can't tell you if magneto is making trouble. Only thing I know is the jQuery-errors in the console (as I am quite familiar with errors ;-))
Answer: Do you have "JS file merging" enabled? If yes, try to disable it, clear your cache and try again. It helped me once when I had a smiliar issue.
Regards

Nothing works! jquery conflict magento


Comparing OrderDict of DataFrames

Question: I am facing a comparing problem, this is my code:
import pandas as pd
from collections import OrderedDict
from pandas.util.testing import assert_frame_equal

df1 = {'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
     'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd']),
    'three' : pd.Series([1., 2., 3., 4., 5.], index=['a', 'b', 'c', 'd','e'])}

df2 = {'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
     'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd']),
    'three' : pd.Series([1., 2., 3., 4., 5.], index=['a', 'b', 'c', 'd','e'])}
od = OrderedDict()
od['a'] = pd.DataFrame(df1)
od['b'] = pd.DataFrame(df1)
od['c'] = pd.DataFrame(df1)
od['d'] = pd.DataFrame(df1)

od2 = OrderedDict()
od2['a'] = pd.DataFrame(df2)
od2['b'] = pd.DataFrame(df2)
od2['c'] = pd.DataFrame(df2)
od2['d'] = pd.DataFrame(df2)

test = assert_frame_equal(od, od2)
print(test)

I have 2 OrderedDict made of pandas DataFrames and I would like to analyze if the single elements inside the DataFrames are equal.
I found the function assert_frame_equal that works perfectly when it comes to compare 2 DataFrames, but gives this error with OrderedDict:

AssertionError: DataFrame Expected type class
  'pandas.core.frame.DataFrame', found class
  'collections.OrderedDict' instead

Is there any solution or workaround to this? Take into account that I necessarily start from an OrderedDict and unfortunately I cannot change that.
Thanks so much in advance any help/hint on this issue.
Answer: Look if this helps. Using zip()
for ord1, ord2 in zip(od.values(), od2.values()):

    print(assert_frame_equal(ord1, ord2))

    # or you can also use
    print(ord1.equals(ord2))

Hope this helps
Comment: The values in `od` and `od2` are dataframes, so I don't think the constructor needs to be called. `k` and `v` are shorthand for `key` and `value`, so using `k` to refer to `od.values()` may be confusing for some.
Comment: @Evan I agree with you.
Answer: Something like this?
for df1, df2 in zip(od.values(), od2.values()):
    test = assert_frame_equal(df1, df2)
    print(test)

Returns:
None
None
None
None

Also, you are calling your initial OrderedDicts df1, which might lead to some confusion later on. By convention, df is short for DataFrame.
You can also use equal, per What is the difference between `assert_frame_equal` and `equals`
for df1, df2 in zip(od.values(), od2.values()):
    test = df1.equals(df2)
    print(test)

Returns:
True
True
True
True

Comparing OrderDict of DataFrames


Adding corrugated plastic panels adjacent to existing roof

Question: I have a 30 x 15 stick built shed with composition shingles over 1/2" sheathing. I would like to take 12 lineal feet off the end, remove the roofing and sheathing and install corrugated plastic to turn it into a greenhouse. How do I make that joint between the remaining composition roof and the corrugated plastic weatherproof?
Thanks
This is what I'm going to try. Any comments would be appreciated.
Comment: Did you ever get this resolved? If so, please give a check-mark to the answer that helped you the most, or write up your own answer explaining what you did to get it fixed and give yourself a check mark. That will help others with this kind of problem know that this has a resolution and is a good place to look for their answer.
Answer: I'd think you'd abut the two roofing types and overlay a flashing, lapping onto each 6 inches or more. The outcome would be similar to any hip or ridge.
Answer: Plastic does not last more than a couple years. I have used about 3 types on my shed roof all failed. I "bit the bullet" and put in 1/4 plate glass , 2 X 4 ft.  panels. They have survived a hail storm which damaged our composition roof so badly that the insurance company replaced it.


Sound Settings won't let me switch Bluetooth headset to A2DP

Question: This issue has been cropping up for a while.  Sometimes my BT headset works fine, and other times I can't switch the output to A2DP.  When I go into sound settings and try and switch from HSP/HFP to A2DP it reverts the output back to the speaker.  There seems to be no way to choose A2DP.
I'm attaching a gif below to show this behavior.
GIF
Answer: i have this problem as well , i found a pattern that works.
connect headset , try to change to A2DP , disconnect headset , reconnect headset , change to A2DP , it will then work
Comment: Yeah, I found that pavucontrol as well seems to work.  Not sure what order of commands forces it eventually to connect through A2DP.  It'd be nice if this "just worked"™.
Comment: it used to in 15.10 with the same hardware , hopefully this regression will be short lived
Comment: this behaviour has changed in 18.10 where is seems to be able to remember settings properly


CSRF token mismatch when laravel used in multiple system

Question: I'm trying to migrate laravel from version 5.2 to 6.0 , but i have different folder for different version in same local wamp server . I'm using same database file both version . But i'm always getting csrf token mismatch and page expired . Please give me some good solutions for this.
Comment: So do you have different vhosts for the different versions or do you just use "localhost" for all those projects? I'd advice setting up vhosts with different domain names (i.e. "la52.local", "la56.local" etc.) for every project you have. Or use `php artisan serve` in the different folders
Comment: have you cleared your cookies?
Comment: open both url in different browser ( one in chrome and other on firefox ), let us know your observation.
Comment: I'm using different vhost for each version
Comment: Using same DB file for both versions
Comment: Which session driver are you using?
Answer: This problem comes from the CSRF token verification which fails. So either you're not posting one or you're posting an incorrect one.
Use {{ csrf_field() }} in your form
OR
Add Your Route URL into the Http/Middleware/VerifyCsrfToken.php file.
Example Like this. If your ajax route Route::post('searchsubmit','User\UserController@ViewSearchList')->name('searchsubmit');
Http/Middleware/VerifyCsrfToken.php
protected $except = [
       'searchsubmit',
    ];

In Your Case You need to add login like this
protected $except = [
           'login',
        ];

Comment: `php artisan config:cache` also runs `php artisan config:clear`. And caching config on DEV systems is not advised
Comment: @kerbholz finally someone else who gets that point about not needing it cached on development :) drives me crazy everytime someone says to cache it
Comment: `cache:clear` is for flushing your cache store, it has nothing to do with the configuration or anything like that
Comment: this is a good solution but i dont recommend that. you should put csrf token for all your forms. maybe php clear all config and caches help you. you can also check @csrf instead of csrf_token()
Comment: i used all above command , my problems is when another guys use same laravel project from my system in his system from networks this problems occur.
Comment: @aliFalahati I'm using csrf_token in all forms , for repeatation of code i'm using csrf_token in master blade page .


Emacs suspends right after starting in bash

Question: (Possibly) important info:
Ubuntu version - 16.04 LTS
GNU Emacs version - 24.5.1
GNU bash version - 4.3.42(1)-release
I'm trying to edit my apache2.conf file in /etc/apache2/, but using
sudo emacs -mm apache2.conf &
to start Emacs doesn't work. In particular, it doesn't ask me for the root password, and the process just suspends immediately after starting. bg doesn't work either because the process just suspends again.
edit:
When starting Emacs as a foreground process instead, I'm asked for the root password, and the process doesn't suspend.
What might be causing this behavior?
Answer: This is because sudo meanwhile not works for many GUI based applications, use gksudo instead which you will find in the package gksu. So example:
sudo apt-get install gksu
gksudo emacs -mm apache2.conf &

Happy hacking.


What is the fastest elementary proof of $A_n≥G_n$?

Question: The $A_m≥G_m$ has a whole lot of proofs, the large majority I've seen by induction. Currently the quickest one that I've seen is the following: (note $A_n=\frac{a_1+a_2+a_3+...+a_n}{n}, G_n=\sqrt[n]{a_1a_2a_3...a_n}$ where $a_k$ is a positive real number).
Consider the geometric series: $1+(1+x)+(1+x)^2+(1+x)^3+...+(1+x)^{n-1}=\frac{(1+x)^n-1}{x}$ for all integers $n≥0$.
If $x≥0$ then clearly $1+(1+x)+(1+x)^2+(1+x)^3+...+(1+x)^{n-1}≥n$ which we then substitute into the expression to get $(1+x)^n≥1+nx$, if $-1≤x<0$ then $1+(1+x)+(1+x)^2+(1+x)^3+...+(1+x)^{n-1}≤n$ which then substitutes re-arranges to $(1+x)^n≥1+nx$ again, noting that the sign flips when the $x$ in the denominator is multiplied across because it is assumed to be negative.
Hence we have shown $(1+x)^n≥1+nx$ is true for $x≥-1$. Then for $n=n+1$ substitute $x=\frac{A_{n+1}}{A_{n}}-1$ to derive the result $\left(\frac{A_{n+1}}{A_{n}}\right)^{n+1}≥\frac{a_{n+1}}{A_n}$.
The proof then finishes with induction with the assumption being $A_k≥G_k$ the the $k+1$ step being:
$LHS=G_{k+1}$
$=\sqrt[k+1]{a_1a_2a_3...a_{k+1}}$
$=(\sqrt[k]{a_1a_2a_3...a_{k}})^{\frac{k}{k+1}}\sqrt[k+1]{a_{k+1}}$
$≤(A_k)^{\frac{k}{k+1}}\sqrt[k+1]{a_{k+1}}$ by assumption
$≤\left(\sqrt[k]{\frac{A_{k+1}^{k+1}}{a_{k+1}}}\right)^{\frac{k}{k+1}}\sqrt[k+1]{a_{k+1}}$ using the proved inequality rearranged for $A_k$
$=A_{k+1}$ which completes the proof.
I was wondering what is the absolute quickest way (the least amount of steps that can still be followed without any extra work between those steps) that I can prove $A_n≥G_n$ from the ground up (maybe without induction)? That is, not using any other inequality results without proof, (this proof used Bernoulli's inequality but that was relatively quick to prove) and not using any advanced techniques (to me) such as matrices or something.
Comment: It depends on the meaning of "fastest".
Comment: @markvs A proof requiring the least amount of steps that can still be followed without any extra work between those steps.
Comment: "can still be followed without any extra work between those steps." is even more subjective. Can be followed by whom?
Comment: @markvs A high-school student with a reasonable amount of exposure to maths, enough to want to ask this question out of curiosity
Comment: You seem to be unable to formulate precisely. What is "reasonable amount of exposure"? I learned this formula and a proof when I was 14. I was in a middle school. There were more than 25 students in my class and there were millions of students    in my country who learned it at the same time.
Answer: $\ln$ is concave then :
$$\ln \dfrac{a_1 + \cdots + a_n}{n} \geq \dfrac{\ln a_1 + \cdots + \ln a_n}{n} = \ln \sqrt[n]{a_1 \cdots a_n}$$
And we are done.


$\Gamma(1/2)$ and the Euler reflection formula

Question: With Euler's reflection formula we can show that $\Gamma(1/2)^2=\pi$.
Why can't $\Gamma(1/2)=-\sqrt \pi$  ?
Comment: Because $\Gamma(1/2)$ is the integral over $(0,\infty)$ of a positive function, so it must be positive
Comment: The defining integral has a positive integrand and is evaluated over $ \ (0, \ +\infty) \ $ -- could that be negative?
Comment: because $\ln \Gamma(x)$ is convex
Answer: $$
\Gamma\left(\frac 1 2 \right) = \int_0^\infty x^{(1/2)-1} e^{-x}\, dx > 0.
$$
If you integrate a function whose values are positive over a positively oriented interval, then the value of the integral is positive.
("Integrating over a positively oriented interval" means $\displaystyle\int_a^b$ where $a<b$, as opposed to $\displaystyle\int_a^b \text{ where } a>b$.)