text:
Q: Bash : sed -n arguments While reading results of a ls instance, I'm trying to display a specific term from a specific line using sed :
Here is what I managed to do until now :
echo $(ls -lAtro | sed -n '3p' | cut -d' ' -f 6 )

This is reading the 6th term of the 3rd line. What I'm trying to do is replace the '3p' by a more simple variable which would permit to do something like this :
linetoread=3
echo $(ls -lAtro | sed -n "$linetoread" | cut -d' ' -f 6 )

The above example doesn't work of course, but you get the idea. What can I do to achieve this ? Thanks in advance.

A: Try awk instead-
line=3 ;
ls -lAtro | awk -v var="$line" 'NR==var {print $6}'

This takes the variable line=3 and feeds it into awk (the awk -v part).
The NR==var ensures that you get the line corresponding to your variable.
Then you can change the print $6 part to match whichever column you want. Note that the default delimiter is a space.
Of course, as pointed out in the comments, you shouldn't be parsing the output of ls.


text:
Q: How to design body for sending large content in SMS? I am trying to send an SMS to mobile.How to send large data in body ?orderid should be in online, product name in online,
price in online,status in online.How to arrange the body?
var data2 = db.collection("UserProfile").doc(mauths)
  .get().then(doc =>
   {
      mobile= doc.data().MobileNumber;
      console.log("mobile",mobile);
       // Your Account Sid and Auth Token from twilio.com/console
       const accountSid = '======';
       const authToken = '=======';
       const client = require('twilio')(accountSid, authToken);
       client.messages
       .create({
         body: "Your " + pn + " has been cancelled " ,// need to more content line by line
         from: '+-=======',
         to: mobile
         })
         .then(message => {
         });
 })

A: I think this is useful to you.
  public static final String SMS_BUNDLE = "pdus";

public void onReceive(Context context, Intent intent) {
    Bundle intentExtras = intent.getExtras();

        if (intentExtras != null) {
        Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
        String smsMessageStr = "";
        for (int i = 0; i < sms.length; ++i) {
        String format = intentExtras.getString("format");
        SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i], format);

            String smsBody = smsMessage.getMessageBody().toString();
            String address = smsMessage.getOriginatingAddress();

            smsMessageStr += "SMS From: " + address + "\n";
            smsMessageStr += smsBody + "\n";
        }

        MainActivity inst = MainActivity.instance();
        inst.updateInbox(smsMessageStr);
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Problems grouping in XSLT 1.0? I've gotten XSLT 2.0 grouping to work, but I'm having trouble with XSLT 1.0.
XML
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE cataleg SYSTEM "cataleg.dtd">
<?xml-stylesheet href="cataleg.css" ?>
<?xml-stylesheet type="text/xsl" href="cataleg.xsl" ?>

<cataleg>

    <peli ordre="X">
        <titol>X-Men</titol>
        <caratula>XMen.jpg</caratula>
    </peli>
    <peli ordre="B">
        <titol>X-Men 2</titol>
        <caratula>XMen2.jpg</caratula>
    </peli>
    <peli ordre="C">
        <titol>X-Men: La Decisió Final</titol>
        <caratula>XMenFD.jpg</caratula>
    </peli>
    <peli ordre="A">
        <titol>X-Men Origins: Wolverine</titol>
        <caratula>XMenOW.jpg</caratula>
    </peli>

</cataleg>

XSLT 2.0 (working)
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
   <xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />

<xsl:template match="/">

          <title>PRACTICA 1 XML</title>
          <link href="https://procomprador.com/PRACTICA/cataleg.css" rel="stylesheet" />

        <xsl:apply-templates/>

      </xsl:template>

<xsl:template match="cataleg">

        <xsl:for-each-group select="peli" group-by="@ordre">
        <xsl:sort select="titol"/>
            <Inicial value="{@ordre}">

<xsl:value-of select="@ordre"></xsl:value-of>

                <xsl:for-each select="current-group()">

                </xsl:for-each>
            </Inicial>
        </xsl:for-each-group>

</xsl:template>

</xsl:transform>

XSLT 1.0 attempt (not working)
<xsl:key name="contacts-by-surname" match="cataleg/peli" use="titol" />

<xsl:key name="pelis-by-surname" match="peli" use="@peli" />
<xsl:template match="cataleg">
    <xsl:for-each select="peli[count(. | key('pelis-by-surname', surname)[1]) = 1]">
        <xsl:sort select="surname" />
        <xsl:value-of select="surname" />,

        <xsl:for-each select="key('pelis-by-peli', peli)">
            <xsl:sort select="caratula" />
            <xsl:value-of select="caratula" /> (<xsl:value-of select="titol" />)

        </xsl:for-each>
    </xsl:for-each>
</xsl:template>

A: Your XSLT 2.0 stylesheet groups the peli elements by their ordre attribute. If you take an XML example where some peli have the same ordre:
XML
<cataleg>
    <peli ordre="X">
        <titol>X-Men</titol>
        <caratula>XMen.jpg</caratula>
    </peli>
    <peli ordre="A">
        <titol>X-Men 2</titol>
        <caratula>XMen2.jpg</caratula>
    </peli>
    <peli ordre="X">
        <titol>X-Men: La Decisió Final</titol>
        <caratula>XMenFD.jpg</caratula>
    </peli>
    <peli ordre="A">
        <titol>X-Men Origins: Wolverine</titol>
        <caratula>XMenOW.jpg</caratula>
    </peli>
</cataleg>

and apply the following stylesheet:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="pelis-by-ordre" match="peli" use="@ordre" />

<xsl:template match="/cataleg">

        <xsl:for-each select="peli[count(. | key('pelis-by-ordre', @ordre)[1]) = 1]">

                <xsl:value-of select="@ordre" />

            <xsl:for-each select="key('pelis-by-ordre', @ordre)">

                    <xsl:value-of select="titol" />

            </xsl:for-each>
        </xsl:for-each>

</xsl:template>

</xsl:stylesheet>

you will get:
Result

X

X-Men

X-Men: La Decisió Final

A

X-Men 2

X-Men Origins: Wolverine

rendered:


text:
Q: jquery navigation not working in webkit browsers I've noticed the navigation on my site doesn't work in Safari or Chrome(it works fine in Firefox).
In both browsers, it appears but clicking is disabled. What could be the cause and how can I repair?
ETA for clarity:
*In Chrome, the menu will load and you CAN click, but the page doesn't scroll to the section as it should nor does the menu follow along if you manually scroll. Also, the discs do not appear to the left side. In Safari, the menu appears as do the discs however clicking is disabled completely as is the follow along scroll.
Also, I'm certain this is not exclusive to my machine as it was another person that brought these problems to my attention(ie- this problem has been shown on two different machines by two different users*
live site
html

home

manifesta

services

lookbook

contact

goodies

blog

css
nav {
    position: fixed;
    right: 9%;
    top: 55%
}

nav ul {

        list-style-type:disc;
    }

    nav ul li {
        text-align: right;
        color: #fff;
    }

    nav ul li.current {
        color:#000;
    }

A: Couldn't find the exact reason this is happening, but webkit browsers (ie Chrome and Safari) are notorious for their animation artifacts on rich pages. I see files included for slideshow, smooth scrolling, pinterest and google APIs, and a few for theme support - I think the browser is too busy managing these to make its css behaviors seamless.
Since you're already using jquery, instead of making the nav position: fixed; I'd suggest positioning it absolutely and using jquery to animate its position - keep right: 9%; and make top: an explicit pixel distance based on the scroll position. There's a million plugins for this already, so I'm sure you can find one that works for you without much effort. Start here: http://www.jquery4u.com/menus/floating-message-plugins/.

A: Here is the cross-browser working DEMO http://jsfiddle.net/yeyene/KBF7N/
You don't need to use any other plug-in for scrolling navigation. Just these small scripts can give you the effect you want.
Add target attribute to  tag with the same DIV id name that you want to animate instead of href.
HTML

home

manifesta

services

lookbook

contact

home

manifesta

services

lookbook

contact

JQUERY
$(document).ready(function(){
    $('#Nav li a').on('click',function(){
        $("#Nav li").removeClass('current');
        $(this).parent('li').addClass('current');
        $('html, body').animate({ scrollTop: $('#'+$(this).attr('target')).offset().top }, 'slow');
    });
});

CSS
body {
    background:#ccc;
    margin: 0;
    height: 2000px;
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
}
nav {
    position: fixed;
    right: 9%;
    top: 55%
}
nav ul {
        list-style-type:disc;
    }
    nav ul li {
        text-align: right;
        color: #fff;
        cursor:pointer;
    }
    nav ul li a{
        color: #000;
    }
    nav ul li.current {
        color:#000;
    }
#home, #about, #services, #lookbook, #contact{
    float:left;
    width:94%;
    height:600px;
    margin:20px 3%;
    background:#ccc;
    text-align:center;
    font-size:100px;
    border:3px solid #555;
}

A: I found the source of your problem. It's your content slider (RevSlider) within #home. If you remove the class "tp-simpleresponsive" from the div "rev_slider revslider-initialised tp-simpleresponsive", then everything starts working 100%. This tells me you have a JS conflict or error.
It might be worth checking to see if you even need that class in there.


text:
Q: How to decide on the number of microservices and whether to have common jars I have 3 micorservices one that serves request from UI and the other that serves request from public apis and the third which does some data processing and storing the data provided from the kafka topic by UI/public.
I have written common service and dao jar for the services, as the data is coming from the common data source.
If I dont have common service/dao then lot of code will be duplicated.
I am now feeling that this is causing coupling between the services.
Is it the right design?

A: Using a common DAO across microservices is right if it is making development faster and easier to understand for everyone, and wrong if it's not. You are right that this is creating some coupling between the services, but it's coupling that you could easily do away with if the DAOs for the services began to diverge. Since the final shared package will be inside each service's runtime, there would be zero issues introduced if one of the other services decided to stop using the DAO and use a different one.
That being said, you may have a larger coupling issue if all three services are using this DAO to connect to a shared database. If each is dependent on the same tables/schema, it makes it very hard for one service to diverge from the others and make independent schema changes without impacting the others.


text:
Q: How to iterate over two lists of different length without combining them Is there a way to iterate over two lists of different length at the same time without combining them?
I tried itertools.product(list1, list2) but that's very similar to a nested loop. So the second list gets iterated for each item of the first list, which is not what I want.
I want to compare both lists and see if they match.

A: If your purpose is to check for differences, you can use sets.
Let's say you have two lists, like
a=["one", "two", "three"]
b=["one", "other"]

You can check the difference by converting them to set:
print(set(a) - set(b))
The order matters: the first item is the one you are checking against the second:
print(set(a) - set(b))
returns {'three', 'two'} (the items present in the first set that are missing in the second), while
print(set(b) - set(a))
returns {'other'}


text:
Q: How can I pin an access database file to the user's taskbar? I am having trouble finding anything useful online regarding this question. Can someone point me in the right direction? Here is what I have so far:
Option Explicit

'Const CSIDL_COMMON_PROGRAMS = &H17
Dim ShellApp, FSO, Desktop
Set ShellApp = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")

'Set StartMenuFolder = ShellApp.NameSpace(CSIDL_COMMON_PROGRAMS)
Set Desktop =  ShellApp.NameSpace("C:\Users\myUser\Desktop")

