text:
Q: Database locked SQLite Java I'm making some programme for checking approaches scales for different usernames. When I call function DodajObrisiPristupe(table, comboBox), it says database locked. I searched for solutions and all says that it's probably that I didn't close connection somewhere, but I can't find where. Can anyone please help me?
public void DodajObrisiPristupe(JTable tabela, JComboBox<String> korisnickoime)
{
    DefaultTableModel model = (DefaultTableModel)tabela.getModel();

    for (int i = 0; i < model.getRowCount(); i++)
    {
        String serijskibroj = model.getValueAt(i, 2).toString();
        boolean pristup = (Boolean)model.getValueAt(i, 4);

        if(ProveriDaLiPostojiPristup(serijskibroj, korisnickoime.getSelectedItem().toString()) == true)
        {
            if(pristup == false)
                ObrisiPristup(serijskibroj, korisnickoime.getSelectedItem().toString());
        }

        else
        {
            if(pristup == true)
                DodajPristup(serijskibroj, korisnickoime.getSelectedItem().toString());
        }
    }
}

public boolean ProveriDaLiPostojiPristup(String serijskibroj, String korisnickoime)
{
    Connection c = null;
    Statement stmt = null;

    try {

        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:" + naziv + ".db");

        stmt = c.createStatement();

        ResultSet rs = stmt.executeQuery("SELECT * FROM PRISTUPI;");

        while(rs.next())
        {
            if(Decrypt(rs.getString("korisnickoime")).equals(korisnickoime) && Decrypt(rs.getString("vage")).equals(serijskibroj))
                return true;
        }

        rs.close();
        stmt.close();
        c.close();
    }
    catch ( Exception e ) {

        System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        System.exit(0);
    }

    return false;
}

public void DodajPristup(String serijskibroj, String korisnickoime)
{
    Connection c = null;
    Statement stmt = null;

    try {

        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:" + naziv + ".db");

        stmt = c.createStatement();

        String sql = "INSERT INTO PRISTUPI (KORISNICKOIME,VAGE) " +
                  "VALUES ('" + Encrypt(korisnickoime) + "', '" + Encrypt(serijskibroj) + "');";
        stmt.executeUpdate(sql);

        stmt.close();
        c.close();
    }
    catch ( Exception e ) {

        System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        System.exit(0);
    }
}

public void ObrisiPristup(String serijskibroj, String korisnickoime)
{
    Connection c = null;
    Statement stmt = null;

    try {

        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:" + naziv + ".db");

        stmt = c.createStatement();

        String sql = "DELETE from PRISTUPI where KORISNICKOIME = '" + Encrypt(korisnickoime) + "' AND VAGE = '" + Encrypt(serijskibroj) + "';";
        stmt.executeUpdate(sql);

        stmt.close();
        c.close();
    }
    catch ( Exception e ) {

        System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        System.exit(0);
    }
}

A: You are not closing your connection in ProveriDaLiPostojiPristup(String, String).
You should always wrap your connections in try-with-resources or try-finaly, so they are always closed.

   c = DriverManager.getConnection("jdbc:sqlite:" + naziv + ".db");

    stmt = c.createStatement();

    ResultSet rs = stmt.executeQuery("SELECT * FROM PRISTUPI;");

    while(rs.next())
    {
        if(Decrypt(rs.getString("korisnickoime")).equals(korisnickoime) &&
            Decrypt(rs.getString("vage")).equals(serijskibroj))
            return true;
    }

    rs.close();
    stmt.close();
    c.close();

What happens, is that your method returns true, but because the execution is stopped there, it won't execute the lines below it. This can be countered if you wrap the statements in a try with resources block:
try(c = DriverManager.getConnection("jdbc:sqlite:" + naziv + ".db")){

   try(stmt = c.createStatement()){

     try(ResultSet rs = stmt.executeQuery("SELECT * FROM PRISTUPI;")){

        while(rs.next())
        {
            if(Decrypt(rs.getString("korisnickoime")).equals(korisnickoime) && Decrypt(rs.getString("vage")).equals(serijskibroj))
                return true;
        }

     }
   }
}


text:
Q: Are there any alternative to Adobe Community forum? I want to know best forums in 2D animation industry. I know Adobe forum and Creative Cow as forum and Dribbble as community but I want to get interactive with more communities. Can you please help me discover them?

A: There are quite a few active subreddits on Reddit. First that comes to mind are r/motiondesign and r/aftereffects.

redpajama_set_name: RedPajamaStackExchange


text:
Q: why "extra characters after command" error shown for the sed command line shown? I have given the command line as shown below,
command:
sed '/dump 0 $2 $3 $4 $5/dump 1 $2 $3 $4 $5/g' base_file.properties

error showing

sed: -e expression #1, char 22: extra characters after command

while putting "s" option as
 sed 's/dump 0 $2 $3 $4 $5/dump 1 $2 $3 $4 $5/g' base_file.properties

error is showing as

sed: -e expression #1, char 32: unknown option to `s'

A: It appears that some of the variables are expanding to values that contain a /.  Use a different delimiter that isn't contained in any of the variables, e.g.
sed 's@dump 0 $2 $3 $4 $5@dump 1 $2 $3 $4 $5@g' base_file.properties

