text:
Q: CSS not loading on Wordpress / Google App Engine I am having trouble loading some css/js from wp-content, wp-includes on a Wordpress site I have hosted on Google App Engine.

I am using the same app.yaml that is suggested on Google App Engine's Wordpress article. I also tweaked the rules to see if they can accommodate the ver=.*, but no avail.
Any suggestions?

A: You need to define static folder in app.yaml file
In my case I have a static folder which contains all js, css and images.
Here is my folder structure
static
 - css
 - img
 - js

Here is my app.yaml file code spinet
- url: /(img|css|js|images|avatars|font|partials|json)/(.*)
  static_files: static/\1/\2
  upload: static/(img|css|js|images|avatars|font)/(.*)

A: It was a bad rule I added in the end...
I added
url: /blog/(.+)?/?
-  script: \1/index.php
Removed, now it works fine.


text:
Q: How do I solve the circuit below using nodal analysis? I would like to know how I solve this circuit using nodal analysis

source
My attempt:

A: Feel free to ask questions, if you have them. But what follows is nodal analysis, not mesh.
Assign \$0\:\text{V}\$ to the bottom node. You can do that to exactly one node. That's the one I pick.

Then I find these three nodal equations with three unknowns. And in this case, \$V_{_\text{O}}=V_{_\text{A}}\$:
$$\begin{align*}
\frac{V_{_\text{A}}}{8\:\Omega}+\frac{V_{_\text{A}}}{-j\,2\:\Omega}+\frac{V_{_\text{A}}}{j\,5\:\Omega}+4\:\text{A}&=\frac{10\:\text{V}}{8\:\Omega}+\frac{V_{_\text{C}}}{j\,5\:\Omega}
\\\\
\frac{V_{_\text{B}}}{6\:\Omega}+\frac{V_{_\text{B}}}{-j\,4\:\Omega}&=\frac{10\:\text{V}}{-j\,4\:\Omega}+\frac{V_{_\text{C}}}{6\:\Omega}+4\:\text{A}
\\\\
\frac{V_{_\text{C}}}{6\:\Omega}+\frac{V_{_\text{C}}}{j\,5\:\Omega}&=\frac{V_{_\text{A}}}{j\,5\:\Omega}+\frac{V_{_\text{B}}}{6\:\Omega}+3\:\text{A}
\end{align*}$$
Just stuff that into SymPy (yes, I can see Matlab in your link):
var('va vb vc')
eq1 = Eq( va/8 + va/(-2*I) + va/(5*I) + 4, 10/8 + vc/(5*I) )
eq2 = Eq( vb/6 + vb/(-4*I), 10/(-4*I) + vc/6 + 4 )
eq3 = Eq( vc/6 + vc/(5*I), va/(5*I) + vb/6 + 3 )
solve( [ eq1, eq2, eq3 ], [ va, vb, vc ] )
{va: -1046/145 - 952*I/145,
 vb: 4018/145 - 1084*I/145,
 vc: 2164/145 + 2768*I/145}
solve( [ eq1, eq2, eq3 ], [ va, vb, vc ] )[va].n()
-7.21379310344828 - 6.56551724137931*I

That answer matches the one you linked towards:

And my calculator says:
-7.21379310344828 - 6.56551724137931j
-7.2137931 - j6.56551724, 9.75422101 < -137.693611

redpajama_set_name: RedPajamaStackExchange


text:
Q: Using WSL notify-send when Windows Focus Mode is on I use the WSL Notify Send tool to send notifications from WSL to Windows. I can do the following in bash:
notify-send "hello from wsl"

...and the notification is shown as a standard Windows notification - this is achieved by the wsl-notify-send.exe in the Windows PATH.
However, if I have Windows Focus Mode on the notification isn't shown. I would like to tell Windows that notifications from this .exe can always be shown. This can be achieved in Windows settings where there is System > Notifications > Set priority notifications, but the .exe isn't shown in the list of applications that can bypass focus mode.
Is there a way to achieve this, perhaps through the registry?


text:
Q: ColdFusion check if jQuery is loaded I've created this simple script to check if jQuery is loaded
<cfoutput>
<cfif GetPageContext().getCFOutput().getBuffer().findStringNoCase("jquery.js") eq -1>
    <script type="text/javascript" src="jquery.js"></script>
</cfif>

<script>
    $(document).ready( function() {
        $("##theValue").val("the replacement");
    });
</script>

<input type="Text" name="theValue" id="theValue" value="the value">
</cfoutput>

the whole page is surrounded by cfoutput
is there any better solution?

A: Eapen's comment is the best answer.
"I agree with Ken Redler - just use this approach - coldfusioning.com/index.cfm/2010/7/9/… i.e.  if (typeof jQuery === 'undefined') document.write(""); " - eapen


text:
Q: how to send email in java? I am trying to send email in this code but every time it is showing  username and password not accepted.
but I have done everything. I have also set my gmail account to access third party apps. Now I don't understand where is the problem is.
Exception in thread "main" javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials d8sm6051763pfd.159 - gsmtp
    at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965)
    at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:780)
    at javax.mail.Service.connect(Service.java:388)
    at javax.mail.Service.connect(Service.java:246)
    at javax.mail.Service.connect(Service.java:195)
    at javax.mail.Transport.send0(Transport.java:254)
    at javax.mail.Transport.send(Transport.java:124)
    at com.mirajhossain.TransMail.sendMail(Main.java:37)
    at com.mirajhossain.Main.main(Main.java:52)][1]

Here is my code.
class TransMail{
        public static void sendMail(String recepient) throws MessagingException {
            Properties properties=new Properties();
            properties.put("mail.from","REDACTED");
            properties.put(" mail.user","REDACTED");
            properties.put(" mail.passr","REDACTED");
            properties.put("mail.smtp.auth","true");
            properties.put("mail.smtp.starttls.enable","true");
            properties.put("mail.smtp.host","smtp.gmail.com");
            properties.put("mail.smtp.ssl.trust", "smtp.gmail.com");
            properties.put("mail.smtp.port","587");

            String myAccount="miraj98hossain@gmail.com";
            String pwd="69miraj69hossain69shawon69";

            Session session= Session.getInstance(properties, new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(myAccount,pwd);
                }
            });

            Message message= preparemessage(session,myAccount,recepient);
            Transport.send(message);
            System.out.println("yes");
        }

    private static Message preparemessage(Session session, String myAccount,String recepient) throws MessagingException {
            Message message=new MimeMessage(session);
            message.setFrom(new InternetAddress(myAccount));
            message.setRecipient(Message.RecipientType.TO,new InternetAddress(recepient));
            message.setSubject("Verification");
            message.setText("1254562");
            return message;
    }
}
public class Main{
    public static void main(String[] args) throws MessagingException {
        TransMail.sendMail("miraj09hossain@gmail.com");
    }
}

A: Make sure you have to turn on less secure app access from your gmail account settings.
public class Main {
    public static void main(String [] args)
    {
        // Sender's email ID needs to be mentioned
        String from = "test@gmail.com";
        String pass ="xxxxxxx";
        // Recipient's email ID needs to be mentioned.
        String to = "test313@gmail.com";

        String host = "smtp.gmail.com";

        // Get system properties
        Properties properties = System.getProperties();
        // Setup mail server
        properties.put("mail.smtp.starttls.enable", "true");
        properties.put("mail.smtp.host", host);
        properties.put("mail.smtp.user", from);
        properties.put("mail.smtp.password", pass);
        properties.put("mail.smtp.port", "587");
        properties.put("mail.smtp.auth", "true");

        // Get the default Session object.
        Session session = Session.getDefaultInstance(properties);
        int Vcode=(int)(10000+Math.random()*(20000-10000+1));

        try{
            // Create a default MimeMessage object.
            MimeMessage message = new MimeMessage(session);

            // Set From: header field of the header.
            message.setFrom(new InternetAddress(from));

            // Set To: header field of the header.
            message.addRecipient(Message.RecipientType.TO,
                    new InternetAddress(to));

            // Set Subject: header field
            message.setSubject("Email Verification");

            // Now set the actual message
            message.setText("Your verification code for our app is"+Vcode+".\n"+"Enter this code for complete your sign up process");

            // Send message
            Transport transport = session.getTransport("smtp");
            transport.connect(host, from, pass);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();
            System.out.println("Sent message successfully....");
        }catch (MessagingException mex) {
            mex.printStackTrace();
        }
    }
}

A: I am using JavaMail library. Look how it looks:
Configure:
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();

        mailSender.setHost(host); // for example smtp.gmail.com
        mailSender.setPort(port); // 465
        mailSender.setUsername(username); // your email
        mailSender.setPassword(password); // your password

        Properties properties = mailSender.getJavaMailProperties();

        properties.setProperty("mail.transport.protocol", protocol); // smtps
        properties.setProperty("mail.debug", debug); // as you wish
        properties.setProperty("mail.smtp.auth", auth); // true
        properties.setProperty("mail.smtp.starttls.enable", enable); // true

    }

Send message:
private void send(String subject, String message) {
        SimpleMailMessage mailMessage = new SimpleMailMessage();

        mailMessage.setFrom(emailFrom);
        mailMessage.setTo(emailTo); // receiver
        mailMessage.setSubject(subject);
        mailMessage.setText(message);

        mailSender.send(mailMessage);

    }

Try this.


text:
Q: Cropping an image in flutter So I've been trying really hard to crop an image according to my needs in flutter.
Problem statement:
I have a screen and in that screen I show a frame while the device camera is run on the background. Now, what I want is that whenever the user clicks a photo, only the area of that image inside the frame should be kept and rest should be cropped.
What I have done so far?

*

*Added a package image 3.1.3

*Wrote code to fetch x,y coordinates of my frame.

*Using the calculated x,y coordinates and copyCrop method from the Image package to crop the clicked image.

Now the problem is that I do not know how copyCrop works and the code right now does not give me the expected results.
final GlobalKey _key = GlobalKey();
void _getOffset(GlobalKey key) {
    RenderBox? box = key.currentContext?.findRenderObject() as RenderBox?;
    Offset? position = box?.localToGlobal(Offset.zero);
    if (position != null) {
      setState(() {
        _x = position.dx;
        _y = position.dy;
      });
    }
  }

I assign this _key to my Image.file(srcToFrameImage) and the function above yields 10, 289.125
Here 10 is the offset from x and 289.125 is the offset from y. I used this tutorial for the same.
Code to crop my image using the Image package:
var bytes = await File(pictureFile!.path).readAsBytes();
img.Image src = img.decodeImage(bytes)!;
img.Image destImage = img.copyCrop(
   src, _x!.toInt(), _y!.toInt(), src.width, src.height);
var jpg = img.encodeJpg(destImage);
await File(pictureFile!.path).writeAsBytes(jpg);
bloc.addFrontImage(File(pictureFile!.path));

Now, can anyone tell me how i can do this effectively? Right now, it does crop my image but not as I want it to be. It would be really great if someone could tell me how does copyCrop work and what is the meaning of all these different parameters that we pass into it.
Any help would be appreciated.
Edit:

Now, as you can see, i only want the image between this frame to be kept after being captured and rest to be cropped off.


text:
Q: Total Count of Posts NOT in Selected Categories? I need to get the total number of posts that are not in selected categories.
I have category IDs of the categories that I want to exclude from count (in the variable $folio_cat_ids)
So far I have this code which is not working,
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts
  WHERE post_status = 'publish'
    AND post_type = 'post'
    AND post_name NOT LIKE '%revision%'
    AND post_name NOT LIKE '%autosave%'
    AND post_category NOT IN($folio_cat_ids)");