Dim LnkFile
LnkFile = Desktop.Self.Path & "\myTest.lnk"

If(FSO.FileExists(LnkFile)) Then
    Dim tmp, verb
    'For Each verb in Desktop.ParseName("myTest.lnk").Verbs
        'tmp = tmp&verb&chr(13)
    'Next
    'MsgBox(tmp)

    Dim desktopImtes, item
    Set desktopImtes = Desktop.Items()

    For Each item in desktopImtes
        If (item.Name = "myTest") Then
            'MsgBox(item.Name)
            For Each verb in item.Verbs
                If (verb.Name = "Pin to Tas&kbar") Then
                    verb.DoIt
                End If
            Next
        End If
    Next

End If

Set FSO = Nothing
Set ShellApp = Nothing

When I go through each verb.name, "Pin to Tas&kbar" never shows up. Is this a known issue?
Edit: Here is my second attempt:
Dim objShell, objAllUsersProgramsFolder, strAllUsersProgramsPath, objFolder, objFolderItem, colVerbs, objVerb
Const CSIDL_COMMON_PROGRAMS = &H17
Set objShell = CreateObject("Shell.Application")
Set objAllUsersProgramsFolder = objShell.Namespace("C:\Users\myUser\Desktop")
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
Set objFolderItem = objFolder.ParseName("myTest.lnk")
Set objVerb = objFolderItem.Verbs '''!! this line is where it fails !!'''
For Each objVerb In colVerbs
    If Replace(objVerb.Name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next

The line marked shows where the error is located. The error states:
Object variable or With block variable not set.
It may help to note that the link is pointing to an access database.

A: I think the main problem is a common one - code is being copied/pasted from a Google Search result without an attempt to understand it - or even do basic troublsehooting to determine if it works - or how it's supposed to work.
What you've done is to copy directly from this codeproject url or some other site that copied/pasted this code. The commented out code is still intact exactly as is.
It looks like you did the same thing in the second attempt too, but I won't even look at that one as it's a half attempt with same basic errors
The biggest issue with both code samples is that:

*

*Variables are dimmed as variants - when the important ones are
objects.

The biggest issue with your attempt is:

*

*You've done no debugging or troubleshooting with debug statements.

I've cleaned up this sub with variable declarations and debug code to identify how where your code might be failing. Change the constants at the top to match your user and file name - make sure you rightclick on your shortcut and look at the properties to make sure your path is correct.
Try this and hopefully the msgbox and debug statements will point to your problem. I assume it will be a simple path or filename error.
Option Explicit

Public Sub PinApp()

    Const DESKTOP_USER      As String = "Public" ' username shown in file properties
    Const SHORTCUT_FILE     As String = "My Shortcut"

    Dim objShellApp         As Object ' Shell Application
    Dim objFSO              As Object ' FileSystemObject
    Dim objDesktop          As Object ' Folder
    Dim objDesktopItems     As Object

    Dim varVerb             As Variant
    Dim varItem             As Variant

    Dim strShortcut         As String

    Dim blFound             As Boolean
    Dim blPinned            As Boolean

    Set objShellApp = CreateObject("Shell.Application")
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objDesktop = objShellApp.NameSpace("C:\Users\" & DESKTOP_USER & "\Desktop")

    strShortcut = objDesktop.Self.Path & "\" & SHORTCUT_FILE & ".lnk"

    blFound = False
    blPinned = False

    ' Check first to see if Shortcut File exists
    If (objFSO.FileExists(strShortcut)) Then

        Set objDesktopItems = objDesktop.Items()

        For Each varItem In objDesktopItems

            If (varItem.Name = SHORTCUT_FILE) Then
Debug.Print "Found Shortcut"
                blFound = True
                For Each varVerb In varItem.Verbs
Debug.Print varVerb.Name
                    If (varVerb.Name = "Pin to Tas&kbar") Then
                        varVerb.DoIt
                        blPinned = True
                        ' no sense continuing - we found what we're looking for
                        MsgBox "Shortcut File Pinned"
                        Exit For
                    End If
                Next
                ' no sense continuing - we found what we're looking for
                Exit For
            End If
        Next

        If Not blFound Then
            MsgBox "Shortcut File Not Found in Desktop Items: " & strShortcut
        ElseIf Not blPinned Then
            MsgBox "Failed to find Pin To Taskbar"
        End If
    Else
        MsgBox "Missing Shortcut File: " & strShortcut
    End If

    Set objFSO = Nothing
    Set objShellApp = Nothing
End Sub


text:
Q: How to write Any with Contains as an expression? How can I write this
x => x.ListOfStrings.Any(x => x.Contains("foobar"))

as an expression? For
x => x.Contains("foobar")

I do this:
var contains = typeof(string).GetMethod("Contains", new[] { typeof(string) })!;

object? toCompare = value.GetString();

Expression.Call(property, contains, Expression.Constant(toCompare, property.Type));

I am not sure how to combine this with Any.

A: Reflection isn't a good solution - I'm not sure if you are trying to shorten it or simply introduce a syntax sugar.
Syntax Sugar:
You can use an extension method:
public static class XExtensions
{
  public static bool Contains(this MyType x, string mahString)
  {
    return x.ListOfStrings.Any(s => s.Contains(mahString));
  }
}

// Call:
X x;
x.Contains("Hello");

This simply uses static methods.
The keyword this in a parameter turns it into extension method which you can call directly.
But the MSIL will simply call a static method.


text:
Q: Using ax.set_rasterization_zorder() puts rasterized objects outside of the axis extent The following figure (exported as a pdf) contains overly detailed vector images that load slowly in a PDF viewer:

I'm trying to rasterize the outlines of the polygons displayed. However, when I use ax.set_rasterization_zorder(0), the following occurs:

I believe it is a backend issue but cannot figure out how to fix the problem.
import numpy as np
import matplotlib as mpl
from matplotlib.collections import PatchCollection
fig, ax = plt.subplots()
ax.imshow(dem, zorder=-2, rasterized=True)
parts = mpl.patches.Polygon(vertices)
polygon = PatchCollection(parts, zorder=-1)
ax.add_collection(polygon)
ax.set_rasterization_zorder(0)

A: I was not setting rasterized=True when creating the PatchCollection objects that were drawing the polygons. When using rasterized=True without ax.set_rasterization_zorder(), each polygon would be rasterized individually, creating a large file; however, it was at least in the right location.
By rasterizing the polygon initially at the PatchCollection level and combining it with ax.set_rasterization_zorder() prior to calling plt.savefig(), all of the polygon objects were combined with the underlying DEM into one raster, creating a file manageable by Adobe PDF viewers.
import numpy as np
import matplotlib as mpl
from matplotlib.collections import PatchCollection
fig, ax = plt.subplots()
ax.imshow(dem, zorder=-2, rasterized=True)
parts = mpl.patches.Polygon(vertices)
polygon = PatchCollection(parts, zorder=-1, rasterized=True)
ax.add_collection(polygon)
ax.set_rasterization_zorder(0)


text:
Q: useState inside useEffect not updating state the state 'status' does not change values and always keeps its initial value 'pending' and does not change value to 'on hold' knowing that I am sure that the request returns a result
const [_talentID, setTalentID] = useState(props.match.params.idTalent);
const [_jobID, setJobID] = useState(props.match.params.idJob);
const [status, setStatus] = useState('pending');

  useEffect(() => {
    async function getStatus() {
      await axios
        .get('api')
        .then(res => setStatus('on hold'))
    }
    getStatus();

  }, []);

  useEffect(() => {
    console.log(status);
  }, [status]);

A: My guess is you're doing something else in your component that interferes. Can you show the entire component?
Also, does this work? (Basically just some refactoring, and using this little hook.
function usePromiseMemo(callback, deps) {
  // Private states
  const [state, setState] = useState();
  const isMounted = useRef(true);

  // Register unmount
  useEffect(() => {
    if (!isMounted.current) isMounted.current = true;
    return () => {
      isMounted.current = false;
    };
  }, []);

  // Execute callback
  useEffect(() => {
    if (isMounted.current) {
      if (state !== undefined) setState(undefined);
      Promise.resolve()
        .then(() => callback())
        .then(r => {
          if (isMounted.current) setState(r);
        });
    }
  }, deps || []);

  // Return state
  return state;
}

// YOUR COMPONENT HERE
function MyComponent(props: any) {
  const [status, setStatus] = useState('pending');

  // Result of axios.get("api")
  const response = usePromiseMemo(
    () =>
      axios.get('api').then(res => {
        setStatus('on hold');
        return res;
      }),
    [setStatus]
  );

  useEffect(() => {
    console.log(status);
  }, [status]);

  return

;
}


text:
Q: React Native App and a UnStable Internet Connection I have an React Native app that relies heavily on an internet connection.
The app has questionnaire functionality (which works fine).
But there is one functionality where the user is supposed to upload an audio-recording, here the app freezes and won't start working again.
I am in need of solutions for how my android app can keep a good user experience with an unstable internet connection! (Most errors happens in Android)
How can I achieve this??
Thank you for your time!

A: check the network connection available or not, on based on the condition the user will show the UI so there will no collapse
use library like

*

*@react-native-community/netinfo

*react-native-network-info
https://reactnative.directory/?search=network&order=relevance


text:
Q: shell bad subsitution error retrieving jenkins env variables I am trying to use a jenkins env variable within my shell script but getting "bad subsitution error "
shellscript
#!/usr/bin/env bash

#Set Parameters

"echo \"from shell i=${env.abc}\""
echo \"test test="${env.abc}"\"
echo "${env.abc}"

I have tried to retrieve the values for jenkins environment variable abc in my shell script through all above ways. It gives me "bad substitution" error
This variable is being generate runtime in jenkins pipeline and is being set to jenkins env variable at runtime.
jenkins file:
pipeline {
    agent { node { label 'pqr' } }
    stages {
        stage( 'stage1') {
            steps {
                script {
                   withEnv(["address=https://xxxxxxxxxx.com"]) {
                        withCredentials([usernamePassword(credentialsId: 'xxxxxxxx', usernameVariable: 'id', passwordVariable: 'password')]) {

                            abc_original = sh (
                                script: "*************").trim()
                            sh "echo ${abc_original}"

                    withEnv(["abc=${abc_original}"])  {
                    thisPipeline.callpipelinemethod()
                    sh "echo ${env.abc_original}"
//                    }
                    }
                }
            }
        }
    }
}

I am able to fetch the abc_original value through jenkins script but unable to retrieve this value in the shell script.
can someone help?

A: You are missing the returnStdout: true option in your sh call.
It should look like,
         abc_original = sh (
           script: "*************",
           returnStdout: true
         ).trim()


text:
Q: Find the side length of an inscribed tilted cube in a spherical octant
A cube of unknown side length is to be inscribed in the unit spherical octant where all coordinates are nonnegative.  The cube is tilted, and has four vertices belonging to the same cube face on the curved surface of the unit sphere, and two vertices lying on the $xy$ plane, and in addition one vertex on the $xz$ plane, and one vertex on the $yz$ plane.  This is shown in the figure above.  Calculate the tilt angle and the side length of this cube.
My attempt:  Knowing that the four vertices of a cube face lie on the surface of the sphere, it follows that the axis of the cube passing through its center and the center of this cube face, passes through the origin.  Using this fact, we can attach a local coordinate reference frame to the cube with it origin at the center of the cube, and parameterize it using the tilt angle, and the distance of the center of the cube from the world origin.  Then we can express the coordinates of vertices of the cube, using a third variable to represent the side length, and apply the conditions on their coordinates, as set by the question.  From here, the tilt angle and the side length can be found.  I got a tilt angle of $30^\circ$ and a side length of $\approx 0.5011$

A: Attaching a coordinate reference frame to the cube with its $z'$ axis pointing from the origin towards the center of the cube, and its $x'$ axis horizontal (parallel to the $xy$ plane), we can express the coordinates of the vertices.
We have
$\hat{z'} = (\cos(\theta) \cos(\frac{\pi}{4}) , \cos(\theta) \sin(\frac{\pi}{4}), \sin(\theta)) $
where $\theta$ is the tilt angle.
$\hat{x'} = (-\cos(\frac{\pi}{4}), \sin(\frac{\pi}{4}), 0) $
It follows that
$\hat{y'} = (-\sin(\theta) \cos(\frac{\pi}{4}), - \sin(\theta) \sin(\frac{\pi}{4}) , \cos(\theta) ) $
The origin $O'$ of the this $O'x'y'z'$ frame is at the cube center $C$ where
$C = r $\hat{z'} $
If the side length of the cube is $s = 2a$ then, we have the following vertices coordinates expressed in the coordinate system $O'x'y'z'$
$P_1 = a (1, -1, -1  ), P_2 = a (1, 1, -1),  P_3 = (1, 1, 1) $
The corresponding world coordinates of these points are
$Q_1 = C + R P_1, Q_2 = C + R P_2 , Q_3 = C + RP_3 $
where $R = [\hat{x'} , \hat{y'} , \hat{z'} ] $
Hence,
$Q_1 = r \hat{z'} + a (\hat{x'} - \hat{y'} - \hat{z'} ) $
Plugging the expressions for the unit vectors above and letting $c_1 = \cos(\frac{\pi}{4}) = \frac{1}{\sqrt{2}}$, then
$Q_1 = \begin{bmatrix}  c_1( r  \cos \theta + a  (-1 +  \sin \theta -  \cos \theta))  \\
 c_1( r  \cos \theta + a ( 1 +  \sin \theta -  \cos \theta ) ) \\
 r \sin \theta + a (- \cos\theta - \sin \theta ) \end{bmatrix}$
Similarly, for $Q_2$
$Q_2 = r \hat{z'} + a (\hat{x'} + \hat{y'} - \hat{z'} ) $
$Q_2 = \begin{bmatrix}  c_1( r  \cos \theta + a  (-1 -  \sin \theta -  \cos \theta))  \\
 c_1( r  \cos \theta + a ( 1 -  \sin \theta -  \cos \theta ) ) \\
 r \sin \theta + a ( \cos\theta - \sin \theta ) \end{bmatrix}$
And,
$Q_3 = r \hat{z'} + a (\hat{x'} + \hat{y'} + \hat{z'} ) $
$Q_3 = \begin{bmatrix}  c_1( r  \cos \theta + a  (-1 -  \sin \theta +  \cos \theta))  \\
 c_1( r  \cos \theta + a ( 1 -  \sin \theta +  \cos \theta ) ) \\
 r \sin \theta + a ( \cos\theta + \sin \theta ) \end{bmatrix}$
Now we will impose the conditions on $Q_1$ , $Q_2$ and $Q_3$. We have that the $z$ coordinate of $Q_1$ is zero, therefore,
$ r \sin \theta + a (- \cos\theta - \sin \theta ) = 0 \hspace{20pt}(1)$
Next, we know that the $x$ coordinate of $Q_2$ is zero
$ r  \cos \theta + a  (-1 -  \sin \theta -  \cos \theta) = 0 \hspace{20pt}(2)$
Finally, point $Q_3$ is on the unit sphere.  Equations $(1)$ and $(2)$, (since $r, a$ are non-zero), imply that
$ \sin \theta (-1 - \sin \theta - \cos \theta) - \cos \theta( -\cos\theta - \sin \theta ) = 0 $
And this reduces to
$ - \sin \theta - \sin^2 \theta + \cos^2 \theta = 0 $
So,
$ 1 - 2 \sin^2 \theta = \sin \theta $
whose solution is $\theta = \dfrac{\pi}{6} $.
Using the found value of $\theta$ in equation $(1)$
$  r  - a (\sqrt{3} + 1 ) = 0 \hspace{20pt}(3)$
so that, $r = (1 + \sqrt{3}) a \hspace{20pt}(4) $
Using the value of $\theta$ and equation $(4)$ into the expression for $Q_3$, it becomes
$Q_3 = a \begin{bmatrix}   \frac{1}{2} c_1( 2 \sqrt{3})  \\
 \frac{1}{2} c_1( 4  + 2 \sqrt{3}  ) \\
  1 + \sqrt{3}  \end{bmatrix}$
Adding the squares of the components of $Q_3$ and equating that to $1$,
$ a^2 (\frac{1}{8} ( 12 + 16 + 12 + 16 \sqrt{3} ) + 4 + 2 \sqrt{3} ) = 1 $
Simplifying,
$a^2 ( 9 + 4 \sqrt{3} ) = 1 $
Hence
$ a = \dfrac{1}{\sqrt{ 9 + 4 \sqrt{3} }} $
Hence the side length is
$ s = 2 a  = \dfrac{2}{\sqrt{9 + 4 \sqrt{3}}} \approx 0.50112561417 $


text:
Q: Am I losing the 3NF of my table when I populate it with information Created 2 tables which have a relation and are in 3NF.
Table Employee:
Emp_ID

Emp_First_Name

Emp_Last_Name

Emp_DOB

Table Training:
Training_ID

Train_Desc

Train_Date

Emp_ID (FK)

Even though they are in 3NF now, when I populate the training table with information and 2 people have the same training, wouldn't the Training table lose its 3NF? For example, as follows where the data is repeated.

A: Let me explain,
First you should have master table for keeping training details as ,
Table ms_training:

pk_training_id int (Primary,identity)
training_date date
training_desc text

Then there should be transactional mapping table, which maps Training with Employee as,
Table tr_training:

pk_trainingTr_id (Primary key,identity)
fk_training_id(FK ref. ms_training)
Emp_ID (FK)

I hope I have able to explained properly, if not let me know.


text:
Q: How can i add the values in the firebase database and store the total   reference.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

                   double total = 0;

                    for( DataSnapshot ds :dataSnapshot.getChildren()) {
                        incomeinfo incomeinfo = ds.getValue(incomeinfo.class);
                        double amount = Double.valueOf(incomeinfo.getAmount());
                        total = total + amount;
                    }
                }

                @Override
                public void onCancelled(@NonNull DatabaseError databaseError) {

                }
            });

this is my reference code for the adding the total of amount
public class incomeinfo {

    public String payeename;
    public double amount;
    public String status;
    public String mod;
    public double total;

    public String getPayeename() {
        return payeename;
    }

    public void setPayeename(String payeename) {
        this.payeename = payeename;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMod() {
        return mod;
    }

    public void setMod(String mod) {
        this.mod = mod;
    }

    public double getTotal() {
        return total;
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public incomeinfo(String payeename, double amount, String status, String mod, double total) {
        this.payeename = payeename;
        this.amount = amount;
        this.status = status;
        this.mod = mod;
        this.total = total;
    }
}

My incomeinfo class to store the data to firebase
firebase overview need to add the amount sum in all the different groups click here to view the image
some one please help me to add the sum of all the amounts.

A: after your for-each loop you have to go through the database again and set field "total" by value you just counted before and save every instance of incomeinfo to you DB
something like this
for(DataSnapshot ds : dataSnapshot.getChildren()) {
                    incomeinfo incomeinfo = ds.getValue(incomeinfo.class);
                    incomeinfo.setTotal(total);
                    dbHelper.saveIncomeinfo(incomeinfo);
                }


text:
Q: How to call a callback function in a PHP class I want to use array_filter to remove those items in an array whose value is equal to a specific character like '.' . To do, so I used the following code but I don't know how to pass the callback function to array_filter:
    class Myclass(){
            private function isPunc($var){
        if($var=='.'){
            return TRUE;
        }else{
            return FALSE;
        }
        public function myfunction($arr){
         $arr = array_filter($arr,"isPunc");
    }

    }

Any idea how to solve this problem?

A: use $arr = array_filter($arr, array($this, 'isPunc'));

A: class Myclass(){

    private function isPunc($var) {
        if ($var=='.') {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    public function myfunction($arr) {
         $arr = array_filter($arr, array($this,'isPunc'));
    }

}

A: array_filter() expects a Callable. This is an special internal type in PHP that can be on of four things:

*

*a string with function name

*an array with an object and method name as elements

*an anonymous function

*a functor (an object that implements __invoke)

In your case the second variant should work:
class FilterIsDot {

  private function accept($element) {
    if($element == '.'){
      return TRUE;
    }else{
      return FALSE;
    }
  }

  public function filter($array) {
    return array_filter(
      $array, array($this, 'accept')
    );
  }
}

$in = array('.', 'foo');

$filter = new FilterIsDot();
var_dump($filter->filter($in));

I would suggest a different approach avoiding array_filter(). SPL contains a FilterIterator class. You can extends this class:
class FilterIsDot extends FilterIterator {

  public function __construct($arrayOrIterator) {
    parent::__construct(
      is_array($arrayOrIterator)
        ? new ArrayIterator($arrayOrIterator)
        : $arrayOrIterator
    );
  }

  public function accept() {
    if($this->current() == '.') {
      return TRUE;
    }else{
      return FALSE;
    }
  }
}

$in = array('.', 'foo');

$filter = new FilterIsDot($in);
var_dump(iterator_to_array($filter));

In this case the filter works on the fly. It is only used if the elements are actually accessed.


text:
Q: Debugging native c++ threads I have developed some c++ libraries and now I want to use it in android, but I have a problem, I'm not able to debug this libraries on android, I have tried with  Sequoyah plugin for eclipse, I have tried connect directly agains gdb server into the device, but I can't.
I'm using Sony Ericsson Xperia arc lt15i and Android 2.3.3, so in theory I must be able to debug the natives threads.
Any idea or help? Someone have been able to debugged natives threads?
Thanks

A: Have you read this:
wiki.eclipse.org/Sequoyah/ndk_guide


text:
Q: Customizing endnotes: hanging indent + justified text + no space between notes This is what I want to achieve for endnotes in a book typeset using LuaLaTeX 2020.

*

*Endnote marker at the left margin

*Hanging indent (endnote text should indented throughout, not just first line of each note)

*No line space between successive notes

*Endnote text fully justified

I started with the answer here
\documentclass{book}
\usepackage{endnotes}
\usepackage{lipsum}
\renewcommand\enoteformat{%
  \raggedright
  \leftskip=1.8em
  \makebox[0pt][r]{\theenmark. \rule{0pt}{\dimexpr\ht\strutbox+\baselineskip}}%
}
\begin{document}
\endnote{\lipsum[1]}\endnote{\lipsum[2]}
\theendnotes
\end{document}

and changed the code to remove the space between two notes by deleting +\baselineskip. This worked and the extra space was gone. So then I tried to justify the endnote text using justify (I am using ragged2e anyway in my book). This is my code now
\documentclass{book}
\usepackage{endnotes}
\usepackage{lipsum}
\usepackage{ragged2e}
\renewcommand\enoteformat{%
  \justify
  \leftskip=1.8em
  \makebox[0pt][r]{\theenmark. \rule{0pt}{\dimexpr\ht\strutbox}}%
}
\begin{document}
\endnote{\lipsum[1]}\endnote{\lipsum[2]}
\theendnotes
\end{document}

But this reintroduced the space between the endnotes. I tried playing around but cannot figure out how to eliminate the space.

A: Finally got it working. The trick is to remove \raggedright, not add \justify but instead add \noindent before \makebox. This is my code now.
\documentclass{book}
\usepackage{endnotes}
\usepackage{lipsum}
\usepackage{ragged2e}
\renewcommand\enoteformat{%
  \justify
  \leftskip=1.8em
  \makebox[0pt][r]{\theenmark. \rule{0pt}{\dimexpr\ht\strutbox}}%
}
\begin{document}
\endnote{\lipsum[1]}\endnote{\lipsum[2]}
\theendnotes
\end{document}


text:
Q: Disk not ejected properly message since started to use El Capitan I use an external LaCie hard disk as my Time Machine backup drive for MBP.
But since I have upgraded to El Capitan, every time I opened the laptop, I'm getting greeted by at least two notifications:

External Disk is not ejected properly

I tried to exclude the backup disk from Spotlight, but it is not working.
I've never faced this issue in any of previous OSX releases.
Any ideas? It is quite annoying.


text:
Q: Webscraping with Python BeautifulSoup - further search for terms in filtered soup I am still quite a beginner, I have made myself a webscraping script that works to my satisfaction so far. With the script records are written to me in a csv file.
Now I would like to extend the script, but I can't find the right approach.
I would like to further filter the results that my script brings before writing them into the CSV. Namely, only those records should be written, where either in the field short_b or organization certain terms occur.
Something like this:
if short_b contains "term 1 or term2 or term 3.....)

or
if organization contains "term1 or term2 or term3 ...)

How can I implement something like this?
Here is the code so far of the subroutine in which I want to include the filtering. Don't be surprised some terms are german (I am german):
while True:

        soup = BeautifulSoup(driver.page_source, "html.parser")
        results = soup.find('div', {'id':'contentContainer'}).find('tbody').find_all('tr')

        for i in results:

            verdatum = i.find_all('td')[0].get_text().strip()

            # create date via datetime
            dateString = verdatum
            dateFormatter = "%d.%m.%Y"
            ver_datum_date = datetime.strptime(dateString, dateFormatter).date()

            # check date
            if ver_datum_date >= pruefdatum:

                # create list
                verdatum = i.find_all('td')[0].get_text().strip()
                frist = i.find_all('td')[1].get_text().strip()
                ausschreibung = i.find_all('td')[2].get_text().strip()
                typ = i.find_all('td')[3].get_text().strip()
                organisation = i.find_all('td')[4].get_text().strip()

                i_info = {
                    'Vergabedatum': verdatum,
                    'Frist':  frist,
                    'Organisation': organisation,
                    'Ausschreibung': ausschreibung,
                    'Typ': typ,
                    'Website': website,
                    'Prüfung ab': pruefdatum_format,
                    'Datei erzeugt': jetzt

                }
                ausschreibungsliste.append(i_info)

        # print(ausschreibungsliste)
        time.sleep(2)

        # check pagination
        if not soup.find('a', {'class':'browseLastGhost'}):
            next=driver.find_element_by_xpath('//a[@class="browseForward"]').click()
        else:
            print('Ausschreibungen gefunden :', len(ausschreibungsliste))
            break

Thanks a lot.
With the help of HedgeHog is this the final code:
while True:

        soup = BeautifulSoup(driver.page_source, "html.parser")
        results = soup.find('div', {'id':'contentContainer'}).find('tbody').find_all('tr')

        for i in results:

            verdatum = i.find_all('td')[0].get_text().strip()

            # create date via datetime
            dateString = verdatum
            dateFormatter = "%d.%m.%Y"
            ver_datum_date = datetime.strptime(dateString, dateFormatter).date()

            # check date
            if ver_datum_date >= pruefdatum:

                # create list
                verdatum = i.find_all('td')[0].get_text().strip()
                frist = i.find_all('td')[1].get_text().strip()
                ausschreibung = i.find_all('td')[2].get_text().strip()
                typ = i.find_all('td')[3].get_text().strip()
                organisation = i.find_all('td')[4].get_text().strip()

                i_info = {
                    'Vergabedatum': verdatum,
                    'Frist':  frist,
                    'Organisation': organisation,
                    'Ausschreibung': ausschreibung,
                    'Typ': typ,
                    'Website': website,
                    'Prüfung ab': pruefdatum_format,
                    'Datei erzeugt': jetzt

                }

                if any(term in organisation for term in begriffeorganisation):
                    ausschreibungsliste.append(i_info)
                if any(term in ausschreibung for term in begriffeausschreibung):
                    ausschreibungsliste.append(i_info)

        # print(ausschreibungsliste)
        time.sleep(2)

        # check pagination
        if not soup.find('a', {'class':'browseLastGhost'}):
            next=driver.find_element_by_xpath('//a[@class="browseForward"]').click()
        else:
            print('Ausschreibungen gefunden :', len(ausschreibungsliste))
            break

A: There is a wild mix in your namings so I tried to focus on the namings in code part it also is missing the short_b from your example
A general approach could be to check with any() if there is a term from a list in you extracted strings:
term_list = ['term1','term2', 'term3']

if any(term in organisation for term in term_list):
     ausschreibungsliste.append(i_info)

or as mentioned you could filter your DataFrame:
df = pd.DataFrame(ausschreibungsliste)

term_list = ['term1','term2', 'term3']
df[df['Organisation'].str.contains('|'.join(term_list))]


text:
Q: Can the WPF ResourceDictionary return a new instance for each request We're using ResourceDictionaries to store layout information for our app. The lazy initialisation is great because we can grab the required layout for an element only when that element is created. The problem is that each element gets the same instance from the ResourceDictionary for each one that shares the layout (or the same one if it goes out of scope and is needed later).
We could store templates in the dictionary then it doesn't matter if they're shared but we have quite a nice system going if it wasn't for this caching behaviour.
Is there a way to change this behaviour of the dictionary or am I going to have to write my own class which creates items from the XAML on demand?

A: Try applying x:Shared="false" attribute. Each resource should then get seperate copy.


text:
Q: Unable to change upload_max_filesize in php.ini Running PhP v. 5.6.12 on localhost after extracting xampp-win32-v. 5.6.12.0-VC.7z through xampp control panel v. 3.2.1 with administrator rights on Windows 7 Ultimate (64-bit).
After editing php.ini in the php folder in xampp to change upload_max_filesize, phpinfo() shows no change of default value i.e. 2M. Checked phpinfo() through xampp and by creating a test file also. Same value of 2M is displayed.
Searched all concerned forums, but same old solutions didn't solve the problem. Any help will be appreciated. Thanks.

A: Providing solution to help others having similar problems. Editing the original php.ini file in Notepad++ v. 6.8.3  didn't have any effect. Therefore, copied contents of the original php.ini file and pasted it to create a new php.ini file in Notepad++ itself. Changed the required values and saved. Bingo!

A: Like yourself, I tried all the available solutions with no success so I figured why not to delete the file and create a new one from scratch. And voila it worked.
I use Visual Code Studio but it should work with other file editors.


text:
Q: Silent failure loading page application in iframe over https Problem
I have an application driving a tab on a client's page. The application works correctly if the user has not enabled FB's "secure browsing" feature. If attempting to view over HTTPS, the iframe doesn't even appear (no errors, no mixed-content warnings). When correctly loading over HTTP, the div with the id "pagelet_app_runner" has an iframe inserted into it and the application content is loaded inside there. Over HTTPS, this div remains empty and the iframe is not inserted into the page. There are no Javascript errors appearing in Firebug or Chrome's equivalent console.
Why I'm Asking Here
The host has a valid SSL certificate and there is no 'mixed content' at the URL in question. I can successfully view the content over HTTP or HTTPS by visiting the URL directly, and I can do the same by visiting apps.facebook.com/canvasURL/tabURL. It is only when attempting to view within a Page Tab that the HTTPS load fails as described above. My application is configured with both regular and secure canvas and tab URLs.
Attempted Debugging
I've recorded some sessions with Charles but since the iframe isn't being inserted into the page, I think I'm coming at the problem after it's already occured. I'm no Charles expert so happy to be corrected here.
Apache isn't seeing any request (in either regular or ssl logs) for the affected loads. non-SSL loads come through as expected in access_log.
Plea for Help
I'm out of ideas for debugging this. Does anybody have any suggestions? What really obvious and stupid mistake might I have made? :)
edit: nicer formatting

A: Your app canvas URL is https://skinnycomp.nextstudio.com.au/skinnycowcomps/ , which send 404 error to Facebook proxy (request is going through proxy when viewing app via tab), also when viewing your app via apps (https://apps.facebook.com/122381834451561/), again 404... maybe Facebook proxy is ignoring 404 and posting blank...
Try changing canvas URL to https://skinnycomp.nextstudio.com.au/skinnycowcomps/tab, also you can check if your app is accessed via page tab, in signed_request there should be page_id...
23:51:15.379[549ms][total 1667ms] Status: 404[Not Found]
GET https://skinnycomp.nextstudio.com.au/skinnycowcomps/

A: This is a real longshot since I'm sure you've triple checked all the settings, but the blank page can happen if an invalid url is specified in the Page Tab URL field in the app settings. Since it only happens on https, it would imply something specifically with the Secure Page Tab URL entry. It might be worth checking that again, and maybe even re-saving it or changing it to something else to see if it helps.

A: I was using relative URLs for the regular and secure tab URL fields. From memory relative URLs here were mandatory at some point in the past. It appears now that a relative URL will still work for HTTP but not for HTTPs. Fix: absolute URLs. Hopefully FB update their field validation to match what's required too.


text:
Q: Persistent storage in PHP (Data_Registry class) I'm using this library: http://code.google.com/p/data-registry/ with an ExpressionEngine system.
I initialize and set data in an EE plugin like this:
Data_Registry::init('MYPAGE');
Data_Registry::setPersistence(TRUE,TRUE)->restoreNameSpace();
Data_Registry::set('MYPAGE_DATA',json_encode($data['result']));
Data_Registry::set('MYPAGE_LOGGEDIN',true);

If I then log the values with this code, it shows the values correctly.
$fp = fopen('login_model.txt', 'a');
fwrite($fp, "Data:".Data_Registry::init('MYPAGE')->get('MYPAGE_DATA'). "\n");
fwrite($fp, "Loggedin:".Data_Registry::init('MYPAGE')->get('MYPAGE_LOGGEDIN'). "\n");
fclose($fp);

However, when trying to retrieve these values in a template using this code:
$data     = Data_Registry::init('MYPAGE')->get('MYPAGE_DATA');
$loggedin = Data_Registry::init('MYPAGE')->get('MYPAGE_LOGGEDIN');
$fp       = fopen('login_model.txt', 'a');
fwrite($fp, "Data:".$data . "\n");
fwrite($fp, "Loggedin:".$loggedin . "\n");
fclose($fp);

Both values are blank.
Am I doing something wrong here?

A: From Waygood's comment:
"If global persistence is enabled, all namespaces are loaded automaticly" so I assume you have to Data_Registry::setPersistence(TRUE,TRUE)->restoreNameSpace(); on the template to? unless you have set it as the default parameter


text:
Q: Spring Social Facebook: how to get post's owner which is liked by authenticated user I have developed a Spring application which uses Spring Social Facebook, in order to get users activities in social network.
I need to know how i can get post's owner which is liked by authenticated user, and which permission is required to perform this operation.
For sake of clarity: User A (authenticated) likes a post belonging to user B. How i can get user B?
Any ideas?

A: Here you have url from facbook api explorator
me/posts?fields=from,message,picture,icon

This rest execution should return all posts - posted by current user and other users which was liked by him/her. Know you have to write it in Java, below code fetches data from the specified connection.
facebook.fetchConnections(null, "music", Page.class,
            new PagingParameters(25, 0, null, null).toMap(), "from,message,picture,icon")

You can also try (but this I haven't tested)
facebook.fetchConnections(null, "posts", Post.class)


text:
Q: Problems with ligature and libertine font - I cannot post a comment under my previous question so  (i fixed some files because i misunderstood somethings, but there is a problème with tt => fl in sffamily not smallcaps and it seems it cannot do sffamily regular
why do pdflatex have thoses ligatures but they do not work in tex4ebook (lualatex ?)
\documentclass[10pt,a5paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage[left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.5cm]{geometry}
\usepackage{libertine}
\newcommand{\testfont}[1]{
rmfamily\\
{\rmfamily #1\\{\scshape #1}\\\\
\textbf{#1\\{\scshape #1}}\\\\
\textit{#1\\{\scshape #1}}\\}

sffamily\\
{\sffamily #1\\{\scshape #1}\\\\
\textbf{#1\\{\scshape #1}}\\\\
\textit{#1\\{\scshape #1}}\\}
}
\begin{document}
\testfont{ff fli ffi ffr tt th qu FF FLI FFI TT TH}
\end{document}

tex4ebook result

pdflatex result

Problems with ligatures

A: This is result of wrong support files for Libertine fonts in tex4ht. Each used font needs special file with mapping of the character codes in the DVI file to Unicode. The mappings for fonts used in your document expects the standard T1 font encoding, but Libertine fonts use some additional ligatures, so some characters are mapped incorrectly.
The process of creation of the mapping files is quite difficult and error prone. I am working on a tool called Htfgen which can in ideal cases generate the mapping files automatically. It contain lot of scripts and libraries, the most interesting one is called dvitohtf. It can either parse dvi file for the missing map (htf) files, or read list of fonts from the standard input. It then outputs TeX file, which then writes htf files when processed with plain TeX.
This is the TeX file created by this script for all fonts used in your document: mylibertine.tex. I had to put it to a gist, because it is larger than Stackexchange allows in the posts.
Compile it using
tex mylibertine.tex

It should write all necessary HTF file.
Result:


text:
Q: how to compare environment for equality in R I would like to check if the current environment is the global environment in R.  However, direct comparison doesn't seem to work with evironments.  What is the best way to do this?
#doesn't work
sys.frame() == .GlobalEnv

A: Matthew Plourde's solution:
> identical(sys.frame(),.GlobalEnv)
[1] TRUE

You can also check names, though this might be less reliable:
> environmentName(sys.frame())=="R_GlobalEnv"
[1] TRUE


text:
Q: What is the Microsoft Dynamics CRM 2013 iPhone app custom url scheme? Currently we're using two web applications in our sales process, one to create quotes and one to create customers and contacts. Both apps have been built as a HTML5 web application, hosted in Safari on an iPhone.
We're thinking of using Microsoft Dynamics CRM 2013 for the creation of customers and contacts, thus replacing the previous app. We'd like to use the iPhone app for that.
When the users want to create a quote for a new customer it should be possible to start the Microsoft Dynamics CRM 2013 iPhone app from within the quote app and direct the user straight to the CRM iPhone app (and preferably the screen were a user can add a customer).
I know it is possible to start native apps straight from Safari (see Opening Native App. from Safari).
However, I can't find any information about a custom url scheme for the Microsoft Dynamics CRM 2013 iPhone app and would be very happy if anyone could direct me to more information about ways to implement this. Thanks in advance for any information!

A: As far as I know there is no custom uri scheme support in the Microsoft Dynamics CRM mobile apps, at least I haven't been able to find any information about it.
There is a way to find the custom uri scheme from an ipa file as described here: How can I extract the Custom URL Scheme from a .ipa file?, maybe you can try that.


text:
Q: Check array key parameters and call method with appropriate amount of parameters I've got a class with methods that take a different amount of parameters. And I got an array with methods, also with different amount of parameters.
I need to call the methods with the proper amount of parameters for it to work. If the key  in the array has no value, there should always be $input passed through as the first parameter.
Anybody who knows what I'm doing wrong or need to do to achieve it?
$arr = ['trim', 'between' => [6, 254]];

My failed attempt
foreach ($arr as $method) {
    if (count($method) === 0) {
        $this->$method($input);
    } elseif (count($method) === 1) {
        $this->$method($input, $method[0]);
    } elseif (count($method) === 2) {
        $this->$method($input, $method[0], $method[1]);
    }
}

Error
Fatal error: Method name must be a string in (..) on line N

Methods
private function trim($input) //1 param
{
    $this->input = trim($input);
}

private function max($input, $max) //2 params
{
    if (!(strlen($input) <= $max)) {
        $this->errors[] = __FUNCTION__;
    }
}

private function between($input, $min, $max) //3 param
{
    if (!(strlen($input) > $min && strlen($this->input) < $max)) {
        $this->errors[] = __FUNCTION__;
    }
}

A: You can easily call whatever method you want dynamically with a variable number of arguments with call_user_func_array. There's just some details to take care of.
First, the format of $arr is convenient but it's not consistent. Sometimes the method name is the value (e.g. trim), sometimes it's the key (e.g. between). You need to normalize things:
foreach ($arr as $key => $value) {
    if (is_int($key)) {   // $key => 'trim'
        $method = $value;
        $arguments = [$input];
    }
    else {                // 'trim' => [...]
        $method = $key;
        $arguments = array_merge([$input], is_array($value) ? $value : [$value]);
    }

Now that you have $method and $arguments neat and tidy, the final step is trivial:
    call_user_func_array([$this, $method], $arguments);

A: to understand an error
$arr = [0 => 'trim', 'between' => [6, 254]];
you iterate values so in $method you got 1) 'trim', 2) [6,254] (not 'between')


text:
Q: How to take the derivative of this strange alternative to a devil's slippery staircase? I am trying to construct a function $f(x)$ which

*

*has derivative = $0$ almost everywhere, and

*is strictly increasing.

I realize one can do this by playing with the Cantor function, but I would like to do it directly. However, I am having difficulty seeing if the beautiful monster has a derivative at all!
Let $(a_k)$ be a sequence of numbers, such that $\sum |a_k| < \infty$, and $a_k > 0$. Define an ordering on $q_k \in \mathbb{Q}$, which one can do because $\mathbb{Q}$ is countable and totally ordered.
Define $f: \mathbb{R} \to \mathbb{R}$, $$f(x) = \sum\limits_{\{k \text{ : } q_k < x\}} a_k$$
We see that $f_k$ is strictly increasing (thus is both increasing and non-constant on any open interval), for $\mathbb{Q}$ is dense in $\mathbb{R}$, and any open interval in $\mathbb{R}$ contains an element of $\mathbb{Q}$.
I would think this function would have derivative zero on all but $\mathbb{Q}$, which are totally disconnected and countable, and a disjoint union of countably many points has Lesbegue measure 0.
The issue is that I don't know how to rigorously show that $|f'| = 0$ a.e., indeed, I don't know how to check that $f$ is differentiable. I don't know how to see that this $$\lim_{x \to x_0} \frac{f(x) - f(x_0)}{ x - x_0}$$
has limit $0$ on $S \subset \mathbb{R}$ such that the Lesbegue measure of $\{ \mathbb{R} - S \}$ is $0$.
Here is my question: How do I take the derivative of this function? Does this function satisfy the desired criterion?

A: Your construction might work for some choices of the enumeration $(q_k)$ of $ Q$ and some choices of $(a_k)$ but if $a_k=1/k^2$ and if $q_{2k}\in (\pi, \pi+2^{-k})$ for each $k$, then $f(\pi+2^{-k})-f(\pi)\geq \sum_{j\geq k}1/(4j^2)= 1/(4k) + o(1/k)$ as $k\to \infty$, so $f'(\pi)$ does not exist.

A: Revised:
As noted below in the original version, the fact that $f'$ exists almost everywhere is immediate from standard results, for example in Folland. Those results rely on other results - putting it all together into a proof requires a substantial fraction of the results in that chapter. Here's an entirely self-contained ad hoc proof.
If $I$ is an interval we let $3I$ denote the interval with the same center but three times the length: If $I=(a-r,a+r)$ then $3I=(a-3r,a+3r)$.
Lemma 1 Suppose that $K\subset\Bbb R$ is compact and $C$ is a collection of open intervals covering $K$. Then there exist finitely many pairwise disjoint $I_1,\dots,I_n\in C$ such that $3I_1,\dots,3I_n$ cover $K$.
Proof: We can suppose $C$ is finite. Let $I_1$ be an element of $C$ of maximal length. "Discard" any element of $C$ that intersects $I_1$. Note that if $I$ was discarded just now then $I\subset 3I_1$, since $I$ intersects $I_1$ and $I$ is no longer than $I_1$.
Now let $I_2$ be one of the "remaining" intervals in $C$ of maximal length. Discard any remaining interval that intersects $I_2$. Note that any interval discarded at this stage is contained in $3I_2$. Also note that $I_1$ and $I_2$ are disjoint, since $I_2$ was not discarded at the first stage.
Etc. QED.
Now for $f:[0,1]\to\Bbb R$ define $$Mf(x)=\sup_{y\ne x}\left|\frac{f(x)-f(y)}{x-y}\right|$$and $$\omega f(x)=\limsup_{y\to x}\left|\frac{f(x)-f(y)}{x-y}\right|.$$Note that $$0\le\omega f(x)\le Mf(x)$$and that $f'(x)=0$ if and only if $\omega f(x)=0$.
Lemma 2 If $f:[0,1]\to\Bbb R$ is nondecreasing then $$m\left(\{x\in[0,1]\,:\,Mf(x)>\lambda\}\right)\le \frac c\lambda(f(1)-f(0)).$$
Proof: Since $m$ is inner regular it is enough to show that $m(K)$ satisfies the same inequality, where $K$ is a compact set with $Mf(x)>\lambda$ for every $x\in K$.
For each $x\in K$ there exists $y\ne x$ with $|(f(x)-f(y))/(x-y)|>\lambda$. Let $J_x=[x,y]$ or $J_x=[y,x]$, whichever makes sense. Let $I_x$ be an open interval containing $J_x$, with $|I_x|\le 2|J_x|$.
Now the $I_x$ for $x\in K$ form an open cover of $K$. Hence, writing $I_j$ in place of $I_{x_j}$, there exist finitely many disjoint $I_1,\dots I_n$ such that $3I_1,\dots,3I_n$ cover $K$.
Aargh, we need more notation because we didn't know whether $x<y$ or $y<x$ at the start of this. Each $I_j$ is an open interval containing $J_j$, where $|I_j|\le 2|J_j|$. Write $J_j=[a_j,b_j]$. Now
$$m(K)\le\sum m(3I_j)\le 6\sum m(J_j)=6\sum_{j=1}^n(b_j-a_j).$$But $(f(b_j)-f(a_j)/(b_j-a_j)>\lambda$, so that $b_j-a_j\le(f(b_j)-f(a_j))/\lambda$. So we have $$m(K)\le\frac6\lambda\sum_{j=1}^n(f(b_j)-f(a_j)).$$But since $f$ is nondecreasing and the $[a_j,b_j]$ are disjoint, $$\sum(f(b_j)-f(a_j))\le f(1)-f(0).$$QED.
Note of course both lemmas are analogous to results in that chapter in Folland, adapted to the present context.
And now we can show that your $f$ has $f'=0$ almost everywhere. Write $f=\sum f_n$ in the obvious way. Write $$f=s_N+r_N,$$where $$s_N=\sum_{n=1}^Nf_n.$$
For every $N$ we certainly have $s_N'=0$ almost everywhere, so $\omega s_N=0$ almost everywhere. Hence $$\omega f\le\omega s_N+\omega r_N=\omega r_N\le Mr_N$$almost everywhere. Let $\epsilon>0$. Choose $N$ so that $$\frac c\epsilon(r_N(1)-r_N(0))<\epsilon.$$Then the set where $Mr_N>\epsilon$ has measure less than $\epsilon$. So the previous inequality shows that the set where $\omega f>\epsilon$ has measure less than $\epsilon$. So $\omega f=0$ almost everywhere. QED.

Original:
Yes, $f'=0$ almost everywhere. (Assuming $a_k>0$ and $\sum a_k<\infty$.)
This is not quite trivial. I don't know how much real analysis you know; the fact that $f'=0$ almost everywhere is immediate from basic/standard results in reals.
See for example Proposition 3.30 in Folland Real Analysis, as well as related results in that section. Your function $f$ is non-decreasing, hence it has bounded variation. There are fussy details regarding whether or not $f$ lies in what Folland calls NBV, but Theorem 3.23 shows that this doesn't matter; $f$ nondecreasing implies that $f=g$ almost everywhere, where $g$ is in NBV, and also $f'=g'$ almost everywhere. Now in the notation of Proposition 3.30, your $\mu_f$ is a singular measure, being $\sum a_k\delta_{q_k}$ (where $\delta_q$ is a point mass at $q$). So 3.30 says $f'=0$ almost everywhere.
It's not clear to me how difficult a more elementary proof would be (for example a proof accessible to someone taking the course that's called "Advanced Caclulus" here...)


text:
Q: Can I retrieve only certain fields from Windows Azure Table Storage I have the following class:
public class Menu : TableServiceEntity
{

    public string Order { get; set; }
    public string Text { get; set; }
    public int    Length { get; set; }
}

I would like to retrieve only the PartitionKey, RowKey, Order and Length data from my TableStorage.
Is there some way that I can just retrieve this data or do I still need to retrieve everything. The reason I ask is because the Text field contains some large amounts of data and I would like to minimize what is retrieved to just what I need.
Please note this is not SQL Azure storage. Thanks

A: From the 2011-08-18 version you can use the query projection (LINQ Select).
var context = cloudTableClient.GetDataServiceContext();
context.CreateQuery<Menu>().Select(...);

Check this: http://msdn.microsoft.com/en-us/library/windowsazure/dd135725.aspx


text:
Q: How to partition a 16TB table with 3 billion rows within a maintenance window? I've inherited a large table (16TB, 3 billion rows, lot of ntext data), that's never been partitioned. I want to split it over set of filegroups. Current estimate based on limited test is about 70 hours for the index re-create. I'm aware of RESUMABLE, but I think that doesn't solve the problem of trying to squeeze operations into 12 weekly maintenance window and reads wouldn't work properly ...
Any options to achieve this?
Also tried to slice off only the oldest data in test, that doesn't seem to matter, I'm assuming all data gets rewritten. Table has ntext, so columnar possible(?). Free space - not much, couple TB at most.
I'm seeing cutting over to a limited copy with most recent data and then restitching it somehow as only option? Would appreciate your thoughts.


text:
Q: Cannot Turn on Timed publishing mode in Google Play Console I want to update app in Google Play Console as Timed publishing mode. But I cannot turn it on. Cannot find Time Publishing switch. Any idea about this?
My Play Console

A: In the new Google console the wording has changed.
Look for "Publishing overview" in the left side menu, then find the "Managed publishing status" and press "Manage" button.

You will be prompted with a popup that allows to turn the Managed publishing on.

A: Timed Publishing switch will also not appear if you have any version already under review (including in internal tracks).
To confirm a review is in progress you can check the status at the main Dashboard:

Once review completes, you'll find the switch at the bottom of the "Store Listing" page under Store presence in left menu.
It's really at the bottom after all fields, beside the save button.

A: We are having the same issue -- the option to enable isn't where it should be. We reached out to the Google Play Dev Ops team and they notified us that it's a known problem on their side. They are aware and working on it. Cheers.

A: For reference use the below link:
https://support.google.com/googleplay/android-developer/answer/6334282?hl=en

*

*First go to the Publish an app update.

*Then click the Publish with timed publishing.

A: You need to get content rating and other certifications first.
Also set the privacy policy url and upload your first APK.
Then only timely publishing menu will get enabled.

A: Adding step by step guide on timely publishing in new google console

*

*Navigate to your App's Dashboard and select Publishing overview from left side menu.

*Check Managed publishing status. It should be Managed publishing on if not then click manage and opt for Managed publishing on.

*Track google's approval

*After google's approval, go to Publishing overview and check publish button corresponding your app underneath Changes in review.

*Publish it


text:
Q: Given array of integers, find the maximal possible sum of some of its k consecutive elements int sum(vector<int> inputArray, int k, int n)
{
    int s=0;
    for(int i=n; i<n+k; i++)
    {
        s = inputArray[i] + s;
    }

    return s;
}

int solution(vector<int> inputArray, int k) {

    vector<int> answer;
    int ans;

    for(int i=0; i< inputArray.size()-k+1; i++)
    {
        ans = sum(inputArray, k, i);
        answer.push_back(ans);
    }

    int a = *max_element(answer.begin(), answer.end());

    return a;
}

My code gets one hidden test case wrong in codesignal. I am not able to figure it out.
Tests passed: 19/20. Execution time limit exceeded: Program exceeded the execution time limit. Make sure that it completes execution in a few seconds for any possible input.


text:
Q: "She had lost her consciousness last night at pub after having several cocktails". Is this sentence grammatical?
She had lost her consciousness last night at the pub after having several cocktails.

Is the use of had (the past perfect tense) right here?

A: In informal speech and writing, we usually substitute "passed out" for "lost consciousness" when it has occurred as a result of drinking.
As for the use of "had" (past perfect tense), it depends whether the rest of the story is being told in the past tense. With only the one sentence you gave, and based on your use of "last night", it seems you are telling it from perspective of today, so as Josh recommended—  no "had". But if the story continues in the past, e.g. if it tells what happened when she regained consciousness later that night, then "had" might be appropriate.

A: Not quite. A better phrasing is "She lost consciousness last night at the pub after having several cocktails." Consciousness is a state of being, 'losing consciousness' is a compound verb and shouldn't be split, in general.
I would also recommend cleaning up the end of the sentence a little bit, switching "having" to "drinking". Not a usage issue, but generally clearer.


text:
Q: Input Current for Basic Chopper DC I have a very basic question about the input current in a basic DC chopper. Following is a picture taken from the book "Power Electronics for Technology", by Ashfaq Ahmed.

Considering that the switch is ideal, then the power loss during the switching operation is zero and \$V_{\text{o}}I_{\text{o}} = V_{\text{i}}I_{\text{i}}\$. I understand that the input RMS current is the same as the output rms current, however, when I calculate the output RMS voltage and use \$V_{\text{o}}I_{\text{o}} = V_{\text{i}}I_{\text{i}}\$ to determine the output current, the values found are different.
Example: $$V_{\text{RMS}} = V_{\text{i}} \times \sqrt{d}$$ $$ I_{\text{RMS}} = \frac{V_{\text{RMS}}}{R}$$
Input voltage = 100 V, Load = \$10 \Omega\$, duty cycle = 0.4. The output voltage and RMS current are 63.25 V and 6.33 A, respectively. However, the input RMS current calculated by \$V_{\text{o}}I_{\text{o}} = V_{\text{i}}I_{\text{i}}\$ gives 4A.
What am I missing?


text:
Q: When is Encanto's opening scene set? The opening scene (and related flashbacks to same event) depicts young Alma and Pedro escaping their village from violent, shall we say "bandits."
Columbia experienced a Civil War which could reasonably include the type of violence portrayed; the primary belligerents participating in Columbia's Civil War, FARC and the government of Columbia, signed a cease-fire in Sept. 2016, formally ending 52 years of war.
The conflict began on May 27, 1964. However, it's conceivable that low-level political retribution and isolated violence may have been simmering for a long time before that, perhaps decades.
However, even then, this seems like too late a date to allow the candle to be alight for 50 years.
We could stretch this perhaps into the 1920's and 1930's while horseback remained a primary source of transportation.
The history of cars in Columbia started in 1899, when Carlos Coriolano imported the first cars into the country; although pickup trucks became wider spread after the 1930s, car ownership existed as a novelty for rich Columbians from 1899 through the 1930s, and into 1940s. So presumably horse-back ridership by violent political thuggery would be reasonable form of travel through perhaps the 1940s, or even 1950s in rural communities or areas isolated by mountainous terrain.
Are we to assume the opening scene took place during or was associated with "Columbia Civil War" (FARC conflict) during the 1960s, tied to any earlier notable conflict in Columbia's history, or is just unfortunate event untethered to any large-scale conflict?
When is Encanto's opening scene set?

A: According to Alejandra Espinosa, the history and cultural consultant hired by Disney, the film's setting is intentionally vague. But she mentioned the Thousands Day War as a distinct possibility. That war was fought in around 1900, which would align with the horseback riders, and displaced entire villages.
Full quote and Google translation below:

Usted hizo un trabajo de archivo para darle una periodización
histórica a la película. ¿Cuándo se ubica Encanto?
Aunque la película no tiene fecha, se podría ubicar a principios del
siglo XX, por ejemplo, en La guerra de los 1000 días, que sería el
conflicto por el cual huye todo el pueblo. Hay que hacer referencia a
nuestra larga historia de migración, todos somos hijos de andariegos,
migrantes, a veces migrantes que se fueron buscando fortuna, a veces
que fueron desplazados forzosamente por el conflicto. Entonces hay una
historia de desplazamiento importante y una historia de criar y ser
hijos a partir de otras regiones.
You did archival work to give the film historical periodization. When
is Encanto located?
Although the film does not have a date, it could be located at the
beginning of the 20th century, for example, in The 1000 Days War,
which would be the conflict for which the entire town fled. We must
refer to our long history of migration, we are all children of
wanderers, migrants, sometimes migrants who were looking for their
fortune, sometimes who were forcibly displaced by the conflict. So
there is a history of important displacement and a history of raising
and being children from other regions.


text:
Q: Computing $(A^TA)A^T$ versus $A^T(AA^T)$ on a Computer with Limited Memory where $A$ is $1000000 \times 2$ The following is an exercise taken from Aggarwal's Linear Algebra and Optimization for Machine Learning:
Let $A$ be an $1000000 \times 2$ matrix. Suppose you have to compute $A^TAA^T$ on a computer with limited memory. Is it more preferable to compute $(A^TA)A^T$ or $A^T(AA^T)$?
This question is stated at the very beginning of the text, so I only have the definition of matrix multiplication to work with.
I am thinking that it would be preferable to first compute $A^TA$. The reason being that this can be computed as the sum of one million $2\times 2$ outer product matrices, i.e. $A^TA = \sum_{j=1}^{10^6} (\mathrm{Row}_j(A))^T\mathrm{Row}_j(A)$. So to compute $A^TA$, we'd only need to be able to store two $2\times 2$ matrices at a time, just 8 numbers!
On the contrary, first computing $AA^T$ seems like it would require much more memory utilization.
In the context of someone who only knows about the definition of matrix multiplication, would this be correct? What if I knew heavier machinery, like say matrix factorizations, or other tools? Would there be a better way to approach this problem?

A:
In the context of someone who only knows about the definition of matrix multiplication, would this be correct?

$A^TA$ is a $2 \times 2$ matrix (4 total cells), while $AA^T$ is a $1000000 \times 1000000$ matrix ($10^{12}$ total cells).  I think that the choice of which one to store as an intermediate result is obvious.

What if I knew heavier machinery, like say matrix factorizations, or other tools? Would there be a better way to approach this problem?

Sure, there are optimizations you could use.  Like, if you happen to know that $A$ is a sparse matrix, you could use an alternate storage format that doesn't require explicitly storing all of its elements.  You could calculate $AA^T$'s trillion elements on-demand during the second multiplication, instead of explicitly storing all of them.  At the very minimum, you could take advantage of the fact that $AA^T$ is always symmetric to cut your storage space in half.
But regardless of how fancy you make your code, I just don't see any practical way to beat a $2 \times 2$ intermediate result, memory-wise.

A: The product of an $m\times n$ and an $n \times k$ matrix is an $m \times k$ matrix, and each entry requires $n$ multiplications to compute, for a total of $mnk$ multiplications (assuming the naive algorithm).
If $A$ is $m\times n$, then $A^T$ is $n\times m$, and so to compute $(A^TA)A^T$ requires $n^2m$ multiplications for the first matrix multiplication, after which we are multiplying together an $n\times n$ matrix and an $n\times m$ matrix, which will take $n^2m$ multiplications, for a total of $2n^2m$ multiplications.
On the other hand, to computer $A^T(AA^T)$ requires $m^2n$ multiplications to do the first multiplication, but then we are multiplying an $n\times m$ with an $m\times m$ matrix, which will take $m^2n$ multiplications, for a total of $2nm^2$ multiplications.  If $m$ and $n$ are very different from each other, then $2nm^2$ and $2n^2m$ will be vastly different numbers.


text:
Q: How to execute ubuntu.exe and navigate to direct folder with one command? Windows 10 OS.
I'm want to setup phpstorm terminal to use ubuntu.exe "terminal".
When i change it - terminal opens "home" directory for current linux user.
I want to navigate to my certain folder "/var/www/" when terminal inits.
Maybe i should use some flags like this?
 .../ubuntu.exe -e "cd /var/www"

A: So i created bat file with content:
C:\Users\Art4es\AppData\Local\Microsoft\WindowsApps\ubuntu1804.exe run /bin/bash

Then in phpstorm: Settings>Tools>Terminal in 'Shell path' field insert path to this bat file.
Now terminal 'knows' project's directory path.

A: Go to Settings>Tools>Terminal, make sure "Start directory" is set to the desired path:
C:\<path_to_ubuntu_filesystem>\var\www

Set "Sell path":
C:\<path_to_ubuntu_executable>\ubuntu.exe run


text:
Q: How to use Scrum in .NET Framework I want to know how to use Scrum in .NET Framework and why to do this?
I've studied both Scrum and the .NET Framework, but I want to know how to implement Scrum in .NET Framework.

A: Scrum doesn't distinguish by technology. The key issue is learning how to do a lot of the agile development practices in a ".NET context." For example

*

*Learn to use Visual Studio to write unit tests

*Refactoring your code with Visual Studio (thanks to @KentMuntheCaspersen for reminding me of this critical point.)

*Integrate MSBuild with Jenkins or TeamCity for continuous integration

*Add documentation with ///
This of course pertains to the day-to-day developer activities aspect of Scrum. Of course, tools you use to organize your Product Backlog or track Sprint Burndown (like a simple whiteboard with yellow stickies) are the same no matter what you are developing with.
Good luck with your project!

A: Scrum has nothing to do with specific software frameworks.  It is a development strategy and workflow which would work while developing any software.  You wouldn't use Scrum "in .NET", but could easily follow Scrum principles while developing software targetting the .NET Framework, or any other technology, as it's completely technology neutral.

A: Scrum doesn't constrain you to specific software frameworks. However, Team Foundation Server does support Scrum development by default if you want something that is integrated with Visual Studio.


text:
Q: Rspec test keeps failing when passing in a named parameter Sorry in advance....noob question.
I am writing a class to satisfy an Rspec test. It's a test to initialize a class and pass in a string parameter.
My challenge is that the test is passing in a name parameter, and the output keeps failing my test.
Code Below.
My class
module Human
  class Person
    attr_reader :name

    def initialize(name)
       @name = name
    end
  end
end

My Test
RSpec.describe Person::Name do
  subject { described_class.new(name: "Hi my name is peter") }

  it "has a name" do
    expect(subject.name).to eq("Hi my name is peter")
  end

The Result
Human::Person has a name
     Failure/Error: expect(subject.name).to eq("Hi my name is peter")

       expected: "Hi my name is peter"
            got: {:name=>"Hi my name is peter"}

       (compared using ==)

My problem is my class is working, but my output is formatted differently {:name=>"Hi my name is peter"}....it should be"Hi my name is peter"
How do I get my class to return the string output as expected by my test?

A: The test expects that your new method accepts a hash with a name key and a value. The class is not initialized with just a name.
But in your class, you take all the arguments (key plus value) and assign it to the @name variable.
The easiest way to makes this test pass is to used keyword arguments in your initializemethod.
Change
def initialize(name)

to
def initialize(name:)

Read more about kwags - keyword arguments.


text:
Q: How to remove CocoaPods from a project? What's the right way of removing CocoaPods from a project? I want to remove the whole CocoaPod. Due to some limitations imposed by my client I can't use it. I need to have just one xcodeproj instead of an xcworkspace.

A: There can be two aspects developer may face.

*

*Either he wants to remove pods completely from project

*developer wants to uninstall particular framework from project from
pods.

In first case you have to use 'pod deintegrate' and follow several steps which are mentioned in the answers above.
For second case that is if you want to uninstall any particular framework which is installed there very simple way available in your pod file just comment the framework which you want to uninstall and run pod install command.
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

    pod 'iCarousel', '~> 1.8'
#    pod 'Facebook-iOS-SDK', '~> 4.1'
#    pod 'ParseFacebookUtilsV4', '~> 1.11'
#    pod 'Parse', '~> 1.14'

end

Here I want to uninstall facebook and parse frameworks (which were installed using pods) and not iCarousel that is why I have updated my pod file like above.
Now if I run pod install it will keep iCarousel as it is in my project and will remove facebook and parse.

A: To remove pods from a project completely you need to install two thing first...those are follows(Assuming you have already cocoa-pods installed in your system.)...

*

*Cocoapods-Deintegrate Plugin

*Cocoapods-Clean Plugin

Installation

*

*Cocoapods-Deintegrate Plugin
Use this following command on your terminal to install it.
sudo gem install cocoapods-deintegrate

*Cocoapods-Clean Plugin
Use this following command on your terminal to install it.
sudo gem install cocoapods-clean

Usage
First of all goto your project folder by using the as usual command like..
cd (path of the project) //Remove the braces after cd

Now use those two plugins to remove it completely as follows..

*

*Cocoapods-Deintegrate Plugin
Use this following command on your terminal to deintegrate the pods from your project first.
 pod deintegrate

*Cocoapods-Clean Plugin
After deintegration of pod from your project use this following command on your terminal to clean it completely.
 pod clean

After completing the above tasks there should be the Podfile still remaining on your project directory..Just delete that manually or use this following command on the terminal..
 rm Podfile

Thats it...Now you have your project free from pods...Cleaned.
Removing Cocoapods from the system.
Any way try to use the following command on your terminal to uninstall/remove the coca-pods from your system.
sudo gem uninstall cocoapods

It will remove the coca-pods automatically.
Thanks.
Hope this helped.

A: I think there's a more easy way to do that.
As edited by the accepted answer, now you can use a third party plugin cocoapods-deintegrate, it's reliable because its made by a CocoaPods core team member.
But,there're still some files remain:
Podfile
Podfile.lock
Workspace

You could remove them from your project manually,but there's also another tool for helping you to clean them, thanks cocoapods-clean.
Finally, the uninstallation work is still not completed, cocoapods-clean don't clean the Podfile, just run:
rm Podfile

Cheers!
Before removing you should ensure you have a backup of your project!

A:
pod deintegrate

After this cmd, no traces of Cocoapods left in your project.
But your workspace referencing the Pods project still remains, you need to  should remove below 3 files manually:
xx.xcworkspace
Podifle
Podfile.lock
Then you can use your project again.
Have fun!
Test CocoaPod version = 1.2.0

A: pod deintegrate and pod clean are two designated commands to remove CocoaPod from your project/repo.
Here is the complete set of commands:
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod cache clean --all
$ rm Podfile

The original solution was found here: https://medium.com/@icanhazedit/remove-uninstall-deintegrate-cocoapods-from-your-xcode-ios-project-c4621cee5e42#.wd00fj2e5
CocoaPod documentation on pod deintegrate: https://guides.cocoapods.org/terminal/commands.html#pod_deintegrate

A: *

*The first thing that you will need to do is remove the Podfile, Podfile.lock, the Pods folder, and the generated workspace.

*Next, in the .xcodeproj, remove the references to the Pods.xcconfig files and the libPods.a file.

*Within the Build Phases project tab, delete the Check Pods Manifest.lock section (open), Copy Pods Resources section (bottom) and Embed Pod Resources(bottom).

*Remove Pods.framework.

The only thing you may want to do is include some of the libraries that you were using before. You can do this by simply draging whatever folders where in the pods folders into your project (I prefer to put them into my Supporting Files folder).
It worked for me.

A: $ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile

A: If not work, try
 1. clean the project.
 2. deleted derived data.
if you don't know how to delete derived data go here
How to "Delete derived data" in Xcode6?

A: How to remove the pod from your project Xcode
Open the directory of your project then run the scripts
$ pod deintegrate
$ pod clean
$ rm Podfile

Then you have to remove the .xcworkspace extension file manually
"ProjectName.xcworkspace"

or remove by script
$ rm projectname.xcworkspace

A: I tried all these answers but it still wouldn't build, eventually I tried:
pod deintegrate
pod install

which actually worked!
It's like it needs to remove all the pod scripts from your build phases and re-add them back in for it to work, at least in my case.

A: From terminal cd to move to the project folder. The below steps help to de-integrate the pod from the project
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile

Then just open the project file and remove the Pod folder if it is still on the Project Explorer with red color. Build the project... It's ready to go!!!

A: Delete all related pod files:

*

*xx.xcworkspace

*Podfile

*Podfile.lock

and in the Project Navigator:
Click on the project name (blue icon) --> Targets (*) --> Build Phases --> Remove "[CP] Check Pods manifests.lock" (click on the "x")
(*) Click on the project name, you might have to click on "Show project and target list" to see the side bar first.

A: If you just want to remove one pod and keep others you may have installed, open the podfile in your app directory and delete the one you want to remove.  Then navigate to your app directory using terminal and type:
pod update

This will remove the pod you removed from the podfile.  You will see it has been removed in the terminal:
Analyzing dependencies
Removing FirebaseUI
Removing UICircularProgressRing

Note that this method will also pull any updates to the other pods in your podfile.  You may or may not want that.

A: Keith's answer is great - I just want to point out that because Cocoapods 0.36 is starting to support Dynamic Frameworks, if you are using 'use_frameworks!' in your 'Podfile' and you wish to remove the Cocoapods, you must do this:

*

*Under Build Phases delete Embed Pods Frameworks phase.

A: Removing CocoaPods from a project is possible, but not currently automated by the CLI. First thing, if the only issue you have is not being able to use an xcworkspace you can use CocoaPods with just xcodeprojs by using the --no-integrate flag which will produce the Pods.xcodeproj but not a workspace. Then you can add this xcodeproj as a subproject to your main xcodeproj.
If you really want to remove all CocoaPods integration you need to do a few things:
NOTE editing some of these things if done incorrectly could break your main project. I strongly encourage you to check your projects into source control just in case. Also these instructions are for CocoaPods version 0.39.0, they could change with new versions.

*

*Delete the standalone files (Podfile Podfile.lock and your Pods directory)

*Delete the generated xcworkspace

*Open your xcodeproj file, delete the references to Pods.xcconfig and libPods.a (in the Frameworks group)

*Under your Build Phases delete the Copy Pods Resources, Embed Pods Frameworks and Check Pods Manifest.lock phases.

*This may seem obvious but you'll need to integrate the 3rd party libraries some other way or remove references to them from your code.

After those steps you should be set with a single xcodeproj that existed before you integrated CocoaPods. If I missed anything let me know and I will edit this.
Also we're always looking for suggestions for how to improve CocoaPods so if you have an issues please submit them in our issue tracker so we can come up with a way to fix them!
EDIT
As shown by Jack Wu in the comments there is a third party CocoaPods plugin that can automate these steps for you. It can be found here. Note that it is a third party plugin and might not always be updated when CocoaPods is. Also note that it is made by a CocoaPods core team member so that problem won't be a problem.

A: I am gonna write what iv done very briefly (to delete any CocoaPods from my project)..

*

*delete any added folder (frameworks, Pods,...)

*delete any added files (PROJECT.xcworkspace, PodFile, PodFile.lock, Pods-PROJECT.debug.xcconfig, Pods-PROJECT.release.xcconfig,...)

*just leave your original ones (PROJECT, PROJECT_Tests, PROJECT.xcodeproj)

*remove framework reference from the project on xcode

To remove the framework reference from xcode:

*

*Use the Project Navigator

*Select Project

*Select Target PROJECT

*Select Build Phases from the top options

*leave the default groups (Target Dependencies, Compile Sources, Linked Binary with Libraries, Copy Bundle Resources) and delete any other

A: *

*Remove the podfile name from .plist

*Reinstall the pod again (use this link for pod installation)

A: I don't think you need to deintegrate anymore. I was able to do it with the following command in terminal:
pod install
and it automatically removed the ones that are no longer in the podfile

A: All the answers provided are valid and correct. However, when you run pod install and modify any of the fields containing any cocoapods configuration, clean and deintegrate stop working as expected.
In my case, I had, among others FRAMEWORK_SEARCH_PATHS overwritten on the Build Settings and it gets tedious when dealing with 40 targets...

The following ruby file intends to run the cocoapods commands to "fully" clean the project and it performs some extra clean up such as Build settings and removes the "Pod" folder from the project among others. The script might also contain actions performed by "clean" or "deintegrate"
require 'xcodeproj'

### HELPERS ###
# Array extension for non-Ruby rail
class Array
    # Wraps and object into an array
    #
    # @param object [Any] The object to be wrapped
    # @return [Any] The array with the value wrapped. If the object is nil, then returns empty array
    def self.wrap(object)
        if object.nil?
            []
        elsif object.respond_to?(:to_ary)
            object.to_ary || [object]
        else
            [object]
      end
    end
end

# Performs the cocoapods clean up actions. It will install the dependencies needed.
def cocoapod_clean_actions
    ## DEINTEGRATE
    puts "** Installing Cocoapods 'DEINTEGRATE' **"
    system("sudo gem install cocoapods-deintegrate")

    puts "** Performing Cocoapods 'DEINTEGRATE' **"
    system("pod deintegrate")

    ## CLEAN
    puts "** Installing Cocoapods 'CLEAN' **"
    system("sudo gem install cocoapods-deintegrate")

    puts "** Performing Cocoapods 'CLEAN' **"
    system("pod clean")
end

# Performs a clean up on the build settings removing all the identified pods leftovers
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def clean_build_settings(project)
    puts "** Removing Cocoapods references from 'BUILD SETTING' **"
    podsOcurrence = "PODS"

    project.targets.each { |target|
        target.build_configurations.each { |build_configuration|
            puts "Inspecting BUILD_SETTINGS for TARGET => #{target.name} & CONFIGURATION => #{build_configuration.name}"
            build_settings = build_configuration.build_settings
            build_settings.each { |key, value|
                if key.include?(podsOcurrence)
                    build_settings.delete(key)
                else
                    clean(build_settings, key, podsOcurrence)
                end
            }
        }
    }
    project.save()
end

# Performs a clean-up on a specific key of the build settings by removing the occurrences given. It also cleans the value if empty.
#
# @param build_settings [Hash] Build Settings for a specific target and configuration
# @param flag [String] Key to find in the build_settings
# @param occurence [String] The occurence to be removed from the value of build settings key
def clean(build_settings, flag, occurence)
    puts "CLEAN => flag = #{flag}, ocurrence = #{occurence}"
    indexes = Array.new()
    build_settings_flag = Array.wrap(build_settings[flag])
    build_settings_flag.each_with_index { |value, index|
    if value.include?(occurence)
        previous_index = index - 1
            if previous_index >= 0 && build_settings_flag[previous_index].to_s&.start_with?("-")
                indexes.append(previous_index)
            end
            indexes.append(index)
        end
    }

    if indexes.count > 0
        build_settings_flag.delete_if.with_index { |_, index|
            indexes.include? index
        }

        # Replace the value for the build setting
        if build_settings_flag.empty?
            puts "Removing empty array #{flag}"
            build_settings.delete(flag)
        else
            puts "Reassining array #{flag}"
            build_settings[flag] = build_settings_flag
        end
    end
end

# Performs a clean up on the build settings removing all the identified pods leftovers
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def clean_build_phases(project)
    puts "** Removing Cocoapods references from 'BUILD_PHASES' **"
    project.targets.each { |target|
        #if target.name == "WhiteLabel" #TESTING
            puts "Inspecting BUILD_PHASES for TARGET => #{target.name}"
            target.shell_script_build_phases.each { |shell_script|
                if shell_script.name.include?("[CP]")
                    puts "Removing '#{shell_script.name}' shell script"
                    shell_script.remove_from_project()
                elsif shell_script.name == "Crashlytics Run Script"
                    puts "Deleting '#{shell_script.name}'"
                    # Add extra build phases such as the Crashlytics
                    #shell_script.remove_from_project()
                end
            }
            #break #TESTING
        #end #TESTING
    }
    project.save()
end

# Removes all the unwanted cocoapods files and folders from the project
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def remove_files_and_folders(project)
    puts "** Removing Cocoapods files and folders from project **"

    ## Project
    # BE CAREFUL WITH GROUP(LINK) NAME AND GROUP PATH(FOLDER)
    project.groups.find{ |group| group.path == "Pods" }&.remove_from_project()
    project.save()

    # File system
    system('rm -rf Pods')
    #system('rm Podfile')
end

### MAIN ###
puts "********** Cocoapods CLEAN UP **********"
cocoapod_clean_actions()

puts "********** Cocoapods EXTRA CLEAN UP **********"
project = Xcodeproj::Project.open "./WhiteLabel.xcodeproj"

clean_build_settings(project)
clean_build_phases(project)
remove_files_and_folders(project)

project.save()

And it can be called
ruby PodExtraClean.rb

A: Use these Terminal's commands (Don't forget to use sudo at the beginning of new lines):
open:YourDir YouName$ sudo gem uninstall cocoapods
Password:?
Remove executables:
    pod, sandbox-pod

in addition to the gem? [Yn]  Y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.4.0
open:YourDir YourName$ gem list --local | grep cocoapods
cocoapods-core (1.4.0)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.1.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
cocoapods-try (1.1.0)

Uninstall the list one by one like this:
open:YourDir YourName$ sudo gem uninstall cocoapods-core
Successfully uninstalled cocoapods-core-1.4.0
open:YourDir YourName$ sudo gem uninstall cocoapods-trunk
Successfully uninstalled cocoapods-trunk-1.3.0
open:YourDir YourName$ sudo gem uninstall cocoapods-try
Successfully uninstalled cocoapods-try-1.1.0
open:YourDir YourName$ gem list --local | grep cocoapods
open:YourDir YourName$ sudo gem uninstall cocoapods-stats
Successfully uninstalled cocoapods-stats-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-search
Successfully uninstalled cocoapods-search-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-downloader
Successfully uninstalled cocoapods-downloader-1.1.3
open:YourDir YourName$ sudo gem uninstall cocoapods-plugins
Successfully uninstalled cocoapods-plugins-1.0.0
open:YourDir YourName$ gem list --local | grep cocoapods
cocoapods-deintegrate (1.0.2)
open:YourDir YourName$ sudo gem uninstall cocoapods-deintegrate
Successfully uninstalled cocoapods-deintegrate-1.0.2
open:YourDir YourName$ sudo gem uninstall cocoapods-stats
Successfully uninstalled cocoapods-stats-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-search
Successfully uninstalled cocoapods-search-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-downloader
Successfully uninstalled cocoapods-downloader-1.1.3
open:YourDir YourName$ sudo gem uninstall cocoapods-plugins
Successfully uninstalled cocoapods-plugins-1.0.0
open:YourDir YourName$ gem list --local | grep cocoapods
cocoapods-deintegrate (1.0.2)
open:YourDir YourName$ sudo gem uninstall cocoapods-deintegrate
Successfully uninstalled cocoapods-deintegrate-1.0.2

A: I was able to remove my pods in the project using the CocoaPods app (Version 1.5.2). Afterwards I only deleted the podfile, podfile.lock and xcworkspace files in the folder.

A:
pictorial representation detailed

A: The following command work for me to delete a specific element and the install is back.
`$ pod deintegrate
$ pod cache clean --all
$ pod install`