(Your first command isn't a valid sed expression.)


text:
Q: Could not find method implementation() for arguments in Flutter When I try to integrating FireBase to my Flutter project, I'm getting the following error:

"Could not find method implementation() for arguments
[com.android.support:multidex:1.0.3] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler".

File pubspec.yaml:
version: 1.0.0+1
environment:
   sdk: ">=2.7.0 <3.0.0"

dependencies:
   flutter:
     sdk: flutter
  firebase_analytics: ^5.0.2
  firebase_core: ^0.4.0+9
  cloud_firestore: ^0.12.9+5`enter code here`
  cupertino_icons: ^0.1.3

  dev_dependencies:
     flutter_test:
       sdk: flutter

App build gradle (app\build.gradle):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28
        lintOptions {
            disable 'InvalidPackage'
        }
    defaultConfig {
        applicationId "com.example.flutter_demo_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

buildscript {
   dependencies {
       implementation 'com.android.support:multidex:1.0.3'
   }
}

Why this error is happening?

A: Update both firebase_core and cloud_firestore to the latest version:
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0+2

And inside build.gradle file upgrade the minSdkVersion to the following:
minSdkVersion 23

after performing the above actions, you need to remove the following line:
implementation 'com.android.support:multidex:1.0.3'


text:
Q: Android Room auto-generate and initialization I have a Room database that contains Stuff entities. These entities have an ID that will be auto-generated:
@Entity(tableName = "stuff")
data class Stuff(val text: String) {
    @PrimaryKey(autoGenerate = true) var id: Int = 0
}

There are two things I don't like with my code:

*

*I am initializing the id with 0, even though it should be initialized by Room.

*The id data member is mutable.

I tried using lateinit var but the compiler wouldn't let me do it on a primitive type. Is there a way to overcome the two issues mentioned above in Kotlin?

A: what do think about solving this using a secondary constructor?
@Entity(tableName = "stuff")
data class Stuff(
  @PrimaryKey(autoGenerate = true)
  val id: Int,
  val text: String
) {
   constructor(text: String) : this(0,text)
}


text:
Q: How to set Digital Signature in a box provided in PDF using iTextSharp In my PDF I am having one box I want to place digital signature in that box..How can I do it using iTextSharp.

iTextSharp.text.pdf.PdfStamper stamper = iTextSharp.text.pdf.PdfStamper.CreateSignature(reader, fout, '\0');

iTextSharp.text.pdf.PdfSignatureAppearance appearance = stamper.SignatureAppearance;
iTextSharp.text.pdf.BaseFont bf = iTextSharp.text.pdf.BaseFont.CreateFont(System.Web.HttpContext.Current.Server.MapPath("~/files/Arial.ttf"), iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 11);
appearance.Layer2Font = font;
//appearance.Image = new iTextSharp.text.pdf.PdfImage();
appearance.Reason = "Test";
appearance.Location = "Pune";

appearance.SetVisibleSignature("SignHere");
IExternalSignature es = new PrivateKeySignature(pk, "SHA-256");
MakeSignature.SignDetached(appearance, es, new Org.BouncyCastle.X509.X509Certificate[] { pk12.GetCertificate(alias).Certificate }, null, null, null, 0, CryptoStandard.CMS);
stamper.Close();


text:
Q: The readFile html parameter returns null in node When I run the code below, it brings back an error. I console.logged the html that was being sent in as a parameter and it returned null. How would i integrate a html file.
var http = require('http');
var fs = require('fs');

var hostname = '127.0.0.1'
var port = 3000;

fs.readFile("myFile.html", function(html, err){
    if(err){
        console.log(err);
    }
    var server = http.createServer((req, res) => {
        //says that everything is OK and working
        res.statusCode = 200;
        //Sets content type
        res.setHeader("Content-Type", "text/plain")
        //Writes html
        res.write(html);
        //Ends
        res.end();
    });

    server.listen(port, hostname, () => {
        console.log("Server Started on port " + port);
    });
})

A: You have fs.readFile's callback parameters mixed up. The first parameter is err, the second contains your data.
Change
fs.readFile("myFile.html", function(html, err) {

to
fs.readFile("myFile.html", function(err, html) {

Additionally, remember that HTML is not text/plain, it is text/html:
res.setHeader("Content-Type", "text/html")

Anyways, I am guessing that you are learning how to serve a website with Node. I would suggest checking out a library like express which really makes it much less of a pain in the ass.


text:
Q: On the intersection of two open affine subscheme I'm doing exercises 3.1—3.4 in the book of algebraic geometry by Hartshorne. Meet the following question, and is  the following assertion true?
Suppose $U_{1}=Spec A$ and $U_{2}=Spec B$ are two open affine subset of a scheme X, then
$Spec A \bigcap Spec B = \bigcup _{f \in A \bigcap B} D(f)$.


text:
Q: ffmpeg set output resolution by resizing image I'm trying to use ffmpeg for rendering video where an audio file and image are taken as inputs, and turned into a video (basically a music video) with the audio file playing for the duration of the video.
My current working command:
ffmpeg -loop 1 -framerate 2 -i "front.png" -i "testWAVfile.wav" -vf "scale=2*trunc(iw/2):2*trunc(ih/2),setsar=1,format=yuv420p" -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a aac -shortest -vf scale=1920:1080  "outputVideo.mp4"

Will set the output resolution of the video to whatever the resolution of the image is. Is there a way I can resize the image to enlarge it by a couple multiplications so that the output video resolution will be higher?
Like if my front.png image was 800x800 pixels, I could add something to my ffmpeg command to triple the resolution, so that the output video resolution is 2400x2400?

A: The simplest method is to use scale=iw*3:-1.
However, since using libx264 with yuv420p requires width x height to be divisible by 2 use scale=2*trunc(iw/2*3):-2.
Or just declare the size you want: scale=2400:-1
Example:
ffmpeg -loop 1 -framerate 2 -i "front.png" -i "testWAVfile.wav" -vf "scale=2*trunc(iw/2*3):-2,setsar=1,format=yuv420p" -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a aac -shortest "outputVideo.mp4"

*

*See scale filter and expression documentation for more info.

*Note that you should only use one -vf at a time as the other will be ignored.

*Upscaling is not recommended if you can avoid it. There quality will not be better as the additional information is simply interpolated.

*Many players won't like a frame rate of 2, so consider increasing it to 6 or more if you need full compatibility. If you're just uploading to YouTube then don't worry about it as it should be able to handle it.

A: Scale the image front.png using the ffmpeg cmd
ffmpeg -i front.png -vf scale=2400:2400 output_2400x2400.png

use the output of this cmd (output_2400x2400.png as input image) in your working video generating cmd
-vf scale=2400:2400


text:
Q: Redirecting after getting HttpWebResponse Hi I'm trying to execute a PHP auto log in API from another domain which accepts the log in details from POST.
I have tested the api using a simple PHP that sends parameters thru post method using the code below and was successfully redirected to the website logged in.

<form action="http://anotherdomain.com/index.php" method="POST">
Username: <input type="text" name="user" value="testuser" hidden>

Password: <input type="text" name="passw" value="hashedpassword">

API Login: <input type="text" name="apiuser" value="apiuser">

API PASS: <input type="text" name="apiuser" value="apipass">

<input type="submit" value="Autologin">
</form>

Now I want to do this on code behind. I have tried the code below but failed to redirect.
        string sAPIUser = "apiuser";
        string sAPIPassword = "apipass";
        string sURL = "http://anotherdomain.com/index.php";
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(sURL);
        string hashPassword = tbPassword.Text.Trim();

        string postData = "user=" + tbUserName.Text.Trim().ToUpper() + "&passw=" + hashPassword + "&apiuser=" + sAPIUser + "&apipass=" + sAPIPassword;

        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        webRequest.Method = "POST";
        webRequest.ContentType = "application/x-www-form-urlencoded";
        webRequest.ContentLength = byteArray.Length;
        webRequest.AllowAutoRedirect = true;
        Stream dataStream = webRequest.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();
        HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
        dataStream = webResponse.GetResponseStream();
        StreamReader reader = new StreamReader(dataStream);
        string sResponse = reader.ReadToEnd();
        reader.Close();
        webResponse.Close();

        //when displayed to label displays HTML code from site successfully logged in
        lMessage.Text = sResponse;

When I read the sResponse on HTML Visualizer it shows that the user is successfully logged in, but when I add "Response.Redirect(sURL);" it redirects to the site but not logged in. How can I automatically redirect the page after getting the response like the PHP code above. Please help. Thanks. vb.net code is also okay.

A: In the HTML form you have the input field named APILOGIN but when you create the postData string in your code you name it apiuser


text:
Q: Is there a way to keep internet connection alive? Im running linux and I have a task which runs only after midnight. The internet connection I use for this, goes offline if there's a period of inactivity and I want to keep the internet connection alive until midnight by some means (ex: putting it to some MINIMAL use so as to keep connection "active").
What is the best method to accomplish this task ?

A: the easiest way I can think of would be to add a cron job which pings a dns server by adding a line like this one to /etc/crontab :
#
#┌───────────── minute (0 - 59)
#│ ┌───────────── hour (0 - 23)
#│ │    ┌───────────── day of month (1 - 31)
#│ │    │ ┌───────────── month (1 - 12)
#│ │    │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
#│ │    │ │ │                                       7 is also Sunday)
#│ │    │ │ │
#│ │    │ │ │
#* *    * * *

 * *    * * *   user    ping -c 3 8.8.8.8 &> /dev/null

This command would ping Google's DNS server 8.8.8.8 3 times every minute.
"user" should be replaced with any of your system users.
/dev/null is there to mute the output of the command and prevent it to go in /var/log/syslog
You need to understand though how frequently you are required to ping the server in order to keep your connection alive. Hopefully you don't need to do it every minute.
If the frequency should be in the order of seconds then you need to write a customized script and run it from crontab instead of the "ping" command.
It would be also better to ping a server of yours living outside your network (if you have one) instead of Google's DNS.

A: The best option is obviously to reconfigure your router/modem so that it won't take your internet connection  offline during the hours you need it to be online.


text:
Q: Insert Javascript variable into Html.Partial ViewDataDictionary ASP.NET MVC I have a javascript function and when it is called I want to insert a partial into a div. All is working fine, but, when I want to pass some javascript into Html.Partial ViewDataDictionary, it isn't passing the rendered javascript.
<script>

function addExperience() {

     @{var uid = @MvcHtmlString.Create("new Date().getTime()");}
     console.info(@uid); //output ok !

     var partialView = @(Html.Raw(JsonConvert.SerializeObject(Html.Partial("~/Views/Dashboard/_editUserExperience.cshtml", Model,  new ViewDataDictionary { { "id", uid } }).ToString().Trim('"'))))

     $("#newExperienceSection").append(partialView); //it renders "new Date().getTime(), not the number
}

</script>

Thank you !

A: If you call Jsonconvert.SerializeObject with a string (Html.Partial returns a string), it returns a string.
So you statement
var partialView = ... will be rendered as
var partialView = "the contents of the partial view";

That's why, when you do this:
$("#newExperienceSection").append(partialView);

it actually displays the javascript as text.
If you want to get a partial view to execute javascript, you can return javascript inside script tags, and as soon as you add that to the DOM it gets executed, for example if you set your _editUserExperience.cshtml as this:
<script>
  alert('this gets executed as soon as you do add this to the DOM with the jQuery append command');
</script>

When you execute $("#newExperienceSection").append(partialView); you'll see the alert.
An easier way to insert a partial view is to take advantage of $.ajax, for example, in addExperience:
$.get('@Url.Action("ActionMethodThatReturnsPartial", "YourController")').done(function(theHtmlReturned) {
  $("#newExperienceSection").html(theHtmlReturned);
});

($.get is just shorthand for $.ajax using a get request)
Source: http://api.jquery.com/jquery.ajax/
http://api.jquery.com/jquery.get/
http://api.jquery.com/category/deferred-object/


text:
Q: Second-order star convex set: A set whose intersection with any conics passing through two given points consists of at most two connected curves. Motivation

I'm contemplating about what is the geometric property whose special case would be the property of $\mathop{epi}(f)$ for a function $f$ with $f^{(3)}\geq 0$, akin to convexity being the special case of the property of $\mathop{epi}(f)$ for $f$ with $f''\geq 0$? (Note that $S=\mathop{epi}(f)$ of a convex function besides for being convex is such that $S+\{0\}\times \Bbb R_+ = S$, so convexity is indeed a more general property than the one that $\mathop{epi}(f)$ satisfies.)

Consider the following definitions:

Definition 1: We say that a set $S\subset \Bbb R^2$ is second order start-convex with respect to points $s_0\in S, \bar s_0 \in \Bbb R^2 \setminus S$ if for any conic $C$ containing both $s_0$ and $\bar s_0$ the set $S \cap C$ consists of at most 2 connected sets (in the sense that two branches of hyperbola are regarded as a connected curves).

In intuitive terms, any conic passing through both $s_0$ and $\bar s_0$ can not "reenter" $S$ twice.

Definition 2: We say that a set $S\subset \Bbb R^2$ is second order start-convex with respect to line $L\ni (0,0)$ if for any parabola $P$ with the axis of symmetry parallel to $L$ the set $S \cap P$ consists of at most two connected curves.

In intuitive terms, any parabola with the axis of symmetry parallel to $L$ can not "reenter" $S$ twice.

Questions

*

*Is there an established term for what I call second order start-convex set?

*How to make Definition 2 a special case of Definition 1 for a special choice of points $s_0,\bar s_0$. (In my understanding all the parabolas with axis of symmetry parallel to a line $L$ have two points at the infinity in common, but I'm struggling formulating it.)

Analogy
A star-convex set can be similarly characterized as follows:

A set $S\subset \Bbb R^2$ is start-convex with respect to the vantage point $s_0 \in S$ if for any line $L$ passing through $s_0$ the set $S \cap L$ is connected.

Closely related questions

*

*Geometric characterization of functions with positive third derivative

*A higher-order analogy of the fact that a set is star-convex with vantage point at every point in it iff it is convex.


text:
Q: Heroku CLI authentication issue After a fresh install of Heroku on Windows 7, I can't seem to authenticate from the command-line.
Running the command: heroku login prompts me to enter my credentials. After doing so, I received an error:
heroku: Enter your login credentials
Email: my_email
Password: ************
Error: ENOENT: no such file or directory, open 'z:/_netrc'

I am using PowerShell, and when I run the command cat z:/_netrc, I get this error:
cat : Cannot find drive. A drive with the name 'z' does not exist.

Z: is a network drive, and it is accessible from the file explorer.
I already have a .netrc file in my %HOME% path, but it does not contain the heroku login credentials.
Looking at the official documentation and CLI help, I couldn't find anything useful to fix this. How can I login to my heroku account?
> heroku version
heroku/7.16.6 win32-x64 node-v10.11.0

A: So, the issue is arising from not finding  _netrc file on your local computer that is required to complete login with Heroku. I have decided to create the file into following location of my windows 10 computer:
cmd>set HomeDrive=C:/Users/your Windows username/AppData/Local/heroku

In my case,
cmd>set HomeDrive=C:/Users/CrazyMoby/AppData/Local/heroku

Finally I ran heroku login
The above step resolved heroku login issue in my case.

A: Use setx HOME <netrc_default_location>
where <netrc_default_location> can be:

*

*<%NETRC%>\_netrc

*<%HOME%>\_netrc

*<%HOMEDRIVE%%HOMEPATH%>\_netrc

*<%USERPROFILE%>\_netrc

Some clarification can be found here and here.
Probably it's your user <%USERPROFILE%>.
But if you don't need it, just remove _netrc file, reboot and log in again.

A: Run the following command in powershell and the problem should be solved.
$Env:HOMEDRIVE = "C:"
If you need more information, check out the docs on windows environment variables.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7

A: This way work for me. Write in PowerShell next code , where "paulob" need change to your user, because folser "_netrc" exist in:
$Env:HOMEDRIVE = "C:\Users\paulob\"

A: Try running it from GIT BASH cmd instead of PowerShell if you can, I had the same problem and it worked in my case.


text:
Q: mdadm RAID5 to RAID6 migration thrown exceptions, access to data lost After a dozen of hours waiting for my array reshape to move on I think it's finally the right time to ask you for some advice.
Recently I bought 4th WD Red 4TB drive to migrate my 3-disk RAID5 setup to RAID6. All disks are WD Red 4TB, so I have 8TB of usable space. The space occupation is right now at 50%.
I've installed the 4th disk and added it to the /dev/md0 with the following command:
mdadm --manage /dev/md0 --add /dev/sdf1

Then I've started the RAID5 to RAID6 migration with the following command:
mdadm --grow /dev/md0 --level=6 --raid-disk=4

The grow operation started and initially the speed was pretty decent compared to what I've found over the Internet (example), but after 12 hours I've reached 44k/sec and right it's 10k/sec. The cat /proc/mdstat looks as follows:
Personalities : [raid6] [raid5] [raid4]
md0 : active raid6 sdf1[6] sdd1[4] sda1[5] sde1[3]
      7813771264 blocks super 1.2 level 6, 512k chunk, algorithm 18 [4/3] [UUU_]
      [>....................]  reshape =  0.1% (4931044/3906885632) finish=6498319.2min speed=10K/sec
      bitmap: 8/30 pages [32KB], 65536KB chunk

unused devices: <none>

The reshape process didn't move from 4931044 for 5-6 hours in the time of writing this question.
The disk layout of the system i'm working on is the following (a dump from lsblk):
NAME               MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda                  8:0    0  3.7T  0 disk
└─sda1               8:1    0  3.7T  0 part
  └─md0              9:0    0  7.3T  0 raid6
    └─vg_data-data 254:0    0  7.3T  0 lvm   /data
sdb                  8:16   0 55.9G  0 disk
├─sdb1               8:17   0 53.6G  0 part  /
├─sdb2               8:18   0    1K  0 part
└─sdb5               8:21   0  2.3G  0 part  [SWAP]
sdc                  8:32   0  1.8T  0 disk
└─sdc1               8:33   0  1.8T  0 part  /mnt/Backup-usb
sdd                  8:48   0  3.7T  0 disk
└─sdd1               8:49   0  3.7T  0 part
  └─md0              9:0    0  7.3T  0 raid6
    └─vg_data-data 254:0    0  7.3T  0 lvm   /data
sde                  8:64   0  3.7T  0 disk
└─sde1               8:65   0  3.7T  0 part
  └─md0              9:0    0  7.3T  0 raid6
    └─vg_data-data 254:0    0  7.3T  0 lvm   /data
sdf                  8:80   0  3.7T  0 disk
└─sdf1               8:81   0  3.7T  0 part
  └─md0              9:0    0  7.3T  0 raid6
    └─vg_data-data 254:0    0  7.3T  0 lvm   /data

The /dev/md0 is mounted on /data
In order to speed up the migration I've adjusted the following parameters after the reshape was running:
sysctl -w dev.raid.speed_limit_min=100000
sysctl -w dev.raid.speed_limit_max=500000
echo 4096 > /sys/block/md0/md/stripe_cache_size
blockdev --setra 65536 /dev/md0

I've also issued echo max > /sys/block/md0/md/sync_max two times in order to see if it won't affect the speed positively.
My problem is that currently, the reshape process seems to be stuck. If dmesg | grep md0 is issued, the following problems are reported:
[58169.337512] md/raid:md0: raid level 6 active with 3 out of 4 devices, algorithm 18
[58169.805197] md: reshape of RAID array md0
[58169.805201] md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
[58169.805203] md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for reshape.
[58169.805208] md: using 128k window, over a total of 3906885632k.
[58359.078753] md/raid:md0: read error corrected (8 sectors at 9990072 on sdd1)
[58359.078758] md/raid:md0: read error corrected (8 sectors at 9990080 on sdd1)
[58359.078761] md/raid:md0: read error corrected (8 sectors at 9990088 on sdd1)
[58359.078763] md/raid:md0: read error corrected (8 sectors at 9990096 on sdd1)
[58359.078773] md/raid:md0: read error corrected (8 sectors at 9990104 on sdd1)
[58359.078774] md/raid:md0: read error corrected (8 sectors at 9990112 on sdd1)
[58359.078775] md/raid:md0: read error corrected (8 sectors at 9990120 on sdd1)
[58359.078780] md/raid:md0: read error corrected (8 sectors at 9990128 on sdd1)
[58359.078781] md/raid:md0: read error corrected (8 sectors at 9990136 on sdd1)
[58359.078791] md/raid:md0: read error corrected (8 sectors at 9990072 on sda1)
[58666.606583]       Tainted: G         C    3.16.0-4-amd64 #1
[58666.606721]       Tainted: G         C    3.16.0-4-amd64 #1
[58666.606825]       Tainted: G         C    3.16.0-4-amd64 #1
[58666.606948]       Tainted: G         C    3.16.0-4-amd64 #1
[58666.607039]       Tainted: G         C    3.16.0-4-amd64 #1
[58666.607148] INFO: task md0_reshape:17403 blocked for more than 120 seconds.
[58666.607168]       Tainted: G         C    3.16.0-4-amd64 #1
[58666.607206] md0_reshape     D ffff880216d33748     0 17403      2 0x00000000
[58666.607225]  [<ffffffffa0333cf2>] ? is_mddev_idle+0xd2/0x140 [md_mod]
[58666.607229]  [<ffffffffa0336df4>] ? md_do_sync+0x944/0xd80 [md_mod]
[58666.607233]  [<ffffffffa0333b87>] ? md_thread+0x107/0x120 [md_mod]
[58666.607238]  [<ffffffffa0333a80>] ? md_stop+0x40/0x40 [md_mod]
[58786.578974]       Tainted: G         C    3.16.0-4-amd64 #1
[58786.579191]       Tainted: G         C    3.16.0-4-amd64 #1
[58786.579342]       Tainted: G         C    3.16.0-4-amd64 #1
[58786.579508] INFO: task md0_reshape:17403 blocked for more than 120 seconds.
[58786.579545]       Tainted: G         C    3.16.0-4-amd64 #1
[58786.579612] md0_reshape     D ffff880216d33748     0 17403      2 0x00000000
[58786.579639]  [<ffffffffa0333cf2>] ? is_mddev_idle+0xd2/0x140 [md_mod]
[58786.579644]  [<ffffffffa0336df4>] ? md_do_sync+0x944/0xd80 [md_mod]
[58786.579651]  [<ffffffffa0333b87>] ? md_thread+0x107/0x120 [md_mod]
[58786.579658]  [<ffffffffa0333a80>] ? md_stop+0x40/0x40 [md_mod]

Moreover, I cannot access /data contents. If I issue cd /data everything seems to be fine, but if I list the contents the command ls literally hangs returning no result and forcing me to kill ssh session to the server.
I'm using mdadm - v3.3.2 - 21st August 2014 running on Debian Linux debnas 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux.
The output from iostat -k 1 2 is the following:
Linux 3.16.0-4-amd64 (debnas)   09/02/2019      _x86_64_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.25    0.00   15.25   36.91    0.00   46.59

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sdb               4.42        16.33        37.55    2191851    5038772
sda              60.00     29162.00        78.31 3913364324   10508977
sdc               0.11         0.15         0.00      19751         40
sdd              59.64        40.30     29191.39    5408213 3917308368
sde              59.97     29162.68        77.94 3913455394   10459365
sdf               0.12         0.03        36.79       4157    4936637
md0               1.79         7.45        75.01     999197   10066300
dm-0              1.71         7.44        75.01     998645   10066300

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.50    0.00   25.00   74.50    0.00    0.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sdb               0.00         0.00         0.00          0          0
sda               0.00         0.00         0.00          0          0
sdc               0.00         0.00         0.00          0          0
sdd               0.00         0.00         0.00          0          0
sde               0.00         0.00         0.00          0          0
sdf               0.00         0.00         0.00          0          0
md0               0.00         0.00         0.00          0          0
dm-0              0.00         0.00         0.00          0          0

UPDATE 201909021128:
As dmesg reports read errors on sda and sdd I'm publishing the complete output of smartctl -a for both drives.
user@debnas:/home/user# smartctl -a /dev/sda
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Red (AF)
Device Model:     WDC WD40EFRX-68N32N0
Serial Number:    WD-WCC7K0YEYNV9
LU WWN Device Id: 5 0014ee 2663bb359
Firmware Version: 82.00A82
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      3.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Sep  2 11:27:38 2019 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (45360) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 482) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.
SCT capabilities:              (0x303d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   225   163   021    Pre-fail  Always       -       3741
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       66
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   100   253   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       183
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       66
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       20
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       52
194 Temperature_Celsius     0x0022   113   105   000    Old_age   Always       -       37
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

user@debnas:/home/user# smartctl -a /dev/sdd
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Red (AF)
Device Model:     WDC WD40EFRX-68N32N0
Serial Number:    WD-WCC7K2HNS0C0
LU WWN Device Id: 5 0014ee 211682e4b
Firmware Version: 82.00A82
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      3.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Mon Sep  2 11:30:55 2019 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (43920) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 466) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.
SCT capabilities:              (0x303d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   100   253   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   228   200   021    Pre-fail  Always       -       3583
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       8
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       38
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       8
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       6
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       6
194 Temperature_Celsius     0x0022   113   104   000    Old_age   Always       -       37
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

Update 201909021143:
It seems that the md0_raid process is consuming all the CPU resources. After Issuing ps aux | grep md0 I can see the CPU utilization is 99.7% and the reshape is not consuming CPU at all:
root     17401 99.7  0.0      0     0 ?        R    Sep01 1348:35 [md0_raid6]
root     17403  0.0  0.0      0     0 ?        D    Sep01   0:04 [md0_reshape]

These are the last lines of dmesg:
[58786.579309] INFO: task postgres:5070 blocked for more than 120 seconds.
[58786.579342]       Tainted: G         C    3.16.0-4-amd64 #1
[58786.579371] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[58786.579409] postgres        D ffff8801e2860ff8     0  5070   3818 0x00000000
[58786.579412]  ffff8801e2860ba0 0000000000000082 0000000000012f40 ffff8801b4767fd8
[58786.579414]  0000000000012f40 ffff8801e2860ba0 ffff88021fa137f0 ffff88021fdbf578
[58786.579416]  0000000000000002 ffffffff8113eb70 ffff8801b4767ba0 0000000000000000
[58786.579419] Call Trace:
[58786.579421]  [<ffffffff8113eb70>] ? wait_on_page_read+0x60/0x60
[58786.579424]  [<ffffffff815178e9>] ? io_schedule+0x99/0x120
[58786.579426]  [<ffffffff8113eb7a>] ? sleep_on_page+0xa/0x10
[58786.579429]  [<ffffffff81517c6c>] ? __wait_on_bit+0x5c/0x90
[58786.579432]  [<ffffffff8113e976>] ? wait_on_page_bit+0xc6/0xd0
[58786.579434]  [<ffffffff810a95f0>] ? autoremove_wake_function+0x30/0x30
[58786.579437]  [<ffffffff8114dc7a>] ? pagevec_lookup_entries+0x1a/0x30
[58786.579440]  [<ffffffff8114e662>] ? truncate_inode_pages_range+0x302/0x5a0
[58786.579449]  [<ffffffffa02efb67>] ? __ext4_journal_stop+0x37/0xa0 [ext4]
[58786.579457]  [<ffffffffa02d075b>] ? ext4_rename+0x11b/0x660 [ext4]
[58786.579461]  [<ffffffff811d1212>] ? __inode_wait_for_writeback+0x72/0xc0
[58786.579464]  [<ffffffff812037f8>] ? __dquot_initialize+0x28/0x1c0
[58786.579467]  [<ffffffff810a95f0>] ? autoremove_wake_function+0x30/0x30
[58786.579475]  [<ffffffffa02c79f7>] ? ext4_evict_inode+0x127/0x4e0 [ext4]
[58786.579478]  [<ffffffff811c475c>] ? evict+0xac/0x170
[58786.579481]  [<ffffffff811c0548>] ? __dentry_kill+0x168/0x1d0
[58786.579484]  [<ffffffff811c064e>] ? dput+0x9e/0x170
[58786.579486]  [<ffffffff811b8588>] ? SYSC_renameat2+0x498/0x530
[58786.579491]  [<ffffffff811719a5>] ? vm_munmap+0x45/0x50
[58786.579494]  [<ffffffff8151adcd>] ? system_call_fast_compare_end+0x10/0x15

My questions are the following:

*

*What to do in order to move the reshape process forward?

*Do you think the data on the md0 is safe?

*How to access the data on md0 if I cannot cd to it?

*What are those stack traces in the dmesg output?
Help will be greatly appreciated.


text:
Q: Connecting Spring Cloud function using IAM DB Authentication I am trying to build a spring cloud function lambda that connects with AWS RDS using the IAM DB authentication.The token generated is valid for only 15 mins. do we need to refresh the token explicitly? Also what would be a good way to configure the data source to connect to the RDS instance from the spring cloud function?
I am following https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.Java.html approach.


text:
Q: Representing groups with two generators as graph automorphisms Suppose we have a group $G$ which can be generated by two elements $x$, $y$. Call $H$, $K$, $L$ the subgroups of $G$ generated by $x$, $y$ and $y^{-1}x^{-1}$, respectively.
With these data, we can build up a graph $\mathcal{G}$, by declaring the vertices of $\mathcal{G}$ to be the right-cosets of $H$, $K$ and $L$, and by adding an edge between two right-cosets if they have nonempty intersection. Obviously, $G$ acts faithfully on $\mathcal{G}$.
Geometrically, $\mathcal{G}$ can be seen a planar graph, made by triangles (the vertices of each triangle corresponds to right-cosets of different $H$, $K$, and $L$). Then, acting, e.g., by $x$ means to rotate  $\mathcal{G}$ around the vertex $H$. Furthermore, if $\mathcal{G}$ is represented on a constant-curvature surface, then the angle of such a rotation is $2\pi/|H|$. Similarly for $y$ and $y^{-1}x^{-1}$. In other words, $G$ is represented in the group of automorphisms of a regular tiling.
I've heard about this construction years ago during an undergraduate class, but back then I wasn't interested (I even forgot who was the lecturer). Lately, I rediscovered this, and I've spent few days searching the web, but I couldn't find anything resembling what I've explained above. Posting my question here is my last hope! Somehow, it looks such a simple idea, that it is hard to believe that it cannot be found anywhere!
More precisely, my question is the following:
Is there a standard construction to associate a graph $\mathcal{G}$ with a group with two generators $G$, in such a way that

*

*$\mathcal{G}$ can be realized as a regular tiling made of triangles on a constant-curvature surface, and

*$G$ can be seen as a subgroup in the group of automorphisms of $\mathcal{G}$?

A: I think what you are trying to remember is the triangle group $\langle x,y\mid x^k=y^l=(xy)^m=1\rangle$ (see Wiki). Depending on whether $1/k+1/l+1/m$ is less than, equal to or greater than 1, the group corresponds to a tessellation of a hyperbolic plane, Euclidean plane or a 2-sphere. The tesselation is constructed as you described.


text:
Q: Manipulation VirtualPathProvider cache I am building a cms System which depend on VirtualPathProvider.
I need to show the cashed page with ability to release this cache.
here is the code where the cache is built.
how can I access to this cache? to show a list of cached pages
public override CacheDependency GetCacheDependency(
string virtualPath,
System.Collections.IEnumerable virtualPathDependencies,
DateTime utcStart)
{
  if (IsPathVirtual(virtualPath))
  {
System.Collections.Specialized.StringCollection fullPathDependencies = null;

// Get the full path to all dependencies.
foreach (string virtualDependency in virtualPathDependencies)
{
  if (fullPathDependencies == null)
    fullPathDependencies = new System.Collections.Specialized.StringCollection();

  fullPathDependencies.Add(virtualDependency);
}
if (fullPathDependencies == null)
  return null;

// Copy the list of full-path dependencies into an array.
string[] fullPathDependenciesArray = new string[fullPathDependencies.Count];
fullPathDependencies.CopyTo(fullPathDependenciesArray, 0);
// Copy the virtual path into an array.
string[] virtualPathArray = new string[1];
virtualPathArray[0] = virtualPath;

return new CacheDependency(virtualPathArray, fullPathDependenciesArray, utcStart);
}
else
return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}

A: The Problem has been solved by creating CustomeCacheDependency
 public override CacheDependency GetCacheDependency(string virtualPath,
        System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
    {
         if (IsPathVirtual(virtualPath))
             {
                  return CashManager.SetPageCash(virtualPath);
             }
        return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
    }

public class SecuHostCacheDependency: System.Web.Caching.CacheDependency
{
    public CustomeCacheDependency()
    {
        base.SetUtcLastModified(DateTime.UtcNow);
    }
    public void Clear()
    {
         base.SetUtcLastModified(DateTime.UtcNow);
        NotifyDependencyChanged(this, EventArgs.Empty);
    }
}

public class CashManager
{
    // Page Cash
    public static CustomeCacheDependency SetPageCash(string url)
    {
       CustomeCacheDependency customeCacheDependency = new CustomeCacheDependency ();
 System.Web.HttpContext.Current.Application[url]=customeCacheDependency;

        return customeCacheDependency;
    }
    public static void ClearPageCash(string url)
    {
        CustomeCacheDependency  customeCacheDependency=
   System.Web.HttpContext.Current.Application[url] as customeCacheDependency;
        if (CustomeCacheDependency != null)
        {
          CustomeCacheDependency.Clear();
        }
    }
}


text:
Q: React Bootstrap remote row insert I am attempting insert a row into a table once it has been successfully stored in the database.
I am getting the following error:

Warning: Each child in a list should have a unique "key" prop.

I have added the "rowKey="id" parameter to the table component but I am still facing the same issue.
import React, { Component} from "react";
import editImage from '../../src/images/edit.png';
import './Payrolls.css';
import {BootstrapTable,TableHeaderColumn, RemoteInsertRow} from 'react-bootstrap-table';
import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'
import { Link } from 'react-router-dom'
import axios from "axios";
var currentComponent = null;

class Payrolls extends Component {

    componentDidMount() {
        this.getData();
    }

    constructor(props, context) {
        super(props, context);
         this.tableData = [Array]
        this.state = {
            tableData: [],
            selected: []
        };
        this.getData = this.getData.bind(this);
        this.onAddRow = this.onAddRow.bind(this);
    }

getData = () => {
  var self=this;
  axios.get('http://******.co.uk/payrolls.php', {
    })
    .then(function (response) {
       self.state.tableData.push(response.data)
      self.setState({tableData: response.data});
    })
    .catch(function (error) {
     self.props.history.push('/login');
      console.log(error);
    });
}

dateValidator(value, row) {
 if(value === ""){
  return 'You must select a date!';
 }else{
   return true;
 }
}

onAddRow = (row) => {
  // Save to server and on success:
  this.state.tableData.push(row)
  this.setState({
    tableData: this.tableData
  });
}

  render() {

    const { tableData } = this.state;

    const selectRowProp = {
        mode: 'checkbox'
    };

    function editButton(cell, row){
        if(row.status !== "Complete") {
            return ();
        }
    }

  return (

    Active Payrolls

<BootstrapTable data={ this.state.tableData }   remote={ true } insertRow={ true } pagination={ true } deleteRow={ true }  selectRow={ selectRowProp } options={ { onAddRow: this.onAddRow } } striped hover rowKey="id">
          <TableHeaderColumn dataField='id' autoValue ={true}  isKey={ true } hidden hiddenOnInsert>Payroll ID</TableHeaderColumn>
          <TableHeaderColumn dataAlign="center" dataField='creation_date' hiddenOnInsert>Creation Date</TableHeaderColumn>
          <TableHeaderColumn dataAlign="center" dataField='created_by' hiddenOnInsert>Created By</TableHeaderColumn>
          <TableHeaderColumn dataAlign="center" dataField='week_ending'  editable={ { type: 'date' ,validator: this.dateValidator} } >Week Ending</TableHeaderColumn>
          <TableHeaderColumn dataAlign="center" dataField='status' hiddenOnInsert>Status</TableHeaderColumn>
          <TableHeaderColumn dataAlign="center" dataFormat={editButton}></TableHeaderColumn>
      </BootstrapTable>

  );
}
}

export default Payrolls;


text:
Q: Error on creating new domain class I am new to Grails and I have just installed Groovy Grails Tool Suite on Ubuntu and can launch it.  However, following a tutorial when attempting to create a new domain class, I get the following error:

An internal error occurred during: "create-domain-class".
  java.lang.NullPointerException

Any assistance would be much appreciated.


text:
Q: Trim any illegal characters from NSURL before writing to disk I would like to write a string to an NSURL which may contain characters such as / or :, which are not supported by the file system. Is there any convenience method to trim these characters? Or maybe a reference containing all illegal characters, so that I can write such a method myself?

A: May be it's better just to escape them with something like this:
NSString *unescaped = @"http://www";
NSString *escapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
    NULL,
   (CFStringRef)unescaped,
    NULL,
   (CFStringRef)@"!*'();:@&=+$,/?%#[]",
    kCFStringEncodingUTF8);

NSLog(@"escapedString: %@",escapedString);

as it stated here?
Or you can just strip ! * ' ( ) ; : @ & = + $ , / ? % # [ ] characters, if you wish so.
Look here for a list of reserved characters.


text:
Q: Getting error 504: Gateway Time-out in dev server I've been struggling with a 504 error on my python app engine dev server.
I'm behind a corporate proxy but usually have no trouble by setting HTTP_PROXY and HTTPS_PROXY, I don't know if it is related to my problem.
In my code I use discovery from apiclient (main.py line 63)
driveService = discovery.build("drive", "v2", http=http)

When this executes, I get the following traceback
INFO     2013-10-07 13:49:42,812 discovery.py:190] URL being requested: https://www.googleapis.com/discovery/v1/apis/drive/v2/rest?userIp=%3A%3A1
ERROR    2013-10-07 13:49:55,848 wsgi.py:262]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 298, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 84, in LoadObject
    obj = __import__(path[0])
  File "c:\temp\iterlex-backend\main.py", line 63, in <module>
    driveService = discovery.build("drive", "v2", http=http)
  File "c:\temp\iterlex-backend\oauth2client\util.py", line 132, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "c:\temp\iterlex-backend\apiclient\discovery.py", line 192, in build
    resp, content = http.request(requested_url)
  File "c:\temp\iterlex-backend\httplib2\__init__.py", line 1464, in request
    cached_value = self.cache.get(cachekey)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\memcache\__init__.py", line 559, in get
    results = rpc.get_result()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 612, in  get_result
    return self.__get_result_hook(self)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\memcache\__init__.py", line 615, in __get_hook
    rpc.check_success()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 578, in check_success
    self.__rpc.CheckSuccess()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 226, in _MakeRealSyncCall
    encoded_response = self._server.Send(self._path, encoded_request)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "C:\tools\Python27\lib\urllib2.py", line 397, in open
    response = meth(req, response)
  File "C:\tools\Python27\lib\urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\tools\Python27\lib\urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "C:\tools\Python27\lib\urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "C:\tools\Python27\lib\urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 504: Gateway Time-out
HTTPError()

If I try the offending URL with curl in the same console windows, it works (i have to use the -k option though)
C:\temp> curl -k https://www.googleapis.com/discovery/v1/apis/drive/v2/rest?userIp=%3A%3A1
{
 "kind": "discovery#restDescription",
 "etag": "\"XflbyoTZtBo225MnsgwJQ-FHlhA/AFnpisGyT0XxOrZz7gMWdR5PpRg\"",
...

Being new to app engine and python, I confess I'm a bit lost, any help would be greatly appreciated
Thanks!
Nicolas


text:
Q: Polymer.dart: How to set read-only property to read-write attribute? I have a polymer component(lets call it component-one) which exposes an attribute value. I want to use this in another polymer component which has an Observable list property called data. I want to do the following:
<template repeat="{{obj in data}}">
    <component-one value="{{obj}}"></component-one>
</template>

But it generates error saying that there is no "obj=" method.
Can somebody let me know how to data-bind a read-only property to a read-write attribute?
Thanks for your time!

A: Seems you are running into this bug https://code.google.com/p/dart/issues/detail?id=17981. This bug seems to be fixes for about 6 weeks.
You should check that you use a recent Dart version and a recent Polymer package.
If this doesn't help please add a comment.


text:
Q: Why can't a smart pointer call new() for me in its constructor? Is it possible to write a smart pointer which allocates the object itself in its constructor - instead of the developer having to call new?  In other words, instead of writing:
std::unique_ptr<myClass> my_ptr(new myClass(arg1, arg2))
...one could write:
std::smarter_ptr<myClass> my_ptr(arg1, arg2)
Is the language syntax capable of expressing this?  Would this be desirable?  Hideous?  I'm thinking in particular of protecting against this mistake (which I've made myself, of course):
myFunction(std::unique_ptr<myClass>(new myClass()), std::unique_ptr<myClass>(new myClass()))
...which risks leaking whichever object is allocated first if the second allocation happens and throws before the first object is safely ensconced in its smart pointer.  But would a smarter pointer actually make this safe?

A: This is newly possible with C++11 which added perfect forwarding and variadic templates.

A: It's essentially the same problem that necessitate std::find and std::find_if. You can't distinguish this ctor from the existing ctors of shared_ptr in the new myClass(arg1) case. The number of arguments is equal, and arg1 can have any type.
Therefore, you need another name, and that's make_shared

A: Look at the implementation of make_shared(). It does this allocates a new object and creates a shared_ptr out of it.

A: In general, this can't be done with a smart pointer's constructor; there would be an ambiguity over whether a pointer argument should be used to initalise the smart pointer, or forwarded to create a new object.
It can be done with a factory function, for example:
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
    return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

If you're using std::shared_ptr, then you can use std::make_shared. This also gives the advantage of only requiring one memory allocation, where std::shared_ptr<T>(new T) will require one for the object and a second for the shared reference count.


text:
Q: How to easily change the default compiler optimization option for a project? I am now a sophomore in university and just started learning compiler few months ago. I am wondering what tool will make it easier if I want to enable -O3 as default option instead of -O1.

A: To change the global compiler defaults for all projects, you will have to install a new spec file in the place where your GCC installation expects it (for example, /usr/lib/gcc/x86_64-linux-gnu/6/specs). See Spec Files in the GCC documentation.  This might work:
*cc1_options:
+ %{!O*:-O3}

*cc1plus_options:
+ %{!O*:-O3}

It enables -O3 if no -O option is set.
Note that this risks breaking quite a few build systems because few of them will expect that -O3 is enabled by default.


text:
Q: Stuck with ForLoop and Inserting DataFrame I have this DataFrame:
    manufacturer    description
0   toyota          toyota, gmc 10 years old.
1   NaN             gmc, Motor runs and drives good.
2   NaN             Motor old, in pieces.
3   NaN             2 owner 0 rust. Cadillac.

And I want to fill the NaN values with keyword taken from the description. To that end I created a list with the keywords I want:
keyword = ['gmc', 'toyota', 'cadillac']

Finally, I want to loop over each row in the DataFrame. Split the contents from the "description" column in each row and, if that word is also in the "keyword" list, add it in the "manufacturer" column. As an example, it would look like this:
    manufacturer    description
0   toyota          toyota, gmc 10 years old.
1   gmc             gmc, Motor runs and drives good.
2   NaN             Motor old, in pieces.
3   cadillac        2 owner 0 rust. Cadillac.

Thanks to a friendly person in this community I could improve my code to this:
import re
keyword = ['gmc', 'toyota', 'cadillac']
bag_of_words = []
for i, description in enumerate(test3['description']):
bag_of_words = re.findall(r"""[A-Za-z\-]+""", test3["description"][i])
for word in bag_of_words:
    if word.lower() in keyword:
            test3.loc[i, 'manufacturer'] = word.lower()

But I realized that the first row also changed values even though it was not NaN:
  manufacturer  description
0   gmc         toyota, gmc 10 years old.
1   gmc         gmc, Motor runs and drives good.
2   NaN         Motor old, in pieces.
3   cadillac    2 owner 0 rust. Cadillac.

I would like to only change the NaN values but when I try to add:
if word.lower() in keyword and test3.loc[i, 'manufacturer'] == np.nan:

It doesn't have any effect.

A: Here is a quick fix. You did several things wrong:

*

*Mixing up the index of description and the description itself (solved by enumerate()).

*bag_of_words should be renewed for each word, not appended.

*Wrong item being iterated (should be word, not bag_of_words).

Some of the errors can be easily seen if intuitive/conventional names were chosen. Do spend some time on that.
Code:
from nltk.tokenize import RegexpTokenizer

# test3 = the main dataset
keyword = ['gmc', 'toyota', 'cadillac']

tokenizer = RegexpTokenizer('\w+|\$[\d\.]+|\S+')

for i, description in enumerate(test3['description']):
    bag_of_words = tokenizer.tokenize(description.lower())
    for word in bag_of_words:
        if word in keyword:
            test3.loc[i, 'manufacturer'] = word

Output:
test3
Out[31]:
  manufacturer                       description
0       toyota             toyota, 10 years old.
1          gmc  gmc, Motor runs and drives good.
2          NaN             Motor old, in pieces.
3     cadillac         2 owner 0 rust. Cadillac.

re.findall() over RegexpTokenizer
I personally think nltk is a relatively heavy module to be imported, installed and deployed. If only a string split is to be conducted, I'd recommend using re.findall to extract the valid word patterns. For example:
import re

# won't extract numbers, currency signs and apostrophes
re.findall(r"""[A-Za-z\-]+""", test3["description"][3])

# the output is much cleaner than before
Out[39]: ['owner', 'rust', 'Cadillac']

But this is up to the choice of user depending on the entire task.


text:
Q: How can I calculate the ratio of distance between 2 longitudes at different latitudes? Suppose i have to calculate the ratio of lengths of AB and CD where A(0° N,0° E) and B(0°N,30° E), and C(30°N,0°E) and D(30°N,30° E)
the values are just as an example.Is it possible to get the ratio in terms of theta(latitude of AB) and phi(latitude CD) and not having radius of earth in equation(which i suppose should be cancelled when we take ratio)

A: Assuming the Earth is a sphere (which is a good approximation) radius $R$, and assuming you want great-circle distances (which you should) then given two points with latitude and longitude $\phi_1, \theta_1$, $\phi_2, \theta_2$ then the great-circle distance between them is
$$R \cos^{-1}\left(\sin\phi_1 \sin\phi_2
                   + \cos\phi_1 \cos\phi_2
                     \cos\left(\left|\theta_2 - \theta_1\right|\right)\right)
$$
This formula is not numerically brilliant for small distances I think, although it's OK so long as your floats are long enough.
It's easy to see that $R$ cancels if you want only the ratio of distances.
You could have looked this up rather easily: Wikipedia for instance has this formula under 'great-circle distance'.

A: It is like the Thales relation for triangle sides. If $P$ be the north pole then
$$\dfrac{PC}{PA}=\dfrac{CD}{AB}$$
since the points locate on pure shpere then arc form is
$$\dfrac{60^\circ}{90^\circ}=\dfrac{CD}{AB}=\dfrac23$$


text:
Q: EF Core DB-first: How to delete dependent item without cascade delete? (Example code is posted at the end.)
I'm using EF Core 5 database-first (i.e. reverse engineered POCOs). When 'deleting' an item in a collection using .Remove(), a subsequent SaveChanges() complains about the orphaned child. Yup, plenty of Q&A can be found about that.
For code-first scenarios, one can add this to the configuration (from here):
modelBuilder.Entity<Child>.HasKey(t => new { t.ParentId, t.ChildId });

but it is not practical for DB-first. If the database has cascade delete set up for the FK relationship (docs reference here), the generated model [correction] does not include
entity.OnDelete(DeleteBehavior.ClientSetNull)

and the delete (using .Remove()) does work, including SaveChanges(). But ...
The problem I face here is that this "solution" requires all our FK relationships to be configured with cascade delete in the database. Yikes!  Data integrity is important to us and safeguarding it with UNIQUE constraints and non-nullable FK relationships has saved us before. Not having cascade deletes set up is a similar safeguard, and using it only for the severed relationship case is arguably overkill.
So, on to the third option: Explicitly delete the orphaned child item, noting that I'm in the second bullet described here. All I need is the good old ObjectContext.DeleteObject() but there is no EF Core equivalent.
Q: How can I delete that child item? And if it is not possible, do I have any other options?
Here is a quick example the brings it to life in code:
//Create a parent with two children
var db = new Context();
var newParent = new Parent() {Name = "NewParent"+DateTime.Now.Second};
db.Parents.Add(newParent);
newParent.Children = new List<Child>() {new Child() {Name="ChildOne"}, new Child() {Name="ChildTwo"}};
db.SaveChanges();
db.Dispose();

//Pick a parent item and delete one child item
var db2 = new Context();
var Parent = db2.Parents.First();
db2.Entry(Parent).Collection(f => f.Children).Load();
var ChildToDelete = Parent.Children.First();
Parent.Children.Remove(ChildToDelete);
db2.SaveChanges(); // -----> FAILS with "The association between entity types 'Parent'
                   // and 'Child' has been severed, but the relationship is either marked
                   //  as required or is implicitly required because the foreign key
                   // is not nullable."

and the tables are essentially
CREATE TABLE [dbo].[Child](
    [ChildId] [int] IDENTITY(1,1) NOT NULL,
    [ParentId] [int] NOT NULL,
    [Name] [nchar](20) NOT NULL,
 CONSTRAINT [PK_Child] PRIMARY KEY CLUSTERED)

CREATE TABLE [dbo].[Parent](
    [ParentId] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nchar](20) NOT NULL,
 CONSTRAINT [PK_Parent] PRIMARY KEY CLUSTERED)

ALTER TABLE [dbo].[Child]  WITH CHECK ADD  CONSTRAINT [FK_Child_Parent] FOREIGN KEY([ParentId])
REFERENCES [dbo].[Parent] ([ParentId])
ALTER TABLE [dbo].[Child] CHECK CONSTRAINT [FK_Child_Parent]

A: Instead of removing the Child from the Parent's collection
Parent.Children.Remove(ChildToDelete);

delete the child with
db.Set<Child>().Remove(ChildToDelte);


text:
Q: Excel macro to replace missing data with average I have a range of data, from a vba prompt held in a type range variable. I am trying to then go through this range, and for each empty cell, replace it with the average of it's column.
I can replace the empty cells fine, but it's getting the average of each column I am strugging with. Is there an easy way?
I prefer not to do a loop for each column, a loop for each row and then calculate it using total/numberOfNonEmptyCells as this takes a fair bit of time ( And i'm evidently doing something wrong here as i'm getting the wrong value )... but i'm sure it's not the only or correct way to do it.
Is there any kind of way of saying:

For Each Column
  Get column i from the range
  Get the average of that column.
  Put it in an array.

Then have a loop going through replacing the empty cells with that value?
OR, even better a way of just putting in a formula into the empty cells saying
= AVERAGE(Column from Range)
I tried this using AVERAGE(Range.Columns,1) and it didn't work, as it is of type Column I believe which average won't work with.
The easiest way to do this I will mark as the answer. It needs to use a macro though rather than just being manually putting the formula in, as it's for a lot of data on a lot of sheets.
Thanks.

A: This will a selected range, per column, filling in blank cells with the average on non-blank cells.
It addresses your speed concern, by minimising access to cells in the loops (tested on about 5,000,000 cells, took about 10s) (could possibly be improved further at the expence of more complex code)
Preserves any formulas
Sub FillInAverage()
    Dim rng As Range
    Dim col As Range
    Dim a As Variant
    Dim dat As Variant
    Dim i As Long

    Set rng = Selection
    For Each col In rng.Columns
        a = Application.WorksheetFunction.Average(col)
        dat = col.Formula
        For i = 1 To UBound(dat, 1)
            If Len(dat(i, 1)) = 0 Then
                dat(i, 1) = a
            End If
        Next
        col.Formula = dat
    Next
End Sub

A: Say, the range passed is abc
notBlanks = abc.Rows.Count - WorksheetFunction.CountBlank(abc.Columns(i))
avg = WorksheetFunction.Sum(abc.Columns(i)) / notBlanks

A: You can use a formula to act on just the empty cells as you had requested
(Note - this method presumes the cells are truly empty, i.e. not containing formulae that evaluate to "" etc).
This code averages any non-blank numerical cells in A1:A10000, and then populates the blanks in A1:A10000. Then B1:B10000 and so on
Sub FillBlanks()
Dim rng1 As Range
Dim rng2 As Range
Set rng1 = Range("A1:D10000")
On Error Resume Next
For Each rng2 In rng1.Columns
    rng2.SpecialCells(xlCellTypeBlanks).Value = Application.WorksheetFunction.Average(rng2.Columns(1))
Next
End Sub


text:
Q: how to arrange an array like menu order I have an array which i would like to re-arrange sequentially parent to child. Here in my array got unique value 'table_id' & value 'parent_table'. So parent_table will check if there have any 'table_id' exist or not. if exist it will goes under that 'table_id'. Here is the code:
    Array
(
[0] => Array
(
[table_id] => 7
[table_name] => Macro
[parent_table] => 1
)
[1] => Array
(
[table_id] => 4
[table_name] => Dise
[parent_table] => 7
)
[2] => Array
(
[table_id] => 5
[table_name] => Cox
[parent_table] => 7
)
[3] => Array
(
[table_id] => 6
[table_name] => Ripo
[parent_table] => 4
)
)

Sample Output:
 Array
       (
         [1] => Array
                    (
                    [table_id] => 7
                    [table_name] => Macro
                    [parent_table] => 1
                    [7] => Array
                               (
                               [table_id] => 4
                               [table_name] => Dise
                               [parent_table] => 7
                               [4] => Array
                                          (
                                           [table_id] => 6
                                           [table_name] => Ripo
                                           [parent_table] => 4
                                           )
                                )
                     [7] => Array
                                 (
                                 [table_id] => 5
                                 [table_name] => Cox
                                 [parent_table] => 7
                                 )
               )
)

Please provide some idea to as i am very new to php.

A: You can use a couple foreach loops and references:
// Build a new array, with nodes indexed by table_id
$byID = array();
foreach ($arr as $node) {
    $byID[$node['table_id']] = $node;
}

// Append child nodes to their parents' child_tables arrays
foreach ($byID as &$node) {
    if (isset($node['parent_table'])) {
        $byID[$node['parent_table']]['child_tables'][] =& $node;
    }
}

Then the entire tree is represented by $byID[1]:
Array
(
    [child_tables] => Array
        (
            [0] => Array
                (
                    [table_id] => 7
                    [table_name] => Macro
                    [parent_table] => 1
                    [child_tables] => Array
                        (
                            [0] => Array
                                (
                                    [table_id] => 4
                                    [table_name] => Dise
                                    [parent_table] => 7
                                    [child_tables] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [table_id] => 6
                                                    [table_name] => Ripo
                                                    [parent_table] => 4
                                                )

                                        )

                                )

                            [1] => Array
                                (
                                    [table_id] => 5
                                    [table_name] => Cox
                                    [parent_table] => 7
                                )

                        )

                )

        )

)


text:
Q: ExtJS4: Add field to form panel but not want it to be rendered by panel I have a static html form layout where i add extjs form fields using the "renderTo" config. In order to have form validation and simple submit methods i want to add the fields to a form panel. As the layout is managed by the html frame i don't want the form to be rendered by the panel (panel has html frame as contentEl and this should be used as is).
In extjs3 i could achieve this by adding the field not to the panel but to the BasicForm (formpanel.getForm().add(...)) but in extjs4 this method seems to be gone.
How can i do this using extjs4?
Thanks in advance.

A: Since you already have a Panel that uses the contentEl to render HTML into its body, I recommend to stick with this approach:
Replace the panel with an Ext.form.Panel instance - the configuration, particularly the contentEl config - can remain unchanged.
The code provided here will override a standard Ext class (Ext.layout.Layout) and introduce support for a 'renderItemTo' config property on child items of any Ext container or panel instance (including Ext.form.Panel).
The value of the config property should be the ID of an already rendered DOM node, e.g. a DIV element that is part of the HTML fragment used in as the contentEl of the parent container's body.
Ext.require(['Ext.layout.Layout'], function() {
    Ext.override(Ext.layout.Layout, {
        renderItem: function (item, target, position) {
            if(item.renderItemTo) {
                // render 'renderItemTo' components into the specified DOM element
                item.render(item.renderItemTo, 1);
                // don't allow container layout to seize the component
                item.layoutManagedHeight = 2;
                item.layoutManagedWidth = 2;
            } else {
                // just use standard Ext code for non-renderItemTo components
                this.callOverridden(arguments);
            }
        },
        isValidParent: function(item, target, position) {
            // signal Ext that we are OK with were our 'renderItemTo' component is right now
            // otherwise it would get moved during the layout process
            return item.renderItemTo ? true : this.callOverridden(arguments);
        }
    });
});

Usage:
var panel = Ext.create('Ext.form.Panel', {
    contentEl: 'form', // the DOM element ID that holds the HTML fragment for the body
    title: 'My FormPanel with special FX',
    items: [
        {
            xtype: 'textfield',
            renderItemTo: 'text1', // the ID of a DOM element inside the HTML fragment
            fieldLabel: 'Label 1',
        },
        {
            xtype: 'textfield',
            renderItemTo: 'text2', // the ID of a DOM element inside the HTML fragment
            fieldLabel: 'Label 2'
        }
    ]
});

I uploaded a working example to JSFiddle (note: resize the window if you experience a render problem - this is related to JSFiddle, not my override).

A: After digging through the layout system of ExtJS 4.1 i implemented a custom layout which moves the items after rendering to the desired position in the fixed markup. The result is the same as for the ExtJS 4.0.7 version from this thread. It seams to work for the ExtJS standard fields. I have some problems with my custom fields though.
Ext.define('Ext.ux.layout.Fixed', {
  extend: 'Ext.layout.container.Auto',
  alias: 'layout.uxfixed',
  afterRenderItem: function(item) {
    // move items with renderToFixedMarkup to desired position
    if (item.renderToFixedMarkup) {
      var target = Ext.getDom(item.renderToFixedMarkup);
      this.moveItem(item, target);
    }
  },
  isValidParent: function(item, target, position) {
    // items with renderToFixedMarkup property are always positioned correctly
    return (item.renderToFixedMarkup) ? true : this.callOverridden(arguments);
  }
});

It can be used by setting "layout: 'uxfixed'" on the panel and the "renderToFixedMarkup" config on the items.


text:
Q: Why does 8-bit MUL combine into AX but 16 and 32-bit MUL leave their result split between [E]DX:[E]AX?
*

*MUL CL CL is BYTE size and it equals to  AX = AL * CL

*MUL BX BX is WORD size and it equals to DX:AX = AX * BX

*MUL EBX EBX is DWORD size and it equals to EDX:EAX = EAX * EBX
I want to know why the 8-bit size MUL instruction gives the result in AX and not in DL:AL?
Is it because for 16-bit MUL, result can be EAX, for 32-bit MUL result can be RAX, but for 64-bit mul rcx there wouldn't be be any single register wide enough to hold the result?

A: The 8086 had 16-bit registers (AX, BX, ...).  So an 8*8=16 widening multiply (that is, with 8-bit inputs and a 16-bit result) could fit its result in a single register.  Splitting it across two registers would have been inconvenient and provided no benefit.
But the 16*16=32 widening multiply could not fit its result in a single register, because there were no 32-bit registers.  By necessity it had to be split across two registers, and DX and AX were chosen.
Likewise, the 386 had 32-bit registers (EAX, EBX, ...), so its 32*32=64 widening multiply had to have its result split.  EDX:EAX were chosen for similarity with 8086.
Intel could at this point have added a new version of the 16*16=32 MUL which left its result in a single 32-bit register such as EAX, but they chose not to, perhaps for compatibility or to avoid unnecessary extra complexity, or from simple inertia.  So the 386's 16*16=32 MUL still leaves its result split across DX:AX, even in 32-bit mode.
(They did, however, add a non-widening 32*32=32 form of the signed multiply IMUL instruction, which leaves its result in a single 32-bit register.  One can use this for signed 16*16=32 multiplication by sign-extending the inputs, for which the convenient MOVSX was also added.  And it can be used for 16*16=32 unsigned multiply, by zero-extending the inputs, if one knows that the product will be less than 2^31.)
Likewise again, x86-64 had 64-bit registers.  For the existing multiplication instructions, they kept the behavior the same (so 32*32=64 still splits its result across EDX:EAX instead of using a single 64-bit register), and they added a 64*64=128 widening multiply which, again, must split its result, and leaves it in RDX:RAX.  And there is also a non-widening 64*64=64 signed IMUL which leaves its result in a single 64-bit register.


text:
Q: Check input value with javascript and show image I'm sorry, i'm very new to develop code. Now I'm doing some homework and want to do something outside of the textbook, but I'm failing ... :)
I created some simple html. Example:

    5 + 3 =
      <input id="a_som1" type="number" required>

And it ends with a button:

What I want is when you click on this button, the script checks your answer and either shows the "goed" or the "fout" image.
I hided the images with a css-stylesheet and this code:
img {
  width: 35px;
  display: none;
}

I tried the following as javascript, however, it doesn't work. (I know this code is probably very stupid, I just tried some things when searching the internet.) I hope someone can help me :):
Oh, and is it necessary to use $(document).ready(function() { . It was in my textbook, but I don't really know if it's necessary...
$(document).ready(function() {
$("#cont").click {
  if ($("#a_som1").val() 8 ) {
      show("#i-s1g")
  }
  else {
      show("#i-s1f")
  }
  }

}
Thanks for helping!!

A: getting all the things i need 1:input 2:gIMAGE 3:fIMAGE & saving them in three variables..
putting eventListener on input of keypress then checking if the is enter,if is enter check if the number is equal to my answer("8").if yes show gimage and hide fimage,
if not hide gimage and show fimage

let input = document.getElementById("a_som1");
let gImg = document.getElementById("i-s1g");
let fImg = document.getElementById("i-s1f");

input.addEventListener("keypress", function(event) {
  if (event.key === "Enter") {

    if (input.value == 8) {
      gImg.style.display = "block"
      fImg.style.display = "none"
    } else {
      fImg.style.display = "block"
      gImg.style.display = "none"
    }
  }
});
img {
  width: 35px;
  display: none;
}

  5 + 3 =
    <input id="a_som1" type="number" required>


text:
Q: Pseudocode Not Understand Line Im just confused on Line 11 how to code it into python:

The Line is( FOR N <-- 1 TO Factor

A: With a while loop:
n = 1
while n <= (Factor+1):
    # block of code
    n = n + 1

or as @Thierry Lathuille said, with for-loop:
for n in range(1, Factor + 1):
    # block of code


text:
Q: How To Save a PPTX File with VBA So I'm making a powerpoint game, and I want there to be a save feature. I remember seeing a save function while browsing through the commands but I don't remember what to do. Does anyone know how to save a powerpoint file with a simple line of code? it can't be that complicated.

A: You want the Save method of the presentation object:
Application.ActivePresentation.Save

You can find methods using the search box in the Object Browser:


text:
Q: How to create custom alphabetical order in JavaScript? I have a custom alphabetical order for a custom script I've written. It is defined in the following code, as well as my attempt at specifying an alphabetize algorithm, which isn't working.

const symbols = [
  { ascii: "i", unicode: "\u0470" },
  { ascii: "a", unicode: "\u0500" },
  { ascii: "u", unicode: "\u03f0" },

  { ascii: "e", unicode: "\u0410" },
  { ascii: "E", unicode: "\u0450" },
  { ascii: "U", unicode: "\u04a0" },

  { ascii: "I", unicode: "\u03d0" },
  { ascii: "o", unicode: "\u04e0" },
  { ascii: "A", unicode: "\u03b0" },

  { ascii: "O", unicode: "\u04c0" },
  { ascii: "o#", unicode: "\u0390" },
  { ascii: "u#", unicode: "\u0430" },

  { ascii: "e#", unicode: "\u0451" },
  { ascii: "i#", unicode: "\u03d1" },
  { ascii: "a#", unicode: "\u0501" },

  { ascii: "m", unicode: "\u0100" },
  { ascii: "n", unicode: "\u0140" },
  { ascii: "q", unicode: "\u0160" },
  { ascii: "g", unicode: "\u0130" },
  { ascii: "d", unicode: "\u0060" },
  { ascii: "b", unicode: "\u0040" },
  { ascii: "p", unicode: "\u0030" },
  { ascii: "t", unicode: "\u00d0" },
  { ascii: "k", unicode: "\u0050" },

  { ascii: "h", unicode: "\u0120" },
  { ascii: "l", unicode: "\u0170" },
  { ascii: "w", unicode: "\u0110" },

  { ascii: "f", unicode: "\u00c0" },
  { ascii: "s", unicode: "\u0070" },
  { ascii: "C", unicode: "\u00b0" },

  { ascii: "z", unicode: "\u0090" },
  { ascii: "v", unicode: "\u00f0" },
  { ascii: "y", unicode: "\u0180" },

  { ascii: "x", unicode: "\u0190" },
  { ascii: "r", unicode: "\u00e0" },

  { ascii: "c", unicode: "\u0080" },
  { ascii: "j", unicode: "\u0150" },
  { ascii: "Q", unicode: "\u01a0" },

  { ascii: "S", unicode: "\u0072" },
  { ascii: "Z", unicode: "\u0092" },
  { ascii: "H", unicode: "\u0122" },

  { ascii: "'", unicode: "\u01b0" },
]

const alphabet = symbols.map(o => o.ascii)

const words = [
  'He',
  'Hix',
  'Hex',
  'SoHiz',
  'SoH',
  'xo',
  'SoHi',
  'Hi',
  'CU'
]

const alphabetize = (array, alphabet) => {
  return array.sort((a, b) => {
    for (let i = 0, n = a.length; i < n; i++) {
      let x = a[i]
      let y = b[i]
      if (y) {
        let diff = alphabet.indexOf(x) - alphabet.indexOf(y)
        if (diff) return diff
      } else {
        return -1
      }
    }
  })
}

console.log(alphabetize(words, alphabet).join('\n'))

The output should be:
CU
xo
SoH
SoHi
SoHiz
Hi
Hix
He
Hex

What am I doing wrong here, and how can this become optimal?

A: Two things:

*

*if b[i] is undefined, then the return value should not be -1, but 1: this will put the shorter b before the longer a.

*There is a possibility that the for loop will complete without a return exit. In that case it could be that a and b are equal or b is longer. You need to return a good value for that case.
Here is a correction:

const symbols = [{ ascii: "i", unicode: "\u0470" },{ ascii: "a", unicode: "\u0500" },{ ascii: "u", unicode: "\u03f0" },{ ascii: "e", unicode: "\u0410" },{ ascii: "E", unicode: "\u0450" },{ ascii: "U", unicode: "\u04a0" },{ ascii: "I", unicode: "\u03d0" },{ ascii: "o", unicode: "\u04e0" },{ ascii: "A", unicode: "\u03b0" },{ ascii: "O", unicode: "\u04c0" },{ ascii: "o#", unicode: "\u0390" },{ ascii: "u#", unicode: "\u0430" },{ ascii: "e#", unicode: "\u0451" },{ ascii: "i#", unicode: "\u03d1" },{ ascii: "a#", unicode: "\u0501" },{ ascii: "m", unicode: "\u0100" },{ ascii: "n", unicode: "\u0140" },{ ascii: "q", unicode: "\u0160" },{ ascii: "g", unicode: "\u0130" },{ ascii: "d", unicode: "\u0060" },{ ascii: "b", unicode: "\u0040" },{ ascii: "p", unicode: "\u0030" },{ ascii: "t", unicode: "\u00d0" },{ ascii: "k", unicode: "\u0050" },{ ascii: "h", unicode: "\u0120" },{ ascii: "l", unicode: "\u0170" },{ ascii: "w", unicode: "\u0110" },{ ascii: "f", unicode: "\u00c0" },{ ascii: "s", unicode: "\u0070" },{ ascii: "C", unicode: "\u00b0" },{ ascii: "z", unicode: "\u0090" },{ ascii: "v", unicode: "\u00f0" },{ ascii: "y", unicode: "\u0180" },{ ascii: "x", unicode: "\u0190" },{ ascii: "r", unicode: "\u00e0" },{ ascii: "c", unicode: "\u0080" },{ ascii: "j", unicode: "\u0150" },{ ascii: "Q", unicode: "\u01a0" },{ ascii: "S", unicode: "\u0072" },{ ascii: "Z", unicode: "\u0092" },{ ascii: "H", unicode: "\u0122" },{ ascii: "'", unicode: "\u01b0" },];

const alphabet = symbols.map(o => o.ascii);

const words = ['He','Hix','Hex','SoHiz','SoH','xo','SoHi','Hi','CU']

const alphabetize = (array, alphabet) => {
  return array.sort((a, b) => {
    for (let i = 0, n = a.length; i < n; i++) {
      let x = a[i];
      let y = b[i];
      if (y) {
        let diff = alphabet.indexOf(x) - alphabet.indexOf(y);
        if (diff) return diff;
      } else {
        return 1; // <-- corrected
      }
    }
    return a.length - b.length; // is 0 or negative
  })
}

console.log(alphabetize(words, alphabet).join('\n'));

A: You need to account for when either word is longer than the other

const symbols = [
  { ascii: "i", unicode: "\u0470" },
  { ascii: "a", unicode: "\u0500" },
  { ascii: "u", unicode: "\u03f0" },

  { ascii: "e", unicode: "\u0410" },
  { ascii: "E", unicode: "\u0450" },
  { ascii: "U", unicode: "\u04a0" },

  { ascii: "I", unicode: "\u03d0" },
  { ascii: "o", unicode: "\u04e0" },
  { ascii: "A", unicode: "\u03b0" },

  { ascii: "O", unicode: "\u04c0" },
  { ascii: "o#", unicode: "\u0390" },
  { ascii: "u#", unicode: "\u0430" },

  { ascii: "e#", unicode: "\u0451" },
  { ascii: "i#", unicode: "\u03d1" },
  { ascii: "a#", unicode: "\u0501" },

  { ascii: "m", unicode: "\u0100" },
  { ascii: "n", unicode: "\u0140" },
  { ascii: "q", unicode: "\u0160" },
  { ascii: "g", unicode: "\u0130" },
  { ascii: "d", unicode: "\u0060" },
  { ascii: "b", unicode: "\u0040" },
  { ascii: "p", unicode: "\u0030" },
  { ascii: "t", unicode: "\u00d0" },
  { ascii: "k", unicode: "\u0050" },

  { ascii: "h", unicode: "\u0120" },
  { ascii: "l", unicode: "\u0170" },
  { ascii: "w", unicode: "\u0110" },

  { ascii: "f", unicode: "\u00c0" },
  { ascii: "s", unicode: "\u0070" },
  { ascii: "C", unicode: "\u00b0" },

  { ascii: "z", unicode: "\u0090" },
  { ascii: "v", unicode: "\u00f0" },
  { ascii: "y", unicode: "\u0180" },

  { ascii: "x", unicode: "\u0190" },
  { ascii: "r", unicode: "\u00e0" },

  { ascii: "c", unicode: "\u0080" },
  { ascii: "j", unicode: "\u0150" },
  { ascii: "Q", unicode: "\u01a0" },

  { ascii: "S", unicode: "\u0072" },
  { ascii: "Z", unicode: "\u0092" },
  { ascii: "H", unicode: "\u0122" },

  { ascii: "'", unicode: "\u01b0" },
]

const alphabet = symbols.map(o => o.ascii)

const words = [
  'He',
  'Hix',
  'Hex',
  'SoHiz',
  'SoH',
  'xo',
  'SoHi',
  'Hi',
  'CU'
]

const alphabetize = (array, alphabet) => {
  return array.sort((a, b) => {
    for (let i = 0, n = a.length; i < n; i++) {
      let x = a[i]
      let y = b[i]
      if (y && x) {
        let diff = alphabet.indexOf(x) - alphabet.indexOf(y)
        if (diff) return diff
      } else if (y) {
        return -1
      } else {
        return 1
      }
    }
  })
}

console.log(alphabetize(words, alphabet).join('\n'))


text:
Q: Question with R. Element wise multiplication, addition, and division with 2 data.frames with varying amounts of missing data in a given row I have a various data.frames with columns of the same length where I am trying to multiple 2 rows together element-wise and then sum this up. For example, below are two vectors I would like to perform this operation with.
> a.1[186,]
q01_a q01_b q01_c q01_d q01_e q01_f q01_g q01_h q01_i q01_j q01_k q01_l q01_m
    3     3     3     3     2     2     2     3     1    NA    NA     2     2

and
> u.1[186,]
q04_avl_a q04_avl_b q04_avl_c q04_avl_d q04_avl_e q04_avl_f q04_avl_g q04_avl_h q04_avl_i q04_avl_j q04_avl_k q04_avl_l q04_avl_m
        4         2         3         4         3         4         4         4         3         4         3         3         3`

The issue is that various rows have varying numbers of NA's. What I would like to do is skip the multiplication with any missing values ( the 10th and 11th position from my above example), and then after the addition divide by the number of elements that were multiplied (11 from the above example). Most rows are complete and would just be multiplied by 13.
Thank you!

A: x <- c(3,3,3,3,2,2,2,3,1,NA,NA,2,2)
y <- c(4,2,3,4,3,4,4,4,3,4,3,3,3)

sum(x*y,na.rm = T)/sum(!is.na(x*y))
[1] 8

EDIT
In case of factors, first convert them to numeric
x <- as.factor(c(3,3,3,3,2,2,2,3,1,NA,NA,2,2))
y <- as.factor(c(4,2,3,4,3,4,4,4,3,4,3,3,3))
xy <- as.numeric(as.character(x)) * as.numeric(as.character(y))
sum(xy,na.rm = T)/sum(!is.na(xy))
[1] 8

A: Making some progress here. I used substituteNA from the Fseries package to change all the missing values to zeros.
> sum(a.11[186,]*u.11[186,])/min((rowSums(a.11!=0)), rowSums(u.11!=0))

Now I just need to make this work in a loop!


text:
Q: Email button on Extjs Toolbar I'm having trouble adding a mailto: link to a grid panel's toolbar.
I've tried modifying the object's HTML configuration & also via the handler but neither are opening the new email message.
{
text   : 'Support',
html: 'Support'
}

{
text   : 'Support',
handler: function() {
   return 'Support';
}

A: handler: is used to create handler function of button pressed. To make your mailto link work you should redirect to mailto:email@xx.com address like:
handler: function() {
    window.location = 'mailto:email@xx.com';
}

A: I would do as @webbandit suggested, except I would use window.open('mailto:address.com')

A: If you are using ExtJS 4.x, you can define it in href:
{
    text : 'Support',
    href : "mailto:email@xx.com"
 }

hrefTarget="_blank" is default value, but it is better if you set it to _self:
{
    text : 'Support',
    href : "mailto:email@xx.com",
    hrefTarget: "_self"
 }


text:
Q: R studio no longer allowing me to download / install packages Cant install packages
> install.packages("tidyverse")
Warning in install.packages :
  unable to access index for repository http://cran.rstudio.com/src/contrib:
  cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'

this is what i have tried so far

*

*i have tried using a CRAN repository closer to me (im in sydney australia) - this didnt help

*i have tried downloading rtools42 - didnt help

*i have unchecked the box in packages "use secure download method for http"

*i have even tried using an external repository

options(repos=c(cran="http://cran.rstudio.com"))
and then tried to install.packages
but that still didnt help

I really am not sure what to do


text:
Q: How to Import the Font in xcode for Iphone Application I am import the font in my app folder.
Then i added font in info.plist file.
Like..... Fonts provided by application--->add two font.
Then set the font to title.After create the UILabel to set the font. Like this
 self.title = @"Home";
CGRect frame = CGRectMake(0, 0,100, 44);
label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"Benguiat Gothic" size:9];
label.textAlignment = UITextAlignmentCenter;
self.navigationItem.titleView = label;
label.text =self.title;

This code written in viewdidload method.
But the font is not changed.its appear only default font for that label.

A: 1 Add your custom font into your project , i.e. Dragged the font file(CALIBRIZ_0.TTF) into XCode project.
2 Edit Info.plist: Add a new entry with the key "Fonts provided by application".
3 For each of your files, add the file name to this array
4.Opened the font in font book(double click on your font in finder) to see what the real filename is and I see this:

Now set font to your label
yourLabel.font = [UIFont fontWithName:@"Calibri" size:15];

A: First download your relevant font
Add your custom font into your project , i.e. Dragged the font file(Berlin Sans FB.TTF) into XCode project.
Add a new entry with the key "Fonts provided by application".

Now use this font in your textview
txtview.font = [UIFont fontWithName:@"Berlin Sans FB" size:15];

i used Berlin Sans FB you use your teleugu font
for more detail check this link

A: Using a custom font in iOS requires a few steps:

*

*Have access to the TTF or OTF file for the desired font.

*Drag the TTF or OTF font file into your Xcode project.

*Located the application's Plist file and add a new row with the key "Fonts provided by the application.

*Make sure that the associated value in the Plist perfectly matches the naming of the dragged in font file.

*In your code, you can now assign the custom font to be used with your label, textfield or any other control that has the font property.
[myLabel setFont:[UIFont fontWithName:@"Benguiat Gothic" size:12.0f]];
Or, if you prefer dot notation syntax
myLabel.font = [UIFont fontWithName:@"Benguiat Gothic" size: 12.0f];

There's a few things to take into consideration. The actual naming of the Font File may not always be what you have to pass in as a string literal. Some custom fonts may have different weights associated with it (Light, Regular, Medium, Bold, Italic Bold etc). If the font isn't displaying as you would expect and all steps above have been explicitly followed then it could be down to the string you're using in your code.
You can get the list of font family names in debug by logging out as so:
NSLog (@"Font families: %@", [UIFont familyNames]);

That should give you a decent indication of what to actually use in your code when defining the custom font for use with the label.