Please help.

A: Do your posts have multiple categories? If not - I think individual category counts are cached, so can sum up counts:
$categories = get_categories( array( 'exclude' => $folio_cat_ids ) );

$count = 0;
foreach ( $categories as $category)
    $count += $category->category_count;

Can also just get and count the posts, that is more flexible and takes care of overlap, but also more resource-intensive:
$posts = get_posts( array(
    'category__not_in' => $folio_cat_ids,
    'numberposts' => '-1'
) );

$count = count( $posts );

A: Hi @Rich:
Welcome to WordPress Answers.
The 'post_category' field is not used anymore and has been replaced by a collection of "taxonomy" tables. If you were using direct SQL it would look like this:
$sql = <<<SQL
SELECT
  COUNT(*)
FROM
  {$wpdb->posts}
  INNER JOIN {$wpdb->term_relationships} ON {$wpdb->term_relationships}.object_id={$wpdb->posts}.ID
  INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id={$wpdb->term_relationships}.term_taxonomy_id
WHERE 1=1
  AND {$wpdb->posts}.post_status = 'publish'
  AND {$wpdb->posts}.post_type = 'post'
  AND {$wpdb->posts}.post_name NOT LIKE '%revision%'
  AND {$wpdb->posts}.post_name NOT LIKE '%autosave%'
  AND {$wpdb->term_taxonomy}.term_id NOT IN ($folio_cat_ids)
SQL;
$numposts = $wpdb->get_var($sql);

However, it's a good idea to use the WordPress API rather than direct SQL if you can avoid having to write lots of SQL when using the WordPress API, which in this case is very possible. I've written a small class for you called CountPostsCategoriesNotIn which encapsulates the 'posts_fields' hook you need to use. Calling this class is as simple as this:
$folio_cat_ids = '1,2,3';
$numposts = CountPostsCategoriesNotIn::count($folio_cat_ids);
echo "$numposts\n";

And here is that class which you can copy into your theme's functions.php file or use in the .php file of a plugin you might be writing:
class CountPostsCategoriesNotIn {
  static function count($categories) {
    $posts_fields = array(__CLASS__,'posts_fields');
    add_action('posts_fields',$posts_fields);
    $query = new WP_Query(array(
      'posts_per_page' => '-1',
      'category__not_in' => $categories,
    ));
    remove_action('posts_fields',$posts_fields);
    return $query->post->post_count;
  }
  static function posts_fields($field_list) {
    $field_list = 'COUNT(*) as post_count';
    return $field_list;
  }
}


text:
Q: StickNFind Bluetooth GATT Profiles Does anyone know what Bluetooth LE GATT profiles/services StickNFind is using?
I am working on BLE project on Android with other products. I have not purchased any StickNFind stickers. I just want to know a bit more about these stickers before considering to  have the app supporting it.
Many thanks.

A: I've already bougth one of these stickers and I'm working with.
To answer your question, I don't have the LE GATT Server complete table of all the services that it supports but there's an interesting app on Iphones call "BLE Utility" which provides you the complete list of those services (supported by the stickers) with their UUIDs
There is the link:https://itunes.apple.com/en/app/ble-utility/id606210918?mt=8
Hoping it will help you
Cheers

A: I recently found an app for android: "nRF Master Control Panel (BLE)"
https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp
It helped to me learn lot about the stick-n-find tags. I still haven't been able to map the uuids to anything useful... but this app at least listed them out and can pull/push data to the attributes.
EDIT:
I reached out to the manufacture and they have an SDK (and sample app), you have to sign up for a free account to get access:
https://bluvision.com/developer/beeks-beacons-sdk/
http://bluvision.com/developer/wp-content/uploads/sites/2/2014/09/Android-SDK.zip


text:
Q: bind("tcp://*:6001") meaning in python I came across a zeromq example code
subscriber = ctx.socket(zmq.XSUB)
subscriber.connect("tcp://localhost:6000")

publisher = ctx.socket(zmq.XPUB)
publisher.bind("tcp://*:6001")

The subscriber (client) is connecting to local host port 6000. But the publisher (the server) is binding to *:6001
What does this mean?

A: It means "all interfaces, port 6001" - a given computer can have more than one network interface (a trivial example would be that the average computer's LAN IP and it's localhost address are two different interfaces. The * means to accept connections from any of them.

A: What does it mean to .bind() at port 6000 while .connect() aims at port 6001?
Simply put, these two peers will not meet at this attempt to setup a link to communicate.
While wildcard does work for all <localhost> interfaces, it does not for port#-s.
A .bind() side can open it's receiving policy to accept a connection from any interface "behind" the * wild card, but the port#-s must match.
No exceptions, no excuse.


text:
Q: How can I set dynamic value inside the vue href link? I am trying to set a dynamic value in the URL in href. I am using Vue.js
 <a
          href="https://example.com/glasses/guide-for-uploading"
          target="_blank"
        >
          Check it here
        </a>

So in the middle of URL I need to replace glasses with productName. How can be it done correctly in this link? I am not sure if simple data binding is the case.

A: Yes you can using data binding.
<a
          :href="`https://example.com/glasses/${productName}`"
          target="_blank"
        >
          Check it here
        </a>

A: You can either bind href like:
:href="'https://example.com/glasses/${productName}'"

Or you can achieve the same result using string:
Let link = document.getElemntById("linkId")
Let address = "https://example.com/glasses/" + this.productName

link.href = address

A: you can use
:href="!${url}!"
it works for me replace ! with back Quote ( ` ) cold not display because it use highlights the inner part in this editor


text:
Q: Probability bound on Maxima under random sampling I have a set $S$ = {$e_1,e_2,..e_{400}$} of 400 elements and a non-linear function $f:2^{(S)}\to[0,1]$ that takes a subset of $S$ and returns a real number in $[0,1]$. I want to compute the subset for which $f$ attains the highest value.
Computing $f$ for a given input takes quite a bit of time (~1 hour) and it's not practically feasible to use any optimization algorithm on $f$. I'm trying to sample $n$ points randomly and compute $f(.)$ on those points.
Let $\alpha$ be the maximum among the observed values. Based on the observed mean and variance, Can I make a claim of some sort like: $P(f(S) \ge \alpha) \le \beta$ with a margin of error $e$. In that case how many samples do I need to make a statistical significant claim?


text:
Q: Is There A Way to DRY Up These Vue Attributes? <designs-dialog
      @change="dialogHandler"
      @close="dialogs.designs = false"
      :dialog="dialogs.designs"
      :job="dialogJob"
      v-if="dialogs.designs"
    />
    <details-dialog
      @change="dialogHandler"
      @close="dialogs.details = false"
      :dialog="dialogs.details"
      :job="dialogJob"
      v-if="dialogs.details"
    />

These 2 components are different in that one is more of a table and the other is more of a carousel. Nevertheless, it seems that there should be some way to DRY up the attributes as that part seems very similar between the 2.


text:
Q: How to identify that DVD/Optical disk has been ejected in Qt 5 framework? I need to identify particular moment when DVD disk has been ejected from optical drive, for example by pressing eject button.
I've tried to use signal directoryChanged from QFileSystemWatcher in Qt5 as possible solution.
#include <QFileSystemWatcher>

class RemovableDriveController : public QObject
{
    Q_OBJECT
public:
    RemovableDriveController(QObject * parent = nullptr)
        : QObject(parent)
        , m_fileSystemWatcher(new QFileSystemWatcher(this))
    {
        m_fileSystemWatcher->addPath("E:/"); // In my case the DVD-drive is E letter
        connect(m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &RemovableDriveController::onRemovableDriveEjected);
        qDebug() << m_fileSystemWatcher->directories();
    }

public slots:
    void onRemovableDriveEjected()
    {
        qDebug() << "Continue here";
    }

private:
    QFileSystemWatcher * m_fileSystemWatcher;
};

Using this sample, I've pressed eject button on drive. The drive has been ejected and disappeared from "Computer" directory.
But, QFileSystemWatcher doesn't catch this. No signals emitted.
Any ideas how to do that?


text:
Q: How to Add Columns/Rows to a Grid of Divs Code is here: http://jsfiddle.net/jaredasch1/6dhc240q/5/
I know I've asked this question before, but I wasn't able to get a working answer for that. I'm working on a game where it starts out a 4 by 4 grid, and when you click on one of the divs, it toggles the color of the divs above, below, and next two the one being clicked on. This part is working perfectly fine, and when they are all the other color, they switch back to the original color. However, what I'm trying to do now has presented more of a challenge. Once they are all the second color, I want to add another column and row and reset them back to the original color.
This is where I have run into some trouble. For some reason, the grid isn't recreated. This is where you guys come in. I need hep writing a function or edits to my original script to make this happen. I have this all on a JSFiddle here
I'll also post all of the code here.
    <!DOCTYPE html>

The CSS
    .block {
        height:100px;
        width:100px;
        border-radius:10px;
        display:inline-block;
        background-color:#33CCFF;
    }
    #button {
        height:100px;
        width:410px;
        border-radius:10px;
        display:inline-block;
        background-color:#FF6666;
        margin-bottom:10px;
    }
    .on {
        background-color:#D633FF;
    }

The JavaScript/jQuery
    var main = function () {
        var checkAll = function () {
            var allDivs = $("div.block");
            var classedDivs = $("div.block.on");

            var allDivsHaveClass = (allDivs.length === classedDivs.length);

            if (allDivsHaveClass) {
                allDivs.removeClass("on");
            }
        };
        $("div").mouseenter(function () {
            $(this).fadeTo("slow", 0.25);
            $(this).css('cursor', 'pointer');
        });
        $("div").mouseleave(function () {
            $(this).fadeTo("slow", 1);
            $(this).css('cursor', 'default');
        });
        $(".block").click(function () {
            $(this).toggleClass("on");
            $(this).prev().toggleClass("on");
            $(this).nextAll().eq(4).toggleClass("on");
            $(this).next().toggleClass("on");
            $(this).prevAll().eq(4).toggleClass("on");
            checkAll();
        });
        $("#button").click(function () {
            $(".block").removeClass("on");
        });
        $(document).keydown(function (key) {
            if (event.which === 32) {
                $(".block").removeClass("on");
            }
        });
    };

    $(document).ready(main);

Any help is welcome!

A: It is pretty simple: simply add a new row with the .append() function within the logic in the checkAll() function when you determine that the user has "finished" the game, i.e.:
if (allDivsHaveClass) {
    allDivs.removeClass("on");
    $('body').append('

');
}

However, since you are now going to deal with dynamically added elements, you will have to use the jQuery .on() method to bind mouseenter, mouseleave and click events to div.block on the go. You are currently using the .mouseenter(), .mouseleave() and .click() methods, which will be problematic for newly added elements because they are not present in the DOM initially when the page is loaded. In other words, you will need to use:
$(document).on('mouseenter', 'div', function () {
    // Code here
});
$(document).on('mouseleave', 'div', function () {
    // Code here
});
$(document).on('click', '.block', function () {
    // Code here
});

I have tested your game, and my solution works: http://jsfiddle.net/teddyrised/6dhc240q/6/
p/s: When developing games, it is always nice to include a "cheat" button (in this case, marking all
 with the class .on) so that you don't have to go through the entire game itself to check if a certain new feature works or not ;)

Other comments on your code:

*

*You might want to look into changing the mouseenter and mouseleave into CSS :hover events, since you are simply doing the fading and this can be easily done with transition and opacity

*Update the markup such that you are using
 instead of

*Actually, don't use
 at all because it has no semantic meaning in your case. It is used for line breaks for text. Instead, you can float all the blocks to the left

If you'd like to see the slightly modified code, you can view it here: http://jsfiddle.net/teddyrised/6dhc240q/7/


text:
Q: Add labels to each ng-template I'm trying to add Labels or Names for each of my ng-template and then save that label in a property and I'm not sure how to do this.
I would like to do this because, I want each ng-template associated with the correct Label when the list of ng-templates is iterated over.
To Note:
I am creating a reusable Tab component. The Tab component will hold the logic and the Parent component will hold the ng-templates since only the Parent knows what kind of templates it will need.
And each ng-template needs a tab label to go with it.
Tried:
I have tried adding name = "Label 2" to the ng-template but I don't think that did anything.
 <ng-template #temp1 name="Label 2">
this is template 2
 </ng-template>

Goal: I want to fill my templates property with an object like this.
let templates = {tempLabel: 'Label 2', template: 'temp1'}

I already got the template: temp1 part, I just need the tempLabel: 'Label 2 part of the object.

A: You can create custom directive that will store label and template itself, like this:
@Directive({
  selector: '[appLabel]'
})
export class LabelDirective {
  constructor(public templateRef: TemplateRef<any>) { }
  @Input('appLabel') label = '';
}

And inject it into component:
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  @ViewChildren(LabelDirective) templates: QueryList<LabelDirective>
}

Here's the AppComponent template:
<ng-template appLabel="label 1"></ng-template>
<ng-template appLabel="label 2"></ng-template>
<ng-template appLabel="label 3"></ng-template>

{{t.label}} - {{ t.templateRef }}

And here's the working example https://stackblitz.com/edit/angular-w8sd4y


text:
Q: Splitting inside a flow in Akka-Streams I am trying to come up with a solution to split an incoming String I am receiving into multiple Strings. I have been researching and it looks like in the previous versions of Akka-Streams there was a class Transformer that you could extend to do this kind of transformation.
In the version I am using (RC2) there are Stages but I am not really sure how I can implement the splitting pattern.
Source.actorPublisher[String](MyActor.props).
.XXXXX(_.split("\n"))
.map(...)
.to(Sink(...))

I am looking for the XXXXX component that will allow me to input a String and return a sequence of String and will emit each one to the rest of the flow.

A: I agree with @jrudolph that mapConcat is probably what you are looking for.  A quick example showing this method in action:
  val strings = List(
  """hello
     world
     test
     this""",
     """foo
     bar
     baz
     """

  )

  implicit val system = ActorSystem("test")
  implicit val mater = ActorFlowMaterializer()
  Source(strings).
    mapConcat(_.split("\n").map(_.trim).toList).
    runForeach(println)

If you run this code you will see the following printed out:
hello
world
test
this
foo
bar
baz

A: Akka provides the Framing helper functions for this type of problem.
Assuming your charset is UTF-8 you can write a function that takes in the maximum size of the delimited String values and returns a Flow that can perform the splitting:
import akka.stream.scaladsl.Framing
import akka.util.ByteString

val newLineSplitter : (Int) => Flow[String, String, NotUsed] =
  (maxLineSize) =>
    Flow[String]
      .map(ByteString.apply)
      .via(Framing delimiter (ByteString("\n"), maxLineSize))
      .via(Flow[ByteString] map (_.utf8String))


text:
Q: Using application.properties in xml file I am using spring boot application with appliaction.properties.
In the project there is XML file written by another company to configure Stomp, and there is hardcoded IP of the server, but I want to change those IP to take value from application.properties.
is there any way to do it?
application.properties
property.env=SLA
property.endpoint=http://172.1.1.139/router

tcmanager.xml
<tcmanager>

    <channelbuilders>
        <channelbuilder>
            <class>com.company.tc.stomp.TcStompChannelBuilder</class>
            <config>
                <properties>
                    <property>brokerURL=[property.endpoint]</property> //this is the place
                    <property>login=login</property>
                    <property>passcode=pass</property>
                </properties>
                <in> [...] </in>
                <out> [...]</out>
            </config>
        </channelbuilder>
    </channelbuilders>

    <processingbuilders>
        <processingbuilder>
            <class>com.company.tc.template.camel.MainProcessingBuilder</class>
            <config>
                <properties>
                    <property>p1=1</property>
                </properties>
            </config>
        </processingbuilder>
    </processingbuilders>

</tcmanager>


text:
Q: Parental control in Connectify Hotspot I am sharing my ethernet connexion over WiFi using Connectify Hotspot, and I am searching a way to ban access to adult content for all devices that are connected to my hotspot without "physical" access to these devices in preference by redirecting them to a another website to alert them (a page I created in local network).
I am running Windows 7 SP1 and Connectify Hotspot 3.7.1.25486.
Thanks in advance for your answers.

A: We've been trying to figure out ways to implement a similar functionality into our software DigiParent for some time now. While figuring out the simplest and best way to implement what we wanted we stumbled upon a software titled OPENDNS that can accomplish most of what you want. You might want to check it out at: http://www.opendns.com/


text:
Q: Keycloak bulk user import Does anyone have any thoughts on how one might import a very large number of users into Keycloak.
We are in the process of upgrading from 2.5.5 to 4.0.0 and have had to switch from MongoDB to MySQL. We have been able to export our user base but with 280k+ users to import back into Keycloak. The import process takes 25 mins to import one file of 500 users, which doesnt really seem practical as that would take us approximately 9/10 days to import the user base if we were working 24/7.
Any thoughts or ideas would be appreciated.

A: I realize I'm a little late to the party here...
Keycloak 8 (and newer) has a mechanism for bulk importing users via a .json file: https://www.keycloak.org/docs/8.0/server_admin/index.html#_export_import
If you have some sort of mechanism for dumping your existing users to a .json file, it makes the import reasonably easy.

A: You can use the Keycloak REST API with partialImport
First, you need to get an access_token, you can use your admin user or a client with the role manage-realm assigned
access_token=`curl http://localhost:8080/auth/realms/my-realm/protocol/openid-connect/token -XPOST -d 'grant_type=client_credentials' -u 'admin-client:admin-secret' | jq -r .access_token`

Then you can import an array of users
curl -X POST -H "Authorization: Bearer $access_token"  -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"users":[{"username":"jose.perez","email":"jose.perez@gmail.com","firstName":"Jose","lastName":"Perez","emailVerified":true,"enabled":true,"ifResourceExists":"SKIP"}' http://localhost:8080/auth/admin/realms/my-realm/partialImport


text:
Q: Access field in a Rabbitmq testContainer extension class in junit5 I am using TestContainer to run RabbitMQ instance in order to use it in my integration tests.
I create a Junit 5 extension class that implement the BeforeAllCallback interface to run the container only once before my tests, to connect to the container i need to retrieve the mapped port that is exposed in my host machine, so i am wandering if there is any solution in order to access the extension class field from my integration test class.
The Extension
public  class RmqExtension implements BeforeAllCallback {
    private static final String DEFAULT_USER = "guest";
    private static final String DEFAULT_PASS = "guest";
    public static final int RABBIT_HTTP_API_PORT = 15672;
    private static final String RABBIT_MQ_IMAGE_NAME = "rmqImage";
    private static final String RABBIT_MQ_OVERVIEW_PATH = "/api/overview";

    private static final GenericContainer rabbitMqContainer = new GenericContainer(DockerImageName.parse(RABBIT_MQ_IMAGE_NAME))
            .withExposedPorts(RABBIT_HTTP_API_PORT)
            .waitingFor(Wait.forHttp(RABBIT_MQ_OVERVIEW_PATH).withBasicCredentials(DEFAULT_USER, DEFAULT_PASS).forStatusCode(HttpStatus.SC_OK));

    @Override
    public void beforeAll(ExtensionContext extensionContext) throws Exception {
        rabbitMqContainer.start();
    }

}

My test Class
@ExtendWith(RmqExtension.class)

class RabbitMqIT {

   private int myPort;

   @Test
   void myTest(){

      // What i need to do

      myPort = rabbitMqContainer.getMappedPort(15672);
     }
}

A: I am unsure what is the most elegant JUnit-Jupiter-idiomatic way to do this, but if there is only 1 instance of the container per JVM process, you could either use a public static field or save it System Properties.
Also, see the Singleton Container Pattern for another example of how to do this without JUnit:
https://www.testcontainers.org/test_framework_integration/manual_lifecycle_control/#singleton-containers


text:
Q: avoid Doctrine DBAL query builder select statement to transform camelcase aliase names to lowercase I'm using doctrine DBAL in custom PHP application and in my case when I use query builder select statement for example like:
->select(
         'roles.id as roleId',
                'roles.slug as roleSlug',
                'roles.name as roleName',)

in the result array, keys are like roleslug, rolename. Do I need to add some configuration to avoid lowering the aliases by doctrine? I found nothing in the doctrine documentation related to that

A: This is related to PostgreSQL. Just wrap your select to doublequotes likes this:
->select(
         'roles.id as "roleId"',
                'roles.slug as "roleSlug"',
                'roles.name as "roleName"',)


text:
Q: Why does slice() in javascript accept float values? I thought following would throw an error but it accepted float indices.

var str = 'Why does slice() in javascript accept float values?';
console.log(str.slice(4,8.5));
console.log(str.slice(9.5,16.5));

A: See ECMA-262 specification.

*Let relativeStart be ? ToInteger(start).

and

*If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).

It makes a best effort attempt to convert whatever input it is given into an integer.
This is pretty standard across all of JavaScript. It almost always prefers type conversion over exception throwing.


text:
Q: Is there a proper etiquette for asking an author for their (mathematical) software? This may not be the correct place to ask such a question. I have read a mathematical paper on multiclass total variation clustering. I wish to use the algorithm in the contents to compare with another clustering result. My question is:
Is there a proper etiquette for asking the author(s) of the paper for their code? Is it rude to do so? Should I just try to figure it out on my own? Or is this something that is common?
One reason why I want to ask is because I am short on time and may not be able to figure it out by my deadline.
Any comments would be greatly appreciated.


text:
Q: Angular / ASP.NET Core 2.1 CORS issue The situation is that I had an existing angular application  and I am  changing the the backend service to ASP.NET Core 2.1. I have successfully create the API and I have enabled CORS in my service registration in the startup.cs file but when I try to access any specific url of my api it this error message

Access to XMLHttpRequest at
  'https://localhost:44329/api/ThinkTank/Index' from origin
  'http://localhost:4200' has been blocked by CORS policy: No
  'Access-Control-Allow-Origin' header is present on the requested
  resource

I think it is a problem with my startup page so I put it below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CPDEPCoreApi
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        readonly string MyAllowSpecificOrigins = "https://localhost:44329";
        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                builder =>
                {
                    builder.WithOrigins("https://localhost:44329")
                    .AllowAnyHeader()
                    .AllowAnyMethod(); ;
                });
            });
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            app.UseCors(MyAllowSpecificOrigins);
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}

Thanks in advance for your help.

A: Your origin is localhost:4200 not localhost:44329 (that's your server).
Change this line builder.WithOrigins("https://localhost:44329") to builder.WithOrigins("http://localhost:4200")


text:
Q: UIButtons from different views add images to same view? So, I am building an application with different views. Each of them has a number of buttons. When pressing a button in a view, it should add an image to a addedImages view (the main one).
How do I make a loop that will add the images dynamically according to the position of previously added images?
Im quite new in this, so now I have only one button adding an image like this:
- (IBAction)addItemToShoppingList
{
    UIImage *image = [UIImage imageNamed:@"button1.jpg"];
    UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
    imageView.frame = CGRectMake(120, 100, 80, 80);
    [shoppingList.view addSubview:imageView];
    [imageView release];

}

So I wanna make a function addItemToShoppingList that will be associated to all buttons in different views but to put different images dynamically to the same one?

A: int shoppingListX;

- (IBAction)addItemToShoppingList
{
    UIImage *image = [UIImage imageNamed:@"button1.jpg"];
    UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
    imageView.frame = CGRectMake(shoppingListX, 100, 80, 80);
    shoppingListX += 80;

    [shoppingList.view addSubview:imageView];
    [imageView release];

}


text:
Q: Enable selectable on kendo grid programmatically I have this grid in my application.
  @(Html.Kendo().Grid<Something>
          ()
          .Name("Something")
          .Selectable(builder => builder.Type(GridSelectionType.Row).Mode(GridSelectionMode.Multiple).Enabled(false) )
          .ClientRowTemplate(Html.Partial("Partials/Something").ToHtmlString())
          .TableHtmlAttributes(new { @class = "table table-stripped" })
          .Scrollable(scrollable => scrollable.Height(100).Enabled(true))
          .Columns(columns =>
          {
              columns.Bound(h => h.Something).Title("Something").Width(120);
              columns.Bound(h => h.Something).Title("Something").Width(120);
              columns.Bound(h => h.Something).Title("Something");
          }))

This grid is populated when I select another grid.
Once it is populated, I should be able to select multiple rows.
I looked evrywhere for a value that I could change, but no luck so far.
How or where can I change this
 .Selectable(builder => builder.Type(GridSelectionType.Row).Mode(GridSelectionMode.Multiple).Enabled(false) )

to
 .Selectable(builder => builder.Type(GridSelectionType.Row).Mode(GridSelectionMode.Multiple).Enabled(true) )

programmatically?
Tks in advance.
Rui Martins

A: You should use the following code:
.Selectable(selectable => selectable
    .Mode(GridSelectionMode.Multiple))

You can view a demo here.


text:
Q: Why does Amazon S3 return "MissingRequestBodyError" ("Request Body is empty")? When performing a "Delete Multiple Object" operation against the Amazon S3 server, my app receives an HTTP 400 ("Bad Request", and an Amazon S3 error code of "MissingRequestBodyError" with a message of "Request Body is empty".  According to the Amazon S3 documentation:

This happens when the user sends an empty xml document as a request.
  The error message is, "Request body is empty."

As can be see in the following packet trace, the app is passing a very large XML document of 15411 bytes.  Can anyone tell me why S3 thinks the XML document is empty?
Here is the request:
000000: 50 4f 53 54 20 2f 3f 64 65 6c 65 74 65 20 48 54  POST /?delete HT
000010: 54 50 2f 31 2e 31 0d 0a 41 63 63 65 70 74 3a 20  TP/1.1..Accept:
000020: 2a 2f 2a 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a  */*..User-Agent:
000030: 20 6c 69 62 63 75 72 6c 2f 37 2e 32 38 2e 30 20   libcurl/7.28.0
000040: 4f 70 65 6e 53 53 4c 2f 30 2e 39 2e 38 6a 20 4d  OpenSSL/0.9.8j M
000050: 6f 62 69 6c 65 4d 61 67 6e 65 74 2f 32 2e 31 2e  obileMagnet/2.1.
000060: 31 30 35 2d 57 69 6e 64 6f 77 73 0d 0a 48 6f 73  105-Windows..Hos
000070: 74 3a 20 00 00 00 00 00 00 00 00 00 00 00 00 00  t: xxxxxxxxxxxxx
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  xxxxxxxxxxxxxxxx
000090: 00 00 00 00 00 00 00 00 2e 73 33 2e 61 6d 61 7a  xxxxxxxx.s3.amaz
0000a0: 6f 6e 61 77 73 2e 63 6f 6d 0d 0a 44 61 74 65 3a  onaws.com..Date:
0000b0: 20 53 75 6e 2c 20 32 31 20 46 65 62 20 32 30 31   Sun, 21 Feb 201
0000c0: 36 20 31 36 3a 32 30 3a 31 36 20 2b 30 30 30 30  6 16:20:16 +0000
0000d0: 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68  ..Content-Length
0000e0: 3a 20 31 35 34 31 31 0d 0a 43 6f 6e 74 65 6e 74  : 15411..Content
0000f0: 2d 4d 44 35 3a 20 6a 73 4c 61 37 39 57 37 31 32  -MD5: jsLa79W712
000100: 45 64 44 68 68 4a 42 72 46 55 37 51 3d 3d 0d 0a  EdDhhJBrFU7Q==..
000110: 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70  Content-Type: ap
000120: 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 77 77 77 2d  plication/x-www-
000130: 66 6f 72 6d 2d 75 72 6c 65 6e 63 6f 64 65 64 0d  form-urlencoded.
000140: 0a 41 75 74 68 6f 72 69 7a 61 74 69 6f 6e 3a 20  .Authorization:
000150: 41 57 53 20 41 4b 49 41 00 00 00 00 00 00 00 00  AWS AKIAxxxxxxxx
000160: 00 00 00 00 00 00 00 00 3a 65 38 36 4e 79 70 59  xxxxxxxx:e86NypY
000170: 73 6b 6b 2f 52 4b 4d 6b 45 50 46 38 38 34 79 32  skk/RKMkEPF884y2
000180: 55 6a 4d 73 3d 0d 0a 0d 0a                       UjMs=....

Immediately following in the upstream is the XML document passed as the POST data.  The XML document is valid XML, checked using an online XML verifier:
000000: 3c 44 65 6c 65 74 65 3e 3c 51 75 69 65 74 3e 74  <Delete><Quiet>t
000010: 72 75 65 3c 2f 51 75 69 65 74 3e 3c 4f 62 6a 65  rue</Quiet><Obje
000020: 63 74 3e 3c 4b 65 79 3e 2f 77 77 77 2d 68 79 70  ct><Key>/www-hyp
[lines deleted]
003bf0: 25 44 37 25 39 34 2f 61 5b 70 6c 75 73 5d 25 44  %D7%94/a[plus]%D
003c00: 37 25 39 31 5b 70 6c 75 73 5d 63 5b 70 6c 75 73  7%91[plus]c[plus
003c10: 5d 25 44 37 25 39 33 2e 70 6e 67 3c 2f 4b 65 79  ]%D7%93.png</Key
003c20: 3e 3c 2f 4f 62 6a 65 63 74 3e 3c 2f 44 65 6c 65  ></Object></Dele
003c30: 74 65 3e                                         te>

Here are the responses from the server:
000000: 75 70 6c 6f 61 64 20 63 6f 6d 70 6c 65 74 65 6c  upload completel
000010: 79 20 73 65 6e 74 20 6f 66 66 3a 20 31 35 34 31  y sent off: 1541
000020: 31 20 6f 75 74 20 6f 66 20 31 35 34 31 31 20 62  1 out of 15411 b
000030: 79 74 65 73 0a                                   ytes.

000000: 48 54 54 50 2f 31 2e 31 20 34 30 30 20 42 61 64  HTTP/1.1 400 Bad
000010: 20 52 65 71 75 65 73 74 0d 0a                     Request..

000000: 78 2d 61 6d 7a 2d 72 65 71 75 65 73 74 2d 69 64  x-amz-request-id
000010: 3a 20 46 34 32 41 36 38 45 37 46 30 37 33 32 42  : F42A68E7F0732B
000020: 39 32 0d 0a                                      92..

000000: 78 2d 61 6d 7a 2d 69 64 2d 32 3a 20 33 4c 30 54  x-amz-id-2: 3L0T
000010: 35 4c 6d 4f 59 56 4c 68 67 62 74 44 30 79 4d 56  5LmOYVLhgbtD0yMV
000020: 49 73 59 52 6d 39 4f 51 58 50 71 67 77 6d 6a 39  IsYRm9OQXPqgwmj9
000030: 64 4a 34 42 51 75 2f 37 31 59 70 36 76 61 57 57  dJ4BQu/71Yp6vaWW
000040: 78 57 2b 73 69 4c 4a 51 58 51 4f 30 45 67 63 79  xW+siLJQXQO0Egcy
000050: 4b 36 64 76 32 31 41 3d 0d 0a                    K6dv21A=..

000000: 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70  Content-Type: ap
000010: 70 6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 0d 0a     plication/xml..

000000: 54 72 61 6e 73 66 65 72 2d 45 6e 63 6f 64 69 6e  Transfer-Encodin
000010: 67 3a 20 63 68 75 6e 6b 65 64 0d 0a              g: chunked..

000000: 44 61 74 65 3a 20 53 75 6e 2c 20 32 31 20 46 65  Date: Sun, 21 Fe
000010: 62 20 32 30 31 36 20 31 36 3a 32 30 3a 30 34 20  b 2016 16:20:04
000020: 47 4d 54 0d 0a                                   GMT..

000000: 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63 6c 6f 73  Connection: clos
000010: 65 0d 0a                                         e..

000000: 53 65 72 76 65 72 3a 20 41 6d 61 7a 6f 6e 53 33  Server: AmazonS3
000010: 0d 0a                                            ..

000000: 0d 0a                                            ..

000000: 31 30 36 0d 0a 3c 3f 78 6d 6c 20 76 65 72 73 69  106..<?xml versi
000010: 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e  on="1.0" encodin
000020: 67 3d 22 55 54 46 2d 38 22 3f 3e 0a 3c 45 72 72  g="UTF-8"?>.<Err
000030: 6f 72 3e 3c 43 6f 64 65 3e 4d 69 73 73 69 6e 67  or><Code>Missing
000040: 52 65 71 75 65 73 74 42 6f 64 79 45 72 72 6f 72  RequestBodyError
000050: 3c 2f 43 6f 64 65 3e 3c 4d 65 73 73 61 67 65 3e  </Code><Message>
000060: 52 65 71 75 65 73 74 20 42 6f 64 79 20 69 73 20  Request Body is
000070: 65 6d 70 74 79 3c 2f 4d 65 73 73 61 67 65 3e 3c  empty</Message><
000080: 52 65 71 75 65 73 74 49 64 3e 46 34 32 41 36 38  RequestId>F42A68
000090: 45 37 46 30 37 33 32 42 39 32 3c 2f 52 65 71 75  E7F0732B92</Requ
0000a0: 65 73 74 49 64 3e 3c 48 6f 73 74 49 64 3e 33 4c  estId><HostId>3L
0000b0: 30 54 35 4c 6d 4f 59 56 4c 68 67 62 74 44 30 79  0T5LmOYVLhgbtD0y
0000c0: 4d 56 49 73 59 52 6d 39 4f 51 58 50 71 67 77 6d  MVIsYRm9OQXPqgwm
0000d0: 6a 39 64 4a 34 42 51 75 2f 37 31 59 70 36 76 61  j9dJ4BQu/71Yp6va
0000e0: 57 57 78 57 2b 73 69 4c 4a 51 58 51 4f 30 45 67  WWxW+siLJQXQO0Eg
0000f0: 63 79 4b 36 64 76 32 31 41 3d 3c 2f 48 6f 73 74  cyK6dv21A=</Host
000100: 49 64 3e 3c 2f 45 72 72 6f 72 3e 0d 0a 30 0d 0a  Id></Error>..0..
000110: 0d 0a                                            ..

As far as I can see, there is an XML document sent as the POST data.  what is S3 complaining about?
Thanks in advance!

A: I don't think S3 actually believes the XML document to be empty -- I think it believes the request body is generally unusable and the error message it returns is a little bit imprecise.  Here's the issue:
000110: 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70  Content-Type: ap
000120: 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 77 77 77 2d  plication/x-www-
000130: 66 6f 72 6d 2d 75 72 6c 65 6e 63 6f 64 65 64 0d  form-urlencoded.

Your request body is not actually encoded as application/x-www-form-urlencoded so this Content-Type: request header you're sending isn't correct.
The example in the API documentation for multi-object-delete shows no Content-Type: request header at all, though something more valid like application/xml would probably work, too, if your HTTP library makes it difficult to not send the header at all.
I can really only speculate why the error is a little bit imprecise, but it seems as if a front-end request parsing subsystem at S3 is probably discarding the body since it's not actually encoded as the request header says it is.  It ends up with something it can't properly parse, and therefore nothing usable, and ultimately reports that the expected body was "missing."


text:
Q: How are infinitesimals of polar coordinates "treated"? How are infinitesimals of polar coordinates "treated"?
E.g.
what does
$$\frac{d}{dx}=\bigg( \frac{dr}{dx} \frac{d}{dr}\bigg) + \bigg( \frac{d \theta}{dx}  \frac{d}{d \theta}\bigg)$$
mean?
Particularly how does one "evaluate" $\frac{dr}{dx}$ or $\frac{d}{dr}$ etc.?

A: If $(x,y)$ denote Cartesian coordinates, then you have transformation laws $r=r(x,y)$ and $\theta=\theta(x,y)$, which can be found inverting the equations $x=r\cos \theta$ and $y = r\sin \theta$. If you have a function $f=f(r,\theta)$ this is also a function of $(x,y)$, because $f(r,\theta)=f(r(x,y),\theta(x,y))$, so it makes sense to compute the total derivative of $f$ with respect to $x$. By the chain rule you get
$$\frac{\mathrm{d}f}{\mathrm{d}x} = \frac{\partial f}{\partial r}\frac{\partial r}{\partial x}+\frac{\partial f}{\partial \theta}\frac{\partial \theta}{\partial x},$$
from which you get the identity for differential operators:
$$\frac{\mathrm{d}}{\mathrm{d}x} = \frac{\partial }{\partial r}\frac{\partial r}{\partial x}+\frac{\partial }{\partial \theta}\frac{\partial \theta}{\partial x}.$$


text:
Q: Complete guide to pass credentials to a server via HTTP auth and getting response back So we know how to do http get and post connections.
http://exampledepot.com/egs/java.net/pkg.html
And we want to pass credentials(uname,passwd) to any web server to access the url or get the response.
And we can't pass it as post parameters.
So have a look @ this very simple code which does it all.

A:  try
    {
        // Creatin the connection
        URL url = new URL("http://yoururl");
        URLConnection conn = url.openConnection();

    //sendin the base64 encoded credentials thru d header
    conn.setRequestProperty(
        "Authorization",
        "Basic "+ BasicAuth.encode(username, password));

    // Get the response
    BufferedReader rd = new BufferedReader(
        new InputStreamReader(conn.getInputStream()));

    //readin d response till d end
    while ((line = rd.readLine()) != null) {
        // Process line...
        Log.v("", line);
    }

    rd.close();
}
catch (Exception e) { }

To encode the credentials I am using a simple external class named "BasicAuth.java" which u can just add in to your project.
BasicAuth.java
public class BasicAuth {
 private BasicAuth() {}

    // conversion table
    private static byte[] cvtTable = {
        (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E',
        (byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J',
        (byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O',
        (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T',
        (byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y',
        (byte)'Z',
        (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e',
        (byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j',
        (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o',
        (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t',
        (byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y',
        (byte)'z',
        (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4',
        (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9',
        (byte)'+', (byte)'/'
    };

    /**
     * Encode a name/password pair appropriate to
     * use in an HTTP header for Basic Authentication.
     *    name     the user's name
     *    passwd   the user's password
     *    returns  String   the base64 encoded name:password
     */
    static String encode(String name,
                         String passwd) {
        byte input[] = (name + ":" + passwd).getBytes();
        byte[] output = new byte[((input.length / 3) + 1) * 4];
        int ridx = 0;
        int chunk = 0;

        /**
         * Loop through input with 3-byte stride. For
         * each 'chunk' of 3-bytes, create a 24-bit
         * value, then extract four 6-bit indices.
         * Use these indices to extract the base-64
         * encoding for this 6-bit 'character'
         */
        for (int i = 0; i < input.length; i += 3) {
            int left = input.length - i;

            // have at least three bytes of data left
            if (left > 2) {
                chunk = (input[i] << 16)|
                        (input[i + 1] << 8) |
                         input[i + 2];
                output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
                output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
                output[ridx++] = cvtTable[(chunk&0xFC0)   >> 6];
                output[ridx++] = cvtTable[(chunk&0x3F)];
            } else if (left == 2) {
                // down to 2 bytes. pad with 1 '='
                chunk = (input[i] << 16) |
                        (input[i + 1] << 8);
                output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
                output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
                output[ridx++] = cvtTable[(chunk&0xFC0)   >> 6];
                output[ridx++] = '=';
            } else {
                // down to 1 byte. pad with 2 '='
                chunk = input[i] << 16;
                output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
                output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
                output[ridx++] = '=';
                output[ridx++] = '=';
            }
        }
        return new String(output);
    }

}


text:
Q: How to retrieve json serializer settings via DI (service collection) in asp netcore 3.1 mvc while using AddNewtonsoftJson I have an ASP MVC project using .netcore 3.1, where I am overriding serializer options as the following
services
.AddControllers()
.AddNewtonsoftJson(options =>
{
    options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
    options.SerializerSettings.NullValueHandling = NullValueHandling.Include;
    options.SerializerSettings.Converters.Add(new StringEnumConverter
    {
        NamingStrategy = new CamelCaseNamingStrategy(),
    });
})

This works fine whenever MVC is serialising data (request/response) for me.
But now, in one of the Middlewares I need to serialise manually and return some data as a response, like:
public async Task Invoke(HttpContext context)
{
    try
    {
        await _next(context);
    }
    catch (Exception exception)
    {
        ... // removed for simplicity
        await context.Response.WriteAsync(JsonConvert.SerializeObject(errorResponse, _jsonSerializerSettings));
    }
}

Here I want to reuse existing settings for serialization. But old MvcJsonOptions are not available in .netcore 3.1 anymore (please correct if I am wrong).
So how can I achieve this, without duplicating json serialization settings?

A:
Here I want to reuse existing settings for serialization.

Since you've configured the NewtonsoftJson Options For Mvc within ConfigureServices() method, just inject a IOptions<MvcNewtonsoftJsonOptions> when you need it. For example, change your middleware to accept an argument of IOptions<MvcNewtonsoftJsonOptions>:
public class MyMiddleware
{
    private readonly RequestDelegate _next;
    private readonly JsonSerializerSettings _jsonSerializerSettings;

    public MyMiddleware(RequestDelegate next,IOptions<MvcNewtonsoftJsonOptions> jsonOptions)
    {
        // ... check null and throw
        this._next = next;
        this._jsonSerializerSettings = jsonOptions.Value.SerializerSettings;
    }

    public async Task Invoke(HttpContext context)
    {
        try
        {
            await _next(context);
        }
        catch (Exception exception)
        {
            //... removed for simplicity
            await context.Response.WriteAsync(JsonConvert.SerializeObject(errorResponse, _jsonSerializerSettings));
        }
    }
}

A: I believe you need to send data as json.
add the following namespaces
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Then it would provide serialization of your data.
var response = 'Your Model or list';
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.ContractResolver=new DefaultContractResolver();
return Json(new {data = response}, settings);


text:
Q: Proper way to inherit a class template from a base class while specializing the template I'm in the process of designing a virtual processor and I want to represent different size registers that the virtual cpu will use. I also would like to contain them into a single container regardless of their actual sizes and or types.
I would have a structure that looks like this to store the Registers
struct Memory {
    std::vector<std::shared_ptr<Register>> bank;
};

I'm trying to create a base empty class as such:
struct Register {};

Now I will be inheriting from this base class to create my different types of supported registers. These registers also depend on a few typedefs...
typedef std::int8_t   i8;
typedef std::int16_t i16;
typedef std::int32_t i32;
typedef std::int64_t i64;

typedef std::uint8_t   u8;
typedef std::uint16_t u16;
typedef std::uint32_t u32;
typedef std::uint64_t u64;

const u16 BYTE = 0x08, WORD = 0x10, DWORD = 0x20, QWORD = 0x40;

Lets say I want to have a Register that its underlying data type is a u8, another a u16 and so on...
struct Register8 : Register {
    u8 value;
    u8 getValue() const { return value; }
};

struct Register16 : Register {
    u16 value;
    u8 getValue() const { return value; }
};

struct Register32 : Register {
    u32 value;
    u32 getValue() const { return value; }
};

struct Register64 : Register {
    u64 value;
    u64 getValue() const { return value; }
};

So this is simple enough however I don't like the fact that I'm naming each of my register classes differently and I'm seeing some duplicate code other than the difference in types so we should be able to create a template...
struct Register{};

template<typename T>
Register_t : Register {
    T value;
    T getValue() const { return value; }
};

This is easy enough; However I would like to specialize this class:
struct Register {};

template<typename T>
struct Register_t : Register {
    T value;
    T getValue() const { return value; }
};

template<>
struct Register_t<u8> {
    u8 value;
    u8 getValue() const { return value; }
};

template<>
struct Register_t<u16> {
    u16 value;
    u16 getValue() const { return value; }
};

template<>
struct Register_t<u32> {
    u16 value;
    u16 getValue() const { return value; }
};

template<>
struct Register_t<u64> {
    u16 value;
    u16 getValue() const { return value; }
};

Okay this goes back on what I said earlier about duplicate code and we are introducing more, however in my situation these will be the only acceptable types ever so this bit of duplication is not an issue.
Everything so far is so good...
Now let's say I try to use this...
main.cpp
#include <iostream>
#include "Register.h"

int main () {
    Register_t<u8> r8;
    r8.value = 8;
    Register_t<u16> r16;
    r16.value = 16;
    Register_t<u32> r32;
    r32.value = 32;
    Register_t<u64> r64;
    r64.value = 64;

    Memory mem;
    mem.bank.push_back( std::make_shared<Register>( r8 ) );
    mem.bank.push_back( std::make_shared<Register>( r16 ) );
    mem.bank.push_back( std::make_shared<Register>( r32 ) );
    mem.bank.push_back( std::make_shared<Register>( r64 ) );

    return EXIT_SUCCESS;
};

Okay so I successfully stored these as shared pointers into a vector. Now comes the problem or issue... Let's try to access these values from the class
int main () {
    // ....

    for ( auto& b : mem.bank ) {
        std::cout << b->getValue() << '\n'; // Uh oh class Register has no member getValue() ...
    }

    return EXIT_SUCCESS;
}

So here is my problem; I'm not sure how to indirectly call the inherited class's getValue() function or how to properly inherit this type of design structure - class hierarchy. Or if I should eliminate specialization altogether... This is where I'm stuck and any and all help would be appreciative.


text:
Q: How to position the element at the same position as another element? After Clicking Hello button I was the new hello button to be displayed at exactly the same position as the previous one was there how can I do that ?

  const rightDiv = document.querySelector('#rightDiv');
  const leftButton = document.querySelector('#leftButton');

  function myFunction() {
    rightDiv.style.display = "none";
    leftButton.style.display = "block";  }
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

    <button id="leftButton" style="display: none"> Hello</button>

    <button onclick="myFunction()"> Hello</button>

Edit: I want to set the position same as the other button so that I looks like the button never moved

A: If none is specified for the display property, no box is generated. Also, offsetWidth, offsetHeight attributes, etc. return 0 if there is no CSS layout box associated with the element[1].

9.2.4 The 'display' property[2]
This value causes an element to not appear in the formatting structure (i.e., in visual media the element generates no boxes and has no effect on layout). Descendant elements do not generate any boxes either; the element and its content are removed from the formatting structure entirely. This behavior cannot be overridden by setting the display property on the descendants.
Please note that a display of 'none' does not create an invisible box; it creates no box at all. CSS includes mechanisms that enable an element to generate boxes in the formatting structure that affect formatting but are not visible themselves. Please consult the section on visibility for details.

Therefore, use the visibility property instead of the display property. The visibility property can be used to make the box generated by the element invisible and affect the layout.

11.2 Visibility: the 'visibility' property[3]
The visibility property specifies whether the boxes generated by an element are rendered. Invisible boxes still affect layout (set the display property to 'none' to suppress box generation altogether). Values have the following meanings:

*

*hidden
  The generated box is invisible (fully transparent, nothing is drawn), but still affects layout. Furthermore, descendants of the element will be visible if they have 'visibility: visible'.

Bootstrap 4 uses Flexbox for grid layout, so you can use the order property to control the order of flex items[4].

Grid system[4]
Bootstrap's grid system uses a series of containers, rows, and columns to layout and align content. It's built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.

From the above, you can do this using the visibility and order properties:

const rightDiv = document.querySelector('#rightDiv');
const leftButton = document.querySelector('#leftButton');

function myFunction() {
  rightDiv.style.visibility = "hidden";
  leftButton.style.visibility = "visible";
  leftButton.parentElement.style.order = 1;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

    <button id="leftButton" style="visibility: hidden"> Hello</button>

    <button onclick="myFunction()"> Hello</button>

If you want the #leftButton width to be 100%, you can do this using a pseudo-element and the align-items property.

const rightDiv = document.querySelector('#rightDiv');
const leftButton = document.querySelector('#leftButton');

function myFunction() {
  rightDiv.style.display = "none";
  leftButton.style.display = "block";
}
/* Position adjustment by pseudo-elements and `margin` for` padding` etc ... */

.leftColumn::before {
  flex-basis: 50%;
  content: "";
}

#leftButton {
  margin: 0 15px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

    <button id="leftButton" style="display: none"> Hello</button>

    <button onclick="myFunction()"> Hello</button>

Reference:

*

*CSSOM View Module

*Cascading Style Sheets Level 2 Revision 2 (CSS 2.2) Specification


text:
Q: Plotting dataframe created using pandas with a CSV file. Having trouble with x axis tick labels I want the x axis tick marks to be the different states ie. IDLE, Data=Addr, Hammer, etc that are in column A of the csv file.
import pandas as pd
import matplotlib.pyplot as plt

df1 = pd.read_csv("Output.csv", index_col = 0)
df1.plot(x = df1.index.values)

I have also tried
df1.plot(xticks = df1.index.values)

without any success.
CSV File
Plot
Thanks in advance!

A: You may want to try Seaborn because it looks like it is not a plotting issue but rather peripheral styling issue (all blacked out) in your environment.
Once you installed Seaborn, insert a piece of code below to yours.
import seaborn as sns
sns.set_style("whitegrid")

As a side note, if you wish to align the number of ticks in x axis to that of labels you have, replace your plotting part with the following:
df1.plot()
plt.xticks(range(df1.shape[0]), df1.index)

Hope this helps.


text:
Q: Identify gaps in N dimensional data set We have an interesting problem we need to resolve here, we're using C# .NET 4.0 but the language should be irrelevant as it's a mathematical problem.
Problem: we need to identify gaps in N dimensional data set and report exactly where those gaps are back to the user.
For example, let's assume we're working with 3-D, so we have this object Quote with 6 properties: TermFrom, TermTo, AgeFrom, AgetTo, AmountFrom, AmountTo and boundaries we need to cover: MinTerm = 0, MaxTerm = 5, MinAge = 0, MaxAge = 5, MinAmount = 0, MaxAmount = 5. Assuming all minimums are 0 and maximums are 5 just to simplify the example, albeit they could be different. So, the data we need to check for gaps in is the following data set:
Quote[] {
  {  TermFrom=0, TermTo=3, AgeFrom=0, AgetTo=4, AmountFrom=0, AmountTo=2  },
  {  TermFrom=4, TermTo=5, AgeFrom=0, AgetTo=5, AmountFrom=3, AmountTo=5  }

This dataset contains gaps for combinations: { Term: 0-5, Age: 4-5, Amount: 0-2 } and { Term: 0-3, Age: 0-5, Amount: 2-5 }, { Term: 4-5, Age: 0-5, Amount: 0-2 } (i think)
i.e. if you imagine a cube and the datasets are parts of this cube, to calculated total volume of all datasets must be equal to the cube's volume. And we need to identify where the gaps are in this cube if its volume isn't full.
All of this is required with more dimensions: 4 and 5, but it's a lot harder to visualise. I was hoping there is some sort of mathematical solution to this problem, which we could translate to c# code.

A: With $6$ possible values in $3$ dimensions you would need $6^3=216$ data points to fill the cube.  The number gets larger quickly as the number of dimensions increases.  It would be possible to cut the cube into $2^3=8$ pieces of half the size in each dimension and check that there are points (or even about the same number of points) in each octant.  But checking that there is not a random $3 \times 3 \times 3$ block without points seems rather difficult.


text:
Q: How do you resize DVD subs in VLC? Situation:
Recently I bought a DVD with subtitles. When I play the DVD using Windows Media Player and PowerDVD, the subtitles are just right but when I use VLC, the font becomes very large. So large that the sentence is not completed in the video screen.
What I know:
I am tweaking my VLC and read a few posts. It says that DVD subs are recorded as images so changing the font size would not do. I managed to shift the subs up and down.
What I have:
VLC v. 1.0.5
Windows OS

A: Go to Tools -> Preferences -> Subtitles and OSD (or CRTL+P).  There, you will find an option to change the subtitle size, among other configurations.
Screenshot:


text:
Q: How do I use tcomment (vim's plugin) and how do can I say it is installed? So I decided I should learn how to comment and uncomment code in a fancy way. So I tried vim plugin tcomment. I googled that I needed to open the vba file I downloaded with vim and type
:source %

I google around but I am still not sure how to run the plugin. What do I type in in normal mode to toggle comments? Just simple one line comments. I cannot figure it out. I am convinced I installed the plugin right, but how can I make sure?

A: To make sure you have installed the plugin you can run :scriptnames. This will list all enabled plugins and scripts (you are looking for tcomment.vim).
The commands for tComment are the following:
gc{motion}   :: Toggle comments (for small comments within one line
                the &filetype_inline style will be used, if
                defined)
gcc          :: Toggle comment for the current line
gC{motion}   :: Comment region
gCc          :: Comment the current line

More info here
And the full documentation is here


text:
Q: Transform CSV File and Load into PostgreSQL My CSV data set has a variable number of columns due to certain groups of fields having a different number of sets based on how I query the data (timeframe).
For example, I have:
Field 1 Field 2 Field 3 [Field 4.1.1 Field 4.1.2 Field 4.1.3 Field 4.2.1 Field 4.2.2 Field 4.2.3]

My new PostgreSQL tables contain:
 - **Table 1**
-------------

 - Field 1 Field 2 Field 3

 - **Table 2**
-------------

 - Field 4.X.1 Field 4.X.2 Field 4.X.3

where each X is a new row in table 2.
Recommendations on ETL or other programs to automate this process?


text:
Q: loading a custom uitableviewcell causing a memory leak I am using a custom UITableViewCell and it gives me a memory leak when I run the application using Instruments on a real device. The leak occurs when I call the method cellForRowAtIndexPath:
static NSString *TipIdentifier = @"TCell";

TipsCell *cel = (TipsCell *)[tableView dequeueReusableCellWithIdentifier:TipIdentifier];

if (cel == nil){

    NSLog(@"New Cell Made here");

    cel = (TipsCell *)[[[NSBundle mainBundle] loadNibNamed:@"TipsCell" owner:self options:nil] objectAtIndex:0];

    cel.txtTip.backgroundColor=[UIColor clearColor];
    cel.txtLikes.backgroundColor=[UIColor clearColor];
    cel.txtComments.backgroundColor=[UIColor clearColor];
    cel.txtUserName.backgroundColor=[UIColor clearColor];

    [cel.txtTip setLineBreakMode:UILineBreakModeWordWrap];
    [cel.txtTip setMinimumFontSize:FONT_SIZE];
    [cel.txtTip setNumberOfLines:0];

    cel.backgroundColor = [UIColor colorWithRed:0.113 green:0.42 blue:0.427 alpha:.9];

    //cell.backgroundColor = [UIColor colorWithRed:0.4 green:0.745 blue:0.835 alpha:.9];

    [cel setSelectionStyle:UITableViewCellSelectionStyleGray];

    cel.opaque = NO;

}
/*
if ([[QuestionsiLike objectAtIndex:indexPath.row] isEqual:@"1"]) {
    [cell.txtLikes setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
else{
    [cell.txtLikes setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}*/

[cel.txtLikes setTitle:[QuestionsNoLikes objectAtIndex:indexPath.row] forState:UIControlStateNormal];

[cel.txtLikes setTag:indexPath.row];

[cel.txtLikes addTarget:self action:@selector(Like:) forControlEvents:UIControlEventTouchUpInside];

cel.txtComments.text=[QuestionsNoComments objectAtIndex:indexPath.row];

cel.txtTip.text=[QuestionsTxt objectAtIndex:indexPath.row];
cel.txtUserName.text=[QuestionsUN objectAtIndex:indexPath.row];

UIImage *image = [[TKImageCenter sharedImageCenter] imageAtURL:[NSString stringWithFormat:@"http://www.tipntag.com%@",[QuestionsUimg objectAtIndex:indexPath.row]] queueIfNeeded:YES];

[cel.imgUser setImage:image];

image = [[TKImageCenter sharedImageCenter] imageAtURL:[NSString stringWithFormat:@"http://www.tipntag.com%@",[QuestionsRankImg objectAtIndex:indexPath.row]] queueIfNeeded:YES];

[cel.imgRank setImage:image];

NSString *text =[QuestionsTxt objectAtIndex:indexPath.row];// [items objectAtIndex:[indexPath row]];

CGSize constraint = CGSizeMake(220, 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
[cel.txtTip setFrame:CGRectMake(70, 5, 220 , MAX(size.height, 30.0f))];

//cell.txtLikes.text=[QuestionsNoLikes objectAtIndex:indexPath.row];
//cell.txtComments.text=[QuestionsNoComments objectAtIndex:indexPath.row];

NSString *tstr=[NSString stringWithFormat:@"%@",[QuestionsLat objectAtIndex:indexPath.row]];
NSLog(tstr);

if ([tstr isEqual:@"<null>"]) {
    [cel.imgMap setEnabled:NO];
    [cel.lblDistance setHidden:YES];
    [cel.GetDirections setHidden:YES];
    [cel.imgDistance setHidden:YES];
}
else{
    [cel.imgMap setEnabled:YES];

    [cel.imgMap setTag:indexPath.row];

    [cel.imgMap addTarget:self action:@selector(GoToMap:) forControlEvents:UIControlEventTouchUpInside];

    NSLog(@"%@",[QuestionsDistance objectAtIndex:indexPath.row]);

    [cel.imgDistance setHidden:NO];
    [cel.lblDistance setHidden:NO];

    NSString *tmp2=[[NSString alloc]initWithFormat:[NSString stringWithFormat:@"%@",[QuestionsDistance objectAtIndex:indexPath.row]]];

    NSString *tmp=[[NSString alloc] initWithFormat:@"%@ mi",[tmp2 substringToIndex:4]];

    [tmp2 release];

    [cel.lblDistance setText:[NSString stringWithString:tmp]];

    [tmp release];

    [cel.GetDirections setHidden:NO];

    end.latitude=[[QuestionsLat objectAtIndex:indexPath.row] floatValue];
    end.longitude=[[QuestionsLong objectAtIndex:indexPath.row] floatValue];

    [cel.GetDirections setTag:indexPath.row];

    [cel.GetDirections addTarget:self action:@selector(getDirection:) forControlEvents:UIControlEventTouchUpInside];

}

if ([[QuestionsiLike objectAtIndex:indexPath.row] intValue]==0) {

    [[cel txtLikes] setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}else
{
    [[cel txtLikes] setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
NSLog(@"%@",[QuestionsLat objectAtIndex:indexPath.row]);

return cel;
}

I tried a lot with it but my code is still leaking. I believe that this leak results in a crash.

A: Try this?
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
  cell = [[[TableViewCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
TableViewCustomCell * customCell = (TableViewCustomCell *)cell;

And if you do need load the nib file, run it in initWithStyle:.
I'm not sure if it is the really issue that causes your memory leak. :?


text:
Q: Can't add lines to diamond shape created with only CSS Can anyone help me to make this logo using CSS?
Image of the logo
First I made a square with width and height and then I tried using pseudo elements but I get stuck because I can only use two times pseudo elements,one before and one after so I can't do it with that approach.
This is the code from the second approach but as you can see this method is not really good because it's not quite reusable and the lines are not aligned when you zoom in. JSFiddle of the code below.

* {
  box-sizing: border-box;
}

.container {
  margin: auto;
  background-color: green;
  max-width: 1400px;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.rectangle {
  height: 40px;
  width: 40px;
  border: 3px solid yellow;
  transform: rotate(45deg);
  position: relative;
}

.first-line {
  position: absolute;
  content: "";
  width: 20px;
  height: 20px;
  left: 100%;
  top: 100%;
  transform: translateY(-100%);
  border-top: 3px solid yellow;
}

.second-line {
  position: absolute;
  content: "";
  width: 20px;
  height: 20px;
  top: 0%;
  left: 0%;
  transform: translateX(-100%);
  border-bottom: 3px solid yellow;
}
<!DOCTYPE html>

  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="css/style.css" />
  <title>Web Design | Mike Taylor</title>

A:

/* 1170px container */

* {
  box-sizing: border-box;
}

.container {
  margin: auto;
  background-color: green;
  max-width: 1400px;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.rectangle {
  height: 40px;
  width: 40px;
  border: 3px solid yellow;
  transform: rotate(45deg);
  position: relative;
}

.first-line {
  position: absolute;
  content: "";
  width: 20px;
  height: 20px;
  left: 100%;
  top: 100%;
  transform: translateY(-100%);
  border-top: 3px solid yellow;
}
.second-line {
  position: absolute;
  content: "";
  width: 20px;
  height: 20px;
  top: 0%;
  left: 0%;
  transform: translateX(-100%);
  border-bottom: 3px solid yellow;
}
.third-line {
  position: absolute;
  content: "";
  width: 20px;
  height: 20px;
  top: 0%;
  left: 0%;
  transform: translateY(177%) translateX(81%) rotate(90deg);
  border-bottom: 3px solid yellow;
}
.forth-line {
  position: absolute;
  content: "";
  width: 20px;
  height: 20px;
  top: 0%;
  left: 0%;
  transform: translateY(-115%) translateX(81%) rotate(90deg);
  border-bottom: 3px solid yellow;
}
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="css/style.css" />
    <title>Web Design | Mike Taylor</title>

full page screenshot

A: Check the below answer hope it helps you

* {
  box-sizing: border-box;
}

.container {
  margin: auto;
  background-color: green;
  max-width: 1400px;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.rectangle {
    height: auto;
    width: auto;
    border: 4px solid yellow;
    transform: rotate(45deg);
    position: relative;
    text-align: center;
    min-width: 100px;
    min-height: 100px;
}
.rectangle h1 {
   margin: 0;
    line-height: initial;
    color: #fff;
    font-weight: normal;
    font-size: 50px;
    font-family: arial;
    position: relative;
    transform: rotate(-45deg);
    padding: 40px;
}
.rectangle:after {
    content: "";
    position: absolute;
    width: 60px;
    height: 4px;
    background: yellow;
    right: -60px;
    top: 50%;
    margin-top: -2px;
}

.rectangle:before {
    content: "";
    position: absolute;
    width: 60px;
    height: 4px;
    background: yellow;
    left: -60px;
    top: 50%;
    margin-top: -2px;
}
.rectangle .line:before{
    content: "";
    position: absolute;
    height: 60px;
    width: 4px;
    background: yellow;
    top: -60px;
    left: 50%;
    margin-left: -2px;
}
.rectangle .line:after{
    content: "";
    position: absolute;
    height: 60px;
    width: 4px;
    background: yellow;
    bottom: -60px;
    left: 50%;
    margin-left: -2px;
}

M

A: Here is a one div idea without complex code:

.logo {
  --b:5px; /* adjust this to control the thickness */
  /* control the size */
  width: 50px;
  height: 50px;
  /**/
  font-size: 40px;
  font-family: sans-serif;
  margin: 80px auto;
  position: relative;
  display: grid;
  place-items: center;
}
.logo:before {
  content: "";
  position: absolute;
  inset: -100%;
  transform: rotate(45deg);
  background:
    linear-gradient(#fff 0 0) center/100% var(--b),
    linear-gradient(#fff 0 0) center/var(--b) 100%,
    linear-gradient(#fff 0 0) center/50% 50%;
  background-repeat: no-repeat;
  -webkit-mask:
    linear-gradient(#fff 0 0) center/calc(50% - 2*var(--b)) calc(50% - 2*var(--b)),
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  -webkit-mask-repeat: no-repeat;
}
body {
  background: green;
}

M

Another idea:

.logo {
  --b:5px; /* adjust this to control the thickness */
  /* control the size */
  width: 50px;
  height: 50px;
  /**/
  font-size: 40px;
  font-family: sans-serif;
  margin: 80px auto;
  position: relative;
  display: grid;
  place-items: center;
}
.logo:before {
  content: "";
  position: absolute;
  inset: -100%;
  padding:70%;
  transform: rotate(45deg);
  background:
    linear-gradient(90deg,#fff 25%,#0000 0 75%,#fff 0) 50%/100% var(--b),
    linear-gradient( 0deg,#fff 25%,#0000 0 75%,#fff 0) 50%/var(--b) 100%,
    conic-gradient(from  90deg at top   var(--b) left   var(--b),#0000 90deg,#fff 0) content-box,
    conic-gradient(from -90deg at bottom var(--b) right var(--b),#0000 90deg,#fff 0) content-box;
  background-repeat: no-repeat;
}
body {
  background: green;
}

M


text:
Q: how to get MSISDN number in WAP using PHP? I have developed a WAP application and I would like to get the MSISDN of the users that visit my site.
My operator has white listed my WAP application.
I am getting MSISDN successfully on couple of Samsung Mobiles, but not getting same result on Nokia, BlackBerry & iPhone deviceas.
Please suggest me best way to get MSISDN number for all devices.

A: The ability to get the MSISDN of the user visiting the WAP site depends on a number of things.
Firstly, the user has to be on Mobile Data. If the user is on WiFi then you will not receive this information.
Secondly, the users mobile network has to support the passing of the MSISDN in the HTTP headers.
Some mobile networks send headers on all requests. Others only send if going through a specific APN. Some only send this header to specific IP addresses/blocks. I have even come across networks that send the MSISDN as a $_GET variable. You will need to check with each network that you intend to support.
For example, a particular network in South Africa used to send MSISDNs in headers until around 6 months ago, and in order to receive the MSISDN in the headers now your server address needs to be whitelisted with them.
Also remember that headers are very easy to spoof, and shouldn't be relied on unless you are guaranteed that you are the originator of the HTTP request, such as in instances where you are using Web Views inside of Android Applications - you would need to put sufficient measures in place yourself.
With all of that in mind, here is what you should be looking for:
Look through your headers for any of the following. This is not a comprehensive list of MSISDN headers at all, they are only the ones I have come across in my adventures in mobile development.

*

*X-MSISDN

*X_MSISDN

*HTTP_X_MSISDN

*X-UP-CALLING-LINE-ID

*X_UP_CALLING_LINE_ID

*HTTP_X_UP_CALLING_LINE_ID

*X_WAP_NETWORK_CLIENT_MSISDN

What I do is run through the headers looking for any matches. If I don't find any matches I run through the headers again using a country-specific MSISDN regex against the values to see if there are any potential MSISDNs in the headers on keys that I do not know about. If I find a potential match I add the key and data to a list that I can go through later in order to add to my list of known MSISDN headers.
I hope this has bought some clarity. What is most important to remember is that this is not a reliable method for getting an MSISDN.

A: You can try these others (original: puedes intentar con estas otras):

*

*X-MSISDN

*X_MSISDN

*HTTP-X-MSISDN

*X-UP-CALLING-LINE-ID

*X_UP_CALLING_LINE_ID

*HTTP_X_UP_CALLING_LINE_ID

*X_WAP_NETWORK_CLIENT_MSISDN

*X-Forwarded-For

*Proxy-Client-IP

*WL-Proxy-Client-IP

*HTTP_CLIENT_IP

*HTTP_X_FORWARDED_FOR

*x-real-ip

*HTTP_X_UP_CALLING_LINE_ID

*HTTP_MSISDN

*MSISDN

*User-Identity-Forward-msisdn

*HTTP_X_MSISDN

*HTTP_X_NOKIA_MSISDN

*HTTP_X_UP_SUBNO

A: Sometimes the headers are encrypted by the mobile operators. This may change the naming of the headers. For example X-MSISDN becomes X-ENCR-MSISDN.

A: Some operators are sending x headers on server requests ,based on my recent researches ,I found out that many operators are hiding or encrypting or renaming the x headers and it's hard to retrieve the user's MSISDN , I've tried many ways and If you wanna test your operator, you can use this website Test Operator's MSISDN availablity(remember to open the link with your mobile device) I hope it will help you.I have picked up these headers by using Asp.net Mvc


text:
Q: How to switch PIR sensor on/off based on photocell result I've built the following circuit based on an ATtiny85 for a night lamp. The circuit is powered by a 3.7v LiPo battery. I'd like to turn off the PIR sensors when the photocell detects light in order to save battery.
I tried putting a 2N2222 transistor between the power and the PIRs VCC pins but that makes the sensors unstable as not enough current was going through. I suspect some resistance by the 2N2222 but I might be wrong. I'm successfully using a 2N2222 to switch the photocell off when I don't need it. The sensors draw 100 uAh when standing by.
Can someone tell me what would be the best and most efficient way to switch (on/off) the current of the PIR sensors?
Thanks.

A: There are multiple faults with your circuit:

*

*There is insufficient voltage to drive your PIR motion detectors. Reference to the link you provided, the HC-SR505 require from 4.5-20V. You LiPo battery will only provide 4.2 when fully charged, and for most of the discharge cycle will be below 4V. No matter what you use to switch the sensors on/off with, they are unlikely to provide consistent results.

*Using a BJT to try and cycle the VCC for the HC-SR505 will reduce the voltage to an even more critical level.

*The HC-SR505 much like its bigger brother the HC-SR501 takes a long time to initialize and is VERY sensitive to VCC fluctuations. During initialization time you may see an active output. I've used both and typically wait at about 4-5 seconds after applying power to allow the output to settle. At the VCC voltage you are operating the sensor you are likely to see multiple resets.

*The best advice seems to be that the HC-SR505 uses an EG4001 chip while the HC-SR501 uses a BIS0001, both chips used in the sensors draw low current. You have already found this to be around 100uA. You can switch the VCC to the sensor using any GPIO port on the ATTiny85 as they will handle many mA (though you need the VCC to be high enough for the regulator to work). I've used both the HC-SR505 and 501 on a 5V Arduino driven directly from the GPIO pins and they work fine. You just have to allow initialization before believing the output signal.

A good review of the HC-505 along with a schematic is here.

You will notice that the input power connection has a series diode, which accounts for the minimum supply voltage of 4.5V.
Suggestions:

*

*You could short out the protection diode and the regulator (HT7133) would then work down to about 3.45V which would then work for your LiPo battery.

*Connect your sensors directly to the ATTiny85 GPIO pin (both sensors could go to one pin), but ensure you give sufficient time for the sensors to settle when you power them up.

*Connect your ambient light detector (CDS cell) to an analog input with the pullup resistor driven by another GPIO pin. Then when you put the ATTiny to sleep you reduce (switch off) that current.

*Switch off your peripherals and put the MCU to sleep for the longest time you can count. When the MCU wakes up test the ambient light detector. If it's dark you can power up your PIR detectors.

*When your PIR detectors are on, minimize the MCU current by turning off as much as you can (like the A/D and BOD) and use IDLE state with wake on PIR detection.

A: The way you're connecting your NPN transistors is called "common collector" or "emitter follower", and it leaves you with one diode drop between the base voltage and the emitter voltage -- so your PIR was getting Vbatt - 0.65V, rather than Vbatt.
You want to use a P-channel MOSFET, connected as shown, to switch power to your PIR sensors.  Note that when the gate is HIGH it will be OFF -- that's opposite of what you're getting with your NPN emitter follower.
Your photosensor should be drawing little enough current that you can just power it straight from your microprocessor pin.  Check the data sheet, but with that 1k\$\Omega\$ resistor in there, it should only be pulling about 4mA, which your processor can almost certainly source.  If it can't, use another P-channel FET.
The part number for the FET is almost certainly not correct -- you want to find a "logic-level" P-channel FET with an \$RDS_{ON}\$ small enough so that the PIR sensors won't notice the voltage drop.

simulate this circuit – Schematic created using CircuitLab

A: PIRs use so little current that you can power them directly from the AVR GPIO pins
the photoresistor can be powered this way too saving even more energy, you only need to check for light once every second or so...


text:
Q: Server 2008 will not boot after mobo swap Current Spec:
Intel i3-3220
GA-H77-DS3H (New)
1x8gb ddr3 1600
2x500 gb WDC wd5003abyx drives; raid1
windows server 2008 R2 foundation
The system was working fine utilizing the gigabyte GA-h77m-d3h and hung during a shutdown. The system was force powered off, and upon restart was indicating a memory error. (3 short beeps small pause, 3 more short beeps) Once I was sure the memory was fine (tested known good sticks, and original stick on different mobo) I found the closest motherboard I could to the original.
Upon installation the computer posted fine but I was greeted with "your computer did not shutdown properly, option to repair or boot normal. Tried booting normal and received Windows Failed to start. A recent hardware or software change might be the cause error code 0x000000e
When booting from installation media, when I attempt to repair I am greeted with "this version of system recovery options is not compatible with the version of windows you are trying to repair. I believe that is do to the disk being raid1. -- I am able to disconnect one of the drives to receive some options of getting into the command prompt etc.
Boot Option1: Intel Raid
Boot Option2: UEFI DVDRam
Sata Controllers: Enabled
Sata Mode Selection: Raid
Any advise where to go from here? Can I break the raid1 and not have any data loss?
Note* I know you should reinstall for a mobo or major hardware swap but I did not have that option unfortunately, and was hoping with a similar enough chipset everything could work out.
Any suggestions greatly appreciated!


text:
Q: How do I compare text lines in 2 files between 2 specific characters in a C++ program I have this program I am writing that cleans up a xml file and adds new lines to a settings section from a txt file. Part of it I have a section labeled //  Part in my code. It is during or after that section, either is fine, I would like to compare the lines to make sure they are not duplicated but ignore their setting in this case True and False and consider them identical if one is set to true and the other set to false and only keep the second line and discard the first. Here is an example of how the settings look:
    <setting1>true</setting1>
    <setting2blue>false</setting2blue>
    <setting3>true</setting3>
    <setting1>false</setting1>
    <setting4>true</setting4>
    <setting2blue>true</setting2blue>

So in the end I would like the first setting 1 to be removed and the second setting 1 to stay and same thing for setting 2. Keep in mind this is an example as the settings have different names and sometimes contain the same words.
I've tried to use .compare but got really lost as I am still very new to C++.  I even though that I might need to do a new in stream and out stream and then compare after my previous work was done but I am still getting hung up on how to compare.
I appreciate any help.
Thanks,
Vendetto
Here is part of the program I broke out to test in without having to run the whole thing.
#include <stdio.h>
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <vector>
#include <algorithm>
#include <cassert>
#include <Windows.h>
using namespace std;

bool isSpace(unsigned char c) {
    return ( c == '\r' ||
        c == '\t' || c == '\v' || c == '\f');
}

int main()
{

    const string Dir{ "C:/synergyii/config/" };
    ifstream in_config{ Dir + "clientconfig.xml" },
        in_newlines{ Dir + "newlines.txt" };
    ofstream out{ Dir +  "cltesting.txt" };

    vector<string> vlines31;
    vector<string> vlines32;
    set<string>    slines31;
    set<string>    slines32;

    for (string line31; getline(in_config, line31); vlines31.push_back(line31))
        if (line31.find("<settings>") != string::npos) {
            vlines31.push_back(line31);
            break;
        }

    for (const auto& v : vlines31)
        out << v << '\n';

    // <settings> Part

    for (string line32; getline(in_config, line32) && line32.find("</settings>") == string::npos; ) {
        line32.erase(remove_if(line32.begin(), line32.end(), isSpace), line32.end());
        line32.erase(line32.find_last_not_of(" ") + 1);
        const auto& result = slines32.insert(line32);
        if (result.second)
            vlines32.push_back(line32);
    }

    for (string line32; getline(in_newlines, line32);) {
        line32.erase(remove_if(line32.begin(), line32.end(), isSpace), line32.end());
        const auto& result = slines32.insert(line32);
        if (result.second)
            vlines32.push_back(line32);
    }

    vlines32.erase(unique(vlines32.begin(), vlines32.end()), vlines32.end() );

    for (auto it = vlines32.cbegin(); it != vlines32.cend(); ++it)
        out << '\t' << '\t' << *it << '\n';

    out << '\t' << "</settings>\n";
    out << "</config>\n";

    in_config.close();
    out.close();
}

A: A note about XML first:
XML allows formatting which doesn't necessarily change the meaning of its contents. Beside of indentation, an element might be written in one line or spread over multiple lines. It's even allowed to write the whole XML file in one line (assuming there are no newlines in the element's contents like in OPs case).
Reading XML correctly with C++ standard I/O is more complicated than a few std::getline()s. To do it right, an XML library should be used to read the XML file into a DOM to do the intended processing.
E.g. SO: What XML parser should I use in C++? provides an overview about available XML libraries.

That being said, I want to demonstrate a possible solution for OPs question but using another even simpler config. format – key value pairs separated by a colon (:).
How to filter out duplicated keys:
The solution is actually simple:
The whole file is read line by line into a vector of strings.
If a line contains a key the key is stored in a look-up table.
If the key was already in that look-up table the previous occurrence (line) is remarked as invalid. To keep it simple, I just clear the line. If empty lines may be valid contents (which shall be kept in file) something else should be used to remark the line e.g. an extra bool stored with each line.
I didn't consider removal of lines as an option because this would invalidate the stored line indices of all keys for following lines (or I had to iterate through the look-up table to fix them).
Demo:
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>

std::vector<std::string> lines;

using LookUpTable = std::map<std::string, size_t>;

LookUpTable lut;

std::istream& readLine(std::istream &in)
{
  std::string line; if (!std::getline(in, line)) return in;
  const size_t iLine = lines.size();
  // extract key
  const size_t i = line.find(':');
  if (i < line.size()) { // Has the line a key at all?
    std::string key = line.substr(0, i);
    // look whether there was already this setting
    const LookUpTable::iterator iter = lut.find(key);
    if (iter != lut.end()) { // Was it already there?
      // clear previous line
      lines[iter->second].clear();
    }
    // store key and line index
    lut.emplace(std::move(key), iLine);
  }
  // store line in lines buffer
  lines.push_back(std::move(line));
  // done
  return in;
}

void readFile(std::istream &in)
{
  while (readLine(in));
}

void writeFile(std::ostream &out)
{
  for (const std::string line : lines) {
    // skip empty lines
    if (line.empty()) continue;
    // write non-empty lines
    out << line << '\n';
  }
}

int main()
{
  std::string sample = R"(# sample config file
setting1: true
setting2blue: false
setting3: true
setting1: false
setting4: true
setting2blue: true
)";
  // read the sample
  { std::istringstream in(sample);
    readFile(in);
  }
  // write the sample (with clean-up)
  std::cout << "Output:\n";
  writeFile(std::cout);
}

Output:
Config.:
# sample config file
setting3: true
setting1: false
setting4: true
setting2blue: true

Live Demo on coliru
Nit-picking:
An unordered map may provide a possible even-faster look up than a map. It may pay for this with a possible higher memory foot-print. I doubt that this difference is essential for the task but with a minimal change, it works with an unordered_map as well:
Live Demo on coliru