text:
Q: Getting the System Folders in C++ I am working on a C++ project in VS 2010. I want to get the path of DESKTOP, I have write the following code which has been given in some tutorial.
 TCHAR path[MAX_PATH];
 SHGetSpecialFolderPath(0,path,CSIDL_DESKTOP,FALSE);
 printf("Path : %s",path);

but the above code just printed

Path : C

kindly make correction in the above code

A: Use _tprintf
http://msdn.microsoft.com/en-us/library/wc7014hz.aspx
When a TCHAR string is passed to a narrow-string function (such as printf), the data will be read byte-by-byte, and when it reaches the first null character ('\0'), it will be interpreted as the end of string. This is why it only prints the first character of the TCHAR string.
_tprintf looks at one TCHAR at a time, so it will keep on looking until it hits a TCHAR that is zero.

A: I think your project had a charset 'Unicode' in settings.
In this case, TCHAR was treated as wchar_t, and SHGetSpecialFolderPath was defined as SHGetSpecialFolderPathW, so, the path of 'DESKTOP' you got was in Unicode, so you have two choices to solve this problem.

*

*1.use 'printf("%S")' with a upper-case 'S' other than lower-case 's' to print your path.

*2.use 'wprintf("%s")' with a lower-case 's' other than upper-case 'S' to print your path.

That is to say, you can print opposite char(char/wchar_t) with a opposite-case 'S' or 's'.
I'm glad may be i can help you!
Oh, i forgot to explan the output.
In your code, path was wchar_t, but '%s' with a lower-case 's', your path was treated as char by 'printf'.
The wchar_t data(16 bits) in your path like this:
{L'C', L'\', L'W', L'i', L'n', L'd', L'o', L'w', L's', L'\', .../i.e./}
And the char data(also known as byte data, 8 bits) like this:
{'C', '\0', '\', '\0', 'W', '\0', 'i', '\0', .../i.e./}
It was just looks like the string "C", because "\Windows.../**/" is behind a 'null-terminal' tag '\0', and it was ignored.


text:
Q: Get view for inherited view controller from storyboard I have two classes: AViewController : UIViewController and BViewController : AViewController.
When I use AViewController.xib, I can create instance BViewController from one common xib:
BViewController *bVC = [[BViewController alloc] initWithNibName:@"AViewController" bundle:nil];
[self presentViewController:bVC animated:YES completion:NULL];

Storyboard can instantiate AViewController:
AViewController *aVC = [self.storyboard instantiateViewControllerWithIdentifier:@"AViewController"];

How can I instantiate BViewController from Storyboard with view with identifier 'AViewController'?

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to make border for circle cropped image in glide in default, the image that is cropped by glide has no border I need to have a border in the circle image.

A:
With compose
Remember to add dependencies to build.gradle:
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.0-beta02'

In your activity
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ShapeImageApplicationTheme {
                Surface(color = MaterialTheme.colors.background) {
                    RoundedCornerShapeDemo()
                }
            }
        }
    }
}

@Composable
fun RoundedCornerShapeDemo() {
    ImageResource(shape = RoundedCornerShape(10.dp))
}

@Composable
fun ImageResource(shape: Shape) {
    ConstraintLayout(modifier = Modifier.fillMaxSize()) {
        val (redBox, imageBox) = createRefs()
        Box(
            modifier = Modifier
                .size(100.dp)
                .clip(shape)
                .background(Color.Red)
                .constrainAs(redBox) {})

        val image: Painter = painterResource(id = R.drawable.ic_launcher_background)
        Image(painter = image, contentDescription = "", modifier = Modifier
            .size(90.dp)
            .clip(shape)
            .constrainAs(imageBox) {
                top.linkTo(redBox.top)
                start.linkTo(redBox.start)
                end.linkTo(redBox.end)
                bottom.linkTo(redBox.bottom)
            })
    }
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    ShapeImageApplicationTheme {
        RoundedCornerShapeDemo()
    }
}

Version 4
I made this way, RoundedCorners Class:
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;

import java.security.MessageDigest;

public class RoundedCornersTransformation implements Transformation<Bitmap> {

    public enum CornerType {
        ALL,
        TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT,
        TOP, BOTTOM, LEFT, RIGHT,
        OTHER_TOP_LEFT, OTHER_TOP_RIGHT, OTHER_BOTTOM_LEFT, OTHER_BOTTOM_RIGHT,
        DIAGONAL_FROM_TOP_LEFT, DIAGONAL_FROM_TOP_RIGHT, BORDER
    }

    private BitmapPool mBitmapPool;
    private int mRadius;
    private int mDiameter;
    private int mMargin;
    private CornerType mCornerType;
    private String mColor;
    private int mBorder;

    public RoundedCornersTransformation(Context context, int radius, int margin) {
        this(context, radius, margin, CornerType.ALL);
    }

    public RoundedCornersTransformation(Context context, int radius, int margin, String color, int border) {
        this(context, radius, margin, CornerType.BORDER);
        mColor = color;
        mBorder = border;
    }

    public RoundedCornersTransformation(BitmapPool pool, int radius, int margin) {
        this(pool, radius, margin, CornerType.ALL);
    }

    public RoundedCornersTransformation(Context context, int radius, int margin,
                                        CornerType cornerType) {
        this(Glide.get(context).getBitmapPool(), radius, margin, cornerType);
    }

    public RoundedCornersTransformation(BitmapPool pool, int radius, int margin,
                                        CornerType cornerType) {
        mBitmapPool = pool;
        mRadius = radius;
        mDiameter = mRadius * 2;
        mMargin = margin;
        mCornerType = cornerType;
    }

    @Override
    public Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth, int outHeight) {
        Bitmap source = resource.get();

        int width = source.getWidth();
        int height = source.getHeight();

        Bitmap bitmap = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
        if (bitmap == null) {
            bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        }

        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
        drawRoundRect(canvas, paint, width, height);
        return BitmapResource.obtain(bitmap, mBitmapPool);
    }

    private void drawRoundRect(Canvas canvas, Paint paint, float width, float height) {
        float right = width - mMargin;
        float bottom = height - mMargin;

        switch (mCornerType) {
            case ALL:
                canvas.drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, paint);
                break;
            case TOP_LEFT:
                drawTopLeftRoundRect(canvas, paint, right, bottom);
                break;
            case TOP_RIGHT:
                drawTopRightRoundRect(canvas, paint, right, bottom);
                break;
            case BOTTOM_LEFT:
                drawBottomLeftRoundRect(canvas, paint, right, bottom);
                break;
            case BOTTOM_RIGHT:
                drawBottomRightRoundRect(canvas, paint, right, bottom);
                break;
            case TOP:
                drawTopRoundRect(canvas, paint, right, bottom);
                break;
            case BOTTOM:
                drawBottomRoundRect(canvas, paint, right, bottom);
                break;
            case LEFT:
                drawLeftRoundRect(canvas, paint, right, bottom);
                break;
            case RIGHT:
                drawRightRoundRect(canvas, paint, right, bottom);
                break;
            case OTHER_TOP_LEFT:
                drawOtherTopLeftRoundRect(canvas, paint, right, bottom);
                break;
            case OTHER_TOP_RIGHT:
                drawOtherTopRightRoundRect(canvas, paint, right, bottom);
                break;
            case OTHER_BOTTOM_LEFT:
                drawOtherBottomLeftRoundRect(canvas, paint, right, bottom);
                break;
            case OTHER_BOTTOM_RIGHT:
                drawOtherBottomRightRoundRect(canvas, paint, right, bottom);
                break;
            case DIAGONAL_FROM_TOP_LEFT:
                drawDiagonalFromTopLeftRoundRect(canvas, paint, right, bottom);
                break;
            case DIAGONAL_FROM_TOP_RIGHT:
                drawDiagonalFromTopRightRoundRect(canvas, paint, right, bottom);
                break;
            case BORDER:
                drawBorder(canvas, paint, right, bottom);
                break;
            default:
                canvas.drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, paint);
                break;
        }
    }

    private void drawTopLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter),
                mRadius, mRadius, paint);
        canvas.drawRect(new RectF(mMargin, mMargin + mRadius, mMargin + mRadius, bottom), paint);
        canvas.drawRect(new RectF(mMargin + mRadius, mMargin, right, bottom), paint);
    }

    private void drawTopRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(right - mDiameter, mMargin, right, mMargin + mDiameter), mRadius,
                mRadius, paint);
        canvas.drawRect(new RectF(mMargin, mMargin, right - mRadius, bottom), paint);
        canvas.drawRect(new RectF(right - mRadius, mMargin + mRadius, right, bottom), paint);
    }

    private void drawBottomLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, bottom - mDiameter, mMargin + mDiameter, bottom),
                mRadius, mRadius, paint);
        canvas.drawRect(new RectF(mMargin, mMargin, mMargin + mDiameter, bottom - mRadius), paint);
        canvas.drawRect(new RectF(mMargin + mRadius, mMargin, right, bottom), paint);
    }

    private void drawBottomRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(right - mDiameter, bottom - mDiameter, right, bottom), mRadius,
                mRadius, paint);
        canvas.drawRect(new RectF(mMargin, mMargin, right - mRadius, bottom), paint);
        canvas.drawRect(new RectF(right - mRadius, mMargin, right, bottom - mRadius), paint);
    }

    private void drawTopRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, right, mMargin + mDiameter), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin, mMargin + mRadius, right, bottom), paint);
    }

    private void drawBottomRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, bottom - mDiameter, right, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin, mMargin, right, bottom - mRadius), paint);
    }

    private void drawLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin + mRadius, mMargin, right, bottom), paint);
    }

    private void drawRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(right - mDiameter, mMargin, right, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin, mMargin, right - mRadius, bottom), paint);
    }

    private void drawOtherTopLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, bottom - mDiameter, right, bottom), mRadius, mRadius,
                paint);
        canvas.drawRoundRect(new RectF(right - mDiameter, mMargin, right, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin, mMargin, right - mRadius, bottom - mRadius), paint);
    }

    private void drawOtherTopRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, bottom), mRadius, mRadius,
                paint);
        canvas.drawRoundRect(new RectF(mMargin, bottom - mDiameter, right, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin + mRadius, mMargin, right, bottom - mRadius), paint);
    }

    private void drawOtherBottomLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, right, mMargin + mDiameter), mRadius, mRadius,
                paint);
        canvas.drawRoundRect(new RectF(right - mDiameter, mMargin, right, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin, mMargin + mRadius, right - mRadius, bottom), paint);
    }

    private void drawOtherBottomRightRoundRect(Canvas canvas, Paint paint, float right,
                                               float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, right, mMargin + mDiameter), mRadius, mRadius,
                paint);
        canvas.drawRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, bottom), mRadius, mRadius,
                paint);
        canvas.drawRect(new RectF(mMargin + mRadius, mMargin + mRadius, right, bottom), paint);
    }

    private void drawDiagonalFromTopLeftRoundRect(Canvas canvas, Paint paint, float right,
                                                  float bottom) {
        canvas.drawRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter),
                mRadius, mRadius, paint);
        canvas.drawRoundRect(new RectF(right - mDiameter, bottom - mDiameter, right, bottom), mRadius,
                mRadius, paint);
        canvas.drawRect(new RectF(mMargin, mMargin + mRadius, right - mDiameter, bottom), paint);
        canvas.drawRect(new RectF(mMargin + mDiameter, mMargin, right, bottom - mRadius), paint);
    }

    private void drawDiagonalFromTopRightRoundRect(Canvas canvas, Paint paint, float right,
                                                   float bottom) {
        canvas.drawRoundRect(new RectF(right - mDiameter, mMargin, right, mMargin + mDiameter), mRadius,
                mRadius, paint);
        canvas.drawRoundRect(new RectF(mMargin, bottom - mDiameter, mMargin + mDiameter, bottom),
                mRadius, mRadius, paint);
        canvas.drawRect(new RectF(mMargin, mMargin, right - mRadius, bottom - mRadius), paint);
        canvas.drawRect(new RectF(mMargin + mRadius, mMargin + mRadius, right, bottom), paint);
    }

    private void drawBorder(Canvas canvas, Paint paint, float right,
                            float bottom) {

        // stroke
        Paint strokePaint = new Paint();
        strokePaint.setStyle(Paint.Style.STROKE);
        if (mColor != null) {
            strokePaint.setColor(Color.parseColor(mColor));
        } else {
            strokePaint.setColor(Color.BLACK);
        }
        strokePaint.setStrokeWidth(mBorder);

        canvas.drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, paint);

        // stroke
        canvas.drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, strokePaint);
    }

    @Override
    public void updateDiskCacheKey(MessageDigest messageDigest) {

    }

    public String getId() {
        return "RoundedTransformation(radius=" + mRadius + ", margin=" + mMargin + ", diameter="
                + mDiameter + ", cornerType=" + mCornerType.name() + ")";
    }
}

Now in your Activity, you have to put this:
public static int sCorner = 15;
public static int sMargin = 2;
public static int sBorder = 10;
public static String sColor = "#7D9067";

    ...

    ImageView imageView = (ImageView) findViewById(R.id.activity_main_image_view);

    ImageView mImageViewBorder = (ImageView) findViewById(R.id.activity_main_image_view_border);

     ....
            // Rounded corners
        Glide.with(this).load("http://scareface.jpeg")
        .apply(RequestOptions.bitmapTransform(
        new RoundedCornersTransformation(this, sCorner, sMargin))).into(mImageView);

        // Rounded corners with border
        Glide.with(this).load("http://scareface.jpeg")
        .apply(RequestOptions.bitmapTransform(
        new RoundedCornersTransformation(this, sCorner, sMargin, sColor, sBorder))).into(mImageViewBorder);

You can check my example in github.
Also you can check this post and this library for Version 3.

A: Based on @wadali's answer to making it work for Glide 4.x and Kotlin programming language. I also optimized the code a little bit, so it is cleaner, you can change the color directly and also leveraging the Kotlin extension function. It's not rounded corner like the accepted answer but fully circle like the sample image below.

Add this code to your project
import android.graphics.*
import android.widget.ImageView
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.BitmapImageViewTarget

/**
 * Load model into ImageView as a circle image with borderSize (optional) using Glide
 *
 * @param model - Any object supported by Glide (Uri, File, Bitmap, String, resource id as Int, ByteArray, and Drawable)
 * @param borderSize - The border size in pixel
 * @param borderColor - The border color
 */
fun <T> ImageView.loadCircularImage(
    model: T,
    borderSize: Float = 0F,
    borderColor: Int = Color.WHITE
) {
    Glide.with(context)
        .asBitmap()
        .load(model)
        .apply(RequestOptions.circleCropTransform())
        .into(object : BitmapImageViewTarget(this) {
            override fun setResource(resource: Bitmap?) {
                setImageDrawable(
                    resource?.run {
                        RoundedBitmapDrawableFactory.create(
                            resources,
                            if (borderSize > 0) {
                                createBitmapWithBorder(borderSize, borderColor)
                            } else {
                                this
                            }
                        ).apply {
                            isCircular = true
                        }
                    }
                )
            }
        })
}

/**
 * Create a new bordered bitmap with the specified borderSize and borderColor
 *
 * @param borderSize - The border size in pixel
 * @param borderColor - The border color
 * @return A new bordered bitmap with the specified borderSize and borderColor
 */
private fun Bitmap.createBitmapWithBorder(borderSize: Float, borderColor: Int): Bitmap {
    val borderOffset = (borderSize * 2).toInt()
    val halfWidth = width / 2
    val halfHeight = height / 2
    val circleRadius = Math.min(halfWidth, halfHeight).toFloat()
    val newBitmap = Bitmap.createBitmap(
        width + borderOffset,
        height + borderOffset,
        Bitmap.Config.ARGB_8888
    )

    // Center coordinates of the image
    val centerX = halfWidth + borderSize
    val centerY = halfHeight + borderSize

    val paint = Paint()
    val canvas = Canvas(newBitmap).apply {
        // Set transparent initial area
        drawARGB(0, 0, 0, 0)
    }

    // Draw the transparent initial area
    paint.isAntiAlias = true
    paint.style = Paint.Style.FILL
    canvas.drawCircle(centerX, centerY, circleRadius, paint)

    // Draw the image
    paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
    canvas.drawBitmap(this, borderSize, borderSize, paint)

    // Draw the createBitmapWithBorder
    paint.xfermode = null
    paint.style = Paint.Style.STROKE
    paint.color = borderColor
    paint.strokeWidth = borderSize
    canvas.drawCircle(centerX, centerY, circleRadius, paint)
    return newBitmap
}

And use it
yourImageView.loadCircularImage(
        imageUrl, // or any object supported by Glide
        borderSizeInPx, // default is 0. If you don't change it, then the image will have no border
        Color.RED // optional, default is white
)

A: Drawable for Circle border of ImageView circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid android:color="@android:color/transparent" />
    <stroke
        android:width="@dimen/et_thick"
        android:color="@color/profile_pic_round" />

    <corners android:radius="@dimen/default_corner_radius" />

</shape>

and layout will be like this
Make sure your ImageView height and width lower then RelativeLayout height and width
<RelativeLayout
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:background="@drawable/circle">// set circle drawable here

    <ImageView
        android:id="@+id/profile_pic"
        android:layout_width="145dp"
        android:layout_height="145dp"
        android:layout_centerInParent="true" />
</RelativeLayout>

and set Image with circuler programetically like this
Glide.with(mContext)
            .load(imagePath)//<= path of image
            .bitmapTransform(new CropCircleTransform(mContext))//<= For Circuler image
            .into(ivProfileImage);//<= your Imageview

A: It's easy with an outer layout:
your_layout.xml
<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:background="@drawable/round_border_style">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"/>

    </RelativeLayout>

res/drawable/round_border_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape>
        <gradient android:angle="0" android:endColor="@color/white" android:startColor="@color/white" android:centerColor="@color/white" android:gradientRadius="10sp" />
        <corners android:radius="5dp" />
            <stroke android:width="2dp"
                android:color="@color/gray"/>
        </shape>
    </item>

</selector>

Controller.java
GlideApp.with(context).load(url).fitCenter().into(imageView);

A: Good way to do this thing without using any outer layout
public static <T> void circleImage(final ImageView imageView, T uri, final boolean border) {
    Glide.with(imageView.getContext()).load(uri).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(imageView.getContext().getResources(), border ? addWhiteBorder(resource, imageView.getContext()) : resource);
            circularBitmapDrawable.setCircular(true);
            imageView.setImageDrawable(circularBitmapDrawable);
        }
    });
}

For Adding border with bitmap
private static Bitmap addBorder(Bitmap resource, Context context) {
    int w = resource.getWidth();
    int h = resource.getHeight();
    int radius = Math.min(h / 2, w / 2);
    Bitmap output = Bitmap.createBitmap(w + 8, h + 8, Bitmap.Config.ARGB_8888);
    Paint p = new Paint();
    p.setAntiAlias(true);
    Canvas c = new Canvas(output);
    c.drawARGB(0, 0, 0, 0);
    p.setStyle(Paint.Style.FILL);
    c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
    p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    c.drawBitmap(resource, 4, 4, p);
    p.setXfermode(null);
    p.setStyle(Paint.Style.STROKE);
    p.setColor(ContextCompat.getColor(context, R.color.colorPrimary));
    p.setStrokeWidth(3);
    c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
    return output;
}


text:
Q: Wait async function to finish from console Main() How I can wait in Main until RunScrapper() function finish in my console application?
    static void Main(string[] args)
    {
        RunScrapper();
    }

    static async void RunScrapper()
    {
        // Download the Chromium revision if it does not already exist
        await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision);

        // Create an instance of the browser and configure launch options
        Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions
        {
            Headless = false
        });

        // Create a new page and go to Bing Maps
        Page page = await browser.NewPageAsync();
        await page.GoToAsync("https://www.google.es");
    }

If I put await RunScrapper(); it says that Main() should be async and RunScrapper() should return a Task.
The problem is that the program runs and nothing happens because the program closes before RunScrapper() makes anything.

A: You can change your Main method to be Async.
public static async Task Main(string[] args)
{
       await DoStuffAsync();
}

public static async Task DoStuffAsync(){
       ...
}


text:
Q: Pedro's barn and how to find constant "In Pedro's barn, the number of mice is inversely proportional to the number of cats. When he owned 5 cats, there were 48 mice in the barn. He increased the number of cats to 8. Based on the increased number of cats, how many mice are in the barn? Assuming that the relationship between the number of nice and the number of cats does not change, write an equation that Pedro could to to determine the number of mice (m), for any number if cats (c)."

I know what inversely proportional means. I know that in this case, as the number of cats increases, the number of mice decreases. I also know that the equation would be: m=k/c, k=constant. I need to know how to find the constant, and the steps leading up to it. Thanks.

Edit: I figured it out, thanks for your help anyway.

A: You find the constant by substituting the known values into the equation $m=\dfrac{k}{c}$:
$$48=\dfrac{k}{5}\implies k=240.$$

A: We have that
$$5=\frac k{48} \implies k= 240$$
and
$$m=\frac{240}c$$
with $c=8$. The result is then $m=30$.


text:
Q: how to make a graph fit with layout on android i'm very new to Android and AChartengine and i'm working in my project.
Assume i have a Layout like this:
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<LinearLayout
     android:id="@+id/displayECG"
     android:layout_width="fill_parent"
     android:layout_height="100px"
    android:orientation="horizontal" >

</LinearLayout>

And in MainActivity.java i code like:
view = ChartFactory.getLineChartView(this, dataSet, renderer);
LinearLayout layout = (LinearLayout) findViewById(R.id.displayECG);
layout.addView(view, new LayoutParams(LayoutParams.MATCH_PARENT,    LayoutParams.MATCH_PARENT));

But when i run my App and i got a graph, it very smaller than layout space. I want a graph, it fits with my layout, so how can i do that?
Thanks,

A: I am not familiar with the ChartFactory.
But from the layout perspective your giving a hight of 100px to the nested LinearLayout, try using wrap_content instead.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   tools:context=".MainActivity" >

   <LinearLayout
      android:id="@+id/displayECG"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" >

   </LinearLayout>

Also, try calling invalidate on the layout after you add the child view for it to redraw itself:
view = ChartFactory.getLineChartView(this, dataSet, renderer);
LinearLayout layout = (LinearLayout) findViewById(R.id.displayECG);
layout.addView(view, new LayoutParams(LayoutParams.MATCH_PARENT,   LayoutParams.MATCH_PARENT));
layout.invalidate();

A: Your chart is actually filling up the whole layout, but by default AChartEngine has a lot of extras turned on. I would suggest adding the following lines prior to creating the chart:
renderer.setLegendHeight(1);
renderer.setZoomButtonsVisible(false);
renderer.setMargins(new int[] {0, 0, 0, 0});

There may be a couple other things you need, but this should at least get you started. Also, your displayECG is only 100 px tall. That may be limiting as well.


text:
Q: Link maven dependencies on non maven project I have two projects in Eclipse, the first project depends on maven, the second project which dependent on the first one does NOT depend on maven.
The first project downloads external libraries like jar files and natives to the .m2 maven folder. However the second project gives a ClassNotFoundException since it cant find the jar files and the native files from the first project.
Is it possible to link these downloaded jars+dlls with the second project without having to reference in the build path->libraries in the second project properties?
I would appreciate any help.

A: In your Maven  project, use Assembly  plugin to create  an   Uber-jar  that  contains the  project  build  artifact and all  its dependencies (mvn assembly:assembly -DdescriptorId=jar-with-dependencies).  Then,  reference that  from  project #2,  either with a  relative path or  by  using an ant build  task to  copy it into your other  project's lib  directory (assuming you have such a  directory).    Also, although  it's  frowned  upon,  you  could  configure the  assembly  plugin so that  your  Uber  jar  artifact always has the  same    finalName.

A:
Is it possible to link these downloaded jars+dlls with the second project without having to reference in the build path->libraries in the second project properties?

I don't think so.
But maybe you could create a 3rd project (which is a Maven project) that depends on the first one, and on the JAR (or whatever) file created by the 2nd one as a non-repository dependency.
Having said that, anything you do is going to be a bit of a hack.  You'd be better of either turning the 2nd project into a proper Maven project, or creating a custom build script that manually pulls the 2nd project's dependencies from somewhere.  (I think that Ivy could help you with that ... assuming you use Ant in the 2nd project.)


text:
Q: End Process vs End Process Tree What is the primary difference between the two? I always see this in the right click menu in windows. What happens if you end a process that is relied upon by another process? Is there a way to "kill" a process tree in linux or is the technology different?

A: When you start a process, many of them can be used to either call additional instances or separate processes.

These are called child processes, additionally each child can then call child processes (Making the original process a grandparent, and each of these new processes as grand child processes).
If you kill the parent process, it should also kill the children / grandchildren in the tree.
It is possible to call processes and not be officially in the tree though. This is a rough concept.
Also, Linux can kill trees but it is generally not as straight forward as right clicking a process in the activity monitor.


text:
Q: Headers already sent in a simple php script I'm having issues with my simple PHP script. I want if $_SESSION['username'] is set to redirect to welcome.php, if not, it goes to /login.php
I thought it would be easy but i seem to have some issues.
INDEX.php
<?php
session_start();
if(isset($_SESSION['username']))
{
  header("Location","/welcome.php");
}
else
{
  header("Location","/login.php");
}
?>

A: Add exit after you redirect to page whenever you do it with condition. Also write header function as below
<?php
session_start();
if(isset($_SESSION['username']))
{
  header("Location: /welcome.php");
  exit();
}
else
{
  header("Location: /login.php");
  exit();
}
?>


text:
Q: Replace files with symlink This question is intended to be the inverse of Replace Symbolic Links with Files, but for windows.
I have started running out of space on my SSD drive, and I found that about 12% of used space is in my installer folder (holds the .msi files for all the programs that I have installed)
I am looking for two things:

*

*A way to move this (or any) folder via symlink. Ideally, some powershell function that I could use to  just designate a folder, a destination, and the symlink would be created in the original (pointing to the destination)

*In this particular case, a registry change that would allow the location to be move would also be helpful, but I would still prefer solution 1.

Update: The solution must work when the folder cannot be copied wholesale, and just move the files that can be copied (and create symlinks for those files)
How can this be done?

A: There is no easy way to move/replace as you're requesting, but doing the task manually is just as easy.
Just do the following:

*

*Open an explorer window

*Navigate to the folder you want to move

*Move the folder to a new location (in my example I'll use C:\My Data\Installer to D:\My Data\Installer)

*Press Start

*Type cmd

*Press ctrl+shift+enter to open the command prompt with elevated permissions (as administrator)

*Use the command CD to navigate to your folder, for example:

.
C:\Users\John Doe>cd\

C:\>cd "My Data"

C:\My Data>

Now type the following command:
mklink /j Installer "D:\My Data\Installer"

A directory junction has now been made, and your installers can be accessed from both C:\My Data\Installer and D:\My Data\Installer, but the files only resides in D:\My Data\Installer
It is possible to create a batch script that will do the above steps, but given that it will take a bit of time to make it perfectly, and you likely will do it maybe 2 times, it is easier to just do it manually.


text:
Q: C++, putting vector data into a .csv file I'm working on something simple, and i want it to be able to take everything within a vector and put it into a .CSV file, where every row would be a new vector and the columns being each position within the vector.
This is my current code, however whenever I open the CSV file it is completely empty.
Any help would be greatly appreciated!
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
    ofstream myfile;
    myfile.open("test.csv");

    vector<int> arrayOne = { 10, 20, 30, 40, 50 };

    for (int i = 0; i < arrayOne.size(); i++)
    {
        myfile << arrayOne.at(i) << ",";
    }

    cin.ignore();
    cin.ignore();
    return 0;
}

A: As the marked answer is totally correct in the function it demands from OP, but is derivatives in the code drastically. Which can result in an undebugable code or alter the behavior OP intended. pls consider this code:
#include <iostream>
#include <fstream>
#include <vector>

// removed "using namespace std"

int main()
{
    std::ofstream myfile; // added "std::"
    myfile.open("test.csv");

    std::vector<int> arrayOne { 10, 20, 30, 40, 50 };

    for (int i = 0; i < arrayOne.size(); i++) { // added "{"
        myfile << arrayOne.at(i) << ",";
    } // added "{"

    myfile.close(); // <- note this correction!!
    std::cin.ignore(); // added this
    std::cin.ignore(); // added this
    return 0;
}

*

*consider not using using namespace std. This namespace includes hundreds of thousand of functions. you may collide with one of them and this is a pain to debug.

*The marked answer removes the parentheses {} at the for-loop. NEVER do that, you may run into undebugable problems, when you add one line to your for-loop. This line is no executed in the loop.

*The answer also remove vital code from the OP twice: std::cin.ignore();

A: Close your file like this:
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
    ofstream myfile;
    myfile.open("test.csv");

    vector<int> arrayOne = { 10, 20, 30, 40, 50 };

    for (int i = 0; i < arrayOne.size(); i++)
        myfile << arrayOne.at(i) << ",";

    myfile.close();
    return 0;
}

The point here is, output streams are often buffered. When you close the file, close() function ensures, any pending output sequence is written to the file.


text:
Q: Unit test for request retry function I have a request retry function that sends post requests 3 times per session and if the post request does not give the response back after 3 attempts then it will raise an error. The function is as follows:
def request_retry_session():

     session = requests.Session()
     retry = Retry(total=3, backoff_factor=0.1,
     method_whitelist=frozenset(['POST']))
     adapter = HTTPAdapter(max_retries=retry)
     session.mount('http://', adapter)
     try:
            response = session.post(
                url=url,
                data=json.dumps(data),
                headers={"Content-Type": "application/json"},
                verify=False,
            )
            response_data = response.json()
            logger.info(f"{ref}processing time cost for {api_name}: {time_cost}s")
      except Exception as e:
            raise e

I would like to write unit test for this function. I would appreciate it if you have any advice.


text:
Q: Write units like micro gram (µg) in LaTeX How can I add a microgram mark in LaTeX?
Because I want to add microgram in my work as a description of a specific unit.

A: As @Juan Castaño noted in a comment, it's perhaps best to use the siunitx package for this sort of thing. You could of course use $\mu$, but I'm not sure if that's good typographic practice (likely not).
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\verb+\mu+: 100 $\mu$g

\verb+siunitx+: \SI{100}{\micro\gram}
\end{document}

EDIT: well, looks like @Mico beat me to answering. ;)

A: The siunitx package provides two macros that address your typesetting needs: \si and \SI.

*

*\si lets you typeset scientific units in ways that satisfy basic SI typographic formatting conventions, and

*\SI lets you typeset numbers and their associated scientific units.
For more information on how scientific units should be typeset according to the Système Inernational (SI) conventions, please see the NIST's SI Unit rules and style conventions.

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\si{\micro\gram}, \SI{1.23}{\milli\gram}
\end{document}

Addendum to pick up on @leandriis's follow-up comment: The siunitx package provides the abbreviations \fg, \pg, \ng, \ug, \mg, \g and \kg for -- you guessed it -- femtogram, picogram, nanogram, microgram, milligram, gram, and kilogram. See the multi-page Table 21 of package's user guide for the full details.


text:
Q: Linear independence question 5 ($a_1,a_2,...a_n$) is a list of linearly independent vectors contained in the vector space $U$
$a_{n+1}$ is not an element of the span of the list ($a_1,a_2,...a_n$)
prove that the list ($a_1,a_2,...a_n,a_{n+1}$) is linearly independent

A: Hint:
let $$\sum_{i=1}^{n+1} c_i a_i=0$$
Your goal is to show that all the $c_i$ must be $0$.
Consider $2$ cases:
Case $1$: if $c_{n+1}=0$.
Case $2$: if $c_{n+1} \neq 0$, express $a_{n+1}$ as a linear combination of the rest. Try to look for a contradiction.

A: Seeking a contradiction, suppose $\{a_1,\dotsc,a_n,a_{n+1}\}$ is linearly dependent, so the equation
$$
\lambda_1\cdot a_1+\dotsb+\lambda_n\cdot a_n+\lambda_{n+1}\cdot a_{n+1}=\mathbf 0\tag{1}
$$
has a solution where $\lambda_k\neq0$ for some $k$. Note that $\lambda_{n+1}=0$ implies that $\lambda_i=0$ for each $i$ since $\{a_1,\dotsc,a_n\}$ is linearly independent. Thus $a_{n+1}\neq0$. Put $\mu_i=-\lambda_i/\lambda_{n+1}$. Then dividing (1) by $\lambda_{n+1}$ and solving for $a_{n+1}$ gives
$$
\mu_1\cdot a_1+\dotsb+\mu_n\cdot a_n=a_{n+1}
$$
a contradiction since $a_{n+1}\not\in\DeclareMathOperator{Span}{Span}\{a_1,\dotsc,a_n\}$. Hence $\{a_1,\dotsc,a_n,a_{n+1}\}$ is linearly independent.


text:
Q: Does the HTML  tag have to be in the head? Looking through this guide on using the HTML <base> tag, it says:

If used, the base element must be placed inside the head element and it should only be used once.

However, I've used <base> in places that were NOT the head, and it appeared to work without a problem.  Is this more a style guideline, or is there something I'm missing?

A: It does seem to be part of the 'metadata' family, which should always reside in the <head>

Contexts in which this element can be used:
      In a head element containing no other base elements.

Here's some official documentation regarding the <base> element:
https://www.w3.org/wiki/HTML/Elements/base

A:
When present, the BASE element must appear in the HEAD section of an HTML document, before any element that refers to an external source.

From the HTML4 specification. Similarly worded in the specs of HTML5
It may be that browsers don't ignore <base> placed somewhere else in a page. It is quite common that browser are tolerant to possible deviations from specifications

A: Always check the current documentation, read the spec

Contexts in which this element can be used: In a head element
  containing no other base elements.

Browsers are required to do the best they can with invalid markup, such as placing this outside the head element. That's why you can get it to work but it would still be invalid. You should never rely on invalid markup working at all or from one browser to the next.

A: TL;DR—Concerning specification, base elements must be placed in context of a head element.

Both WHATWG Living Standard and the W3C Recommendation for HTML5 state:

Contexts in which this element can be used:In a head element containing no other base elements.

As a document metadata, it makes sense to have it in the head of the document. Regardless of specification however, browsers will "auto-correct" misplaced elements anywhere and evaluate them. Since it's not particularly clean work and might constitute a source of errors, one should adhere to the specification.


text:
Q: Visual Studio - Entity Framework ¿Alguien sabe por qué no puedo cambiar la opción de proveedor heredado?
Requiero ponerla en true, como el proyecto de la derecha y me aparece bloqueado.
De antemano muchas gracias.

A: Empieza con un modelo vacío y debería haber una propiedad llamada "Estrategia de generación de código" o algo así (no estoy seguro yo tengo VS en inglés).

Cambia la propiedad a la otra opción, la que no sea "T4".  La propiedad "Usar proveedor heredado" (Use Legacy Provider) debería cambiar a True


text:
Q: Django - Conflicting models in application, same path but different case Django 1.8.
I'm getting this error:
Traceback (most recent call last):
[35mrentapp    | [0m  File "/home/rentapplication/django-rentapplication/manage.py", line 10, in <module>
[35mrentapp    | [0m    execute_from_command_line(sys.argv)
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
[35mrentapp    | [0m    utility.execute()
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 312, in execute
[35mrentapp    | [0m    django.setup()
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[35mrentapp    | [0m    apps.populate(settings.INSTALLED_APPS)
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
[35mrentapp    | [0m    app_config.import_models(all_models)
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models
[35mrentapp    | [0m    self.models_module = import_module(models_module_name)
[35mrentapp    | [0m  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[35mrentapp    | [0m    __import__(name)
[35mrentapp    | [0m  File "/home/rentapplication/django-rentapplication/accounts/models/__init__.py", line 3, in <module>
[35mrentapp    | [0m    from .landlord import Landlord
[35mrentapp    | [0m  File "/home/rentapplication/django-rentapplication/accounts/models/landlord.py", line 20, in <module>
[35mrentapp    | [0m    from accounting.models import Account
[35mrentapp    | [0m  File "/home/rentapplication/django-rentapplication/accounting/models/__init__.py", line 2, in <module>
[35mrentapp    | [0m    from .transaction import Transaction, RequestedWithdrawal
[35mrentapp    | [0m  File "/home/rentapplication/django-rentapplication/accounting/models/transaction.py", line 16, in <module>
[35mrentapp    | [0m    class Transaction(TimeStampedModel):
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 309, in __new__
[35mrentapp    | [0m    new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
[35mrentapp    | [0m  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 221, in register_model
[35mrentapp    | [0m    (model_name, app_label, app_models[model_name], model))
[35mrentapp    | [0mRuntimeError: Conflicting 'transaction' models in application 'accounting': <class 'accounting.models.Transaction.Transaction'> and <class 'accounting.models.transaction.Transaction'>.

My structure is following:
accounting
  api
  migrations
  models
    __init__.py
    account.py
    transaction.py

In init i have following code:
from .account import Account
from .transaction import Transaction, RequestedWithdrawal

I have no idea from where django came up with upper cases transaction package, I didn't use it anywhere in my code.
So why I'm having this error, and how to solve it?
UPDATE.
account.py imports
import StringIO
import csv
import logging
from decimal import Decimal

from django.conf import settings
from django.db import models
from django.db.models import Q
from django_extensions.db.models import TimeStampedModel
from notifications import notify

logger = logging.getLogger(__name__)
from accounting.tasks import notify_of_withdrawal_request_action

landlord.py imports
import datetime
import logging
from decimal import Decimal
from collections import Counter
import random
import string
import analytics

from django.utils.timezone import utc
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.db import models, transaction
from django.contrib.auth.models import User
from django_extensions.db.models import TimeStampedModel
from easy_thumbnails.fields import ThumbnailerImageField
from jsonfield import JSONField
import stripe
from rentapplication.utils import generate_random_slug
from applications.models import ApplicationTemplate
from accounting.models import Account
from reports.models import  Report, ReportSourceProfile, ReportSource
from django.core.exceptions import ValidationError
from django.contrib.auth.tokens import default_token_generator
from django.conf import settings
import base64

transaction.py imports
import logging
from decimal import Decimal

logger = logging.getLogger(__name__)

from django.db import models
from django_fsm import FSMField, transition
from django_extensions.db.models import TimeStampedModel

from reports.models import Report

import stripe

A: I dont know why i was seeing this strange error message and stack trace. But the problem was with circular import inside models.py and tasks.py.


text:
Q: How to monitor for lack of Lambda invocation in AWS Cloudwatch We've ran into issues where lambdas don't end up running when we expect them to, whether triggered from a Cloudwatch Rule or some other source. I'd like to configure a Cloudwatch Alarm to alert me if a lambda doesn't run in an expected time period.
My first pass was to create the following alarm (for a lambda I expect to run once per day):
sum(invocations) < 1 for time period of 1 day
The problem with this is that if the lambda never gets invoked, it never generates a data point in Cloudwatch Metrics, and consequently the alarm stays in an insufficient data state.
I'm thinking I could write a separate lambda that would use boto3 to find the timestamp on the most recent logstream for the lambda in question and use some logic to determine if it's running properly or not - but this seems like a ridiculous solution.
Is there a way to implement this properly in Cloudwatch Alarms?

A: The problem is sum registers 0 as no data points. thus alarm goes to "Insufficient Data" state rather than "In Alarm" state.
As a work around, you can do the following:
1. goto "Missing data treatment" section inside Alarm, then choose:
 2. "Treat missing data as bad(breaching thresold)"
This should set the state in Alarm state, when you have 0 invocation within 24hrs.

A: Having spent around half a day looking to solve the same problem, I've come to the conclusion that it's not possible to solve this using only CloudWatch. We've had to make do with an INSUFFICIENT_DATA state to highlight a lack of invocation.


text:
Q: HTML5 Canvas animation issue I am experimenting with HTML5 Canvases in an attempt to create some animation.  My ultimate goal is to be able to animate a box to a particular location at whim, for now im just animating it across the screen.  When I move it across the screen I geta black trail left behind, how do I clear this "dirty" section without removing the background grid?
A jsFiddle of the code is here

A: Two solutions

*

*Redraw the background on the top of animation before moving it to the new location. This so called dirty sprite technique - faster - more complex.

*Redraw the whole canvas between frames
If drawing the background is a complex operation just hold a prepared background buffered in another canvas for speed.

A: You have to clear what you've drawn if you don't want it to be visible. I assume you don't want to clear entire canvas to avoid redrawing grid and spending CPU cycles. You'll have to do this differently.
Possible solutions:

*

*have two same onscreen canvases one over the other. Draw grid on canvas below and don't clear it. Clear part of top canvas and redraw on it.

*have one on-screen and one off-screen canvas. Draw grid on off-screen canvas. Each time you animate, clear whole on-screen canvas, copy prepared grid from other one, and draw what you need over it.


text:
Q: How to implement two-finger tap gesture in WP7? Is there any standard/documented ways to implement two-finger tap event in WP7?
If not, is it possible to code manually using the manipulation events?

A: No, there is no two-finger tap event for WP7. And, yes, you can build this yourself. I would recommend looking at how the gesture services handle low-level manipulation events to ouput gestures, as described in this blog.


text:
Q: OneDrive signing in with acces token at the moment i am accessing OneDrive via manually signing in with a webbrowser (WinForm). But I want to create a Service which synchronizes my data on OneDrive all x-minutes. So when i start my computer the service starts and should already be logged in. Is there any way to save access token? Because the access token expires after an hour as far is I know, and i have not found out the clue how to refreh the access token with a refresh token yet. But also if I can refresh my access token, wouldn't it be expired? I don't think that over night my refresh token will be valid to request a new access token? And  the refresh token isn't valid forever isn't it?
I hope someone is familiar with this topic and understands my question. I am really stuck here at the moment so I would be really thankful for an answer.
edit:
Ok finally understand refresh token and its behaviour/expire time.
The bigger problem still exists, how do i get an access token through refresh token?
And how do i login with access token ?


text:
Q: Angular 2 is not installing using npm While installing angular 2 it shows the following error:
npm ERR! Windows_NT 6.1.7601

npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ic020019\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "angular@2"

npm ERR! node v4.4.2

npm ERR! npm  v3.10.5

npm ERR! No compatible version found: angular@2
npm ERR! Valid install targets:
npm ERR! 1.5.8, 1.5.7, 1.5.6, 1.5.5, 1.5.3, 1.5.2, 1.5.1, 1.5.0, 1.5.0-rc.2, 1.5.0-rc.1, 1.5.0-rc.0, 1.5.0-beta.2, 1.5.0-beta.0, 1.4.12, 1.4.11, 1.4.10, 1.4.9, 1.4.8, 1.4.7, 1.4.6, 1.4.5, 1.4.4
, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.4.0-rc.2, 1.4.0-rc.1, 1.4.0-rc.0, 1.4.0-beta.6, 1.4.0-beta.5, 1.4.0-beta.4, 1.4.0-beta.3, 1.4.0-beta.2, 1.4.0-beta.1, 1.4.0-beta.0, 1.3.20, 1.3.19, 1.3.18, 1.3.1
7, 1.3.16, 1.3.15, 1.3.14, 1.3.13, 1.3.12, 1.3.11, 1.3.10, 1.3.9, 1.3.8, 1.3.7, 1.3.6, 1.3.5, 1.3.4, 1.3.4-build.3588, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.3.0-rc.5, 1.2.30, 1.2.29, 1.2.28, 1.2.27, 1.
2.23, 1.2.22, 1.2.21, 1.2.20, 1.2.19, 1.2.18, 1.2.17, 1.2.16, 1.2.15, 1.2.14, 1.2.13, 1.2.12, 1.2.11, 1.2.10, 1.2.9, 1.2.8, 1.2.7, 1.2.6, 1.2.5, 1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.5, 1.1.4,
 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.0.8, 1.0.7, 1.0.6, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.0.4, 0.0.3, 0.0.2, 0.0.1, 0.0.1-2, 0.0.1-1
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\SSP\angular 2 POC\npm-debug.log

How can I resolve this?

A: Angular 2 is in a different package than angular 1: https://www.npmjs.com/package/angular2
For example, you could install it using npm install angular2.

A: To install Angular2 you can use the command npm install angular2.  Another way of doing it is to add the package and version number to your package.json file.  For example:
...
"dependencies": {
    "angular2": "2.0.0-beta.17"`
}
...

You then need to run npm install in your project root.
However .... I wouldn't use the Angular2 npm package, because it's a little out of date now (at the time of writing, this may change after full release).  The development team has split the main areas of functionality into separate sub-packages.  To use these you will need to import them individually into your package.json file.  For Example:
...
"dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.1.1",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/platform-server": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.2"
}
...

A: Installation of the current version of Angular 2 is split up into several packages:

*

*@angular/core

*@angular/common

*@angular/platform-browser-dynamic

*@angular/platform-browser

*@angular/http

*@angular/forms

*@angular/router
Just install all of those with npm install


text:
Q: MVC 6 Change where a view block renders My goal is to create an analog to the razor @section Scripts {...} syntax that will work equally well in Views and ViewComponents.
I can do this via helper methods if I convert the JavaScript to a windows string.  However, this destroys intellisense, puts you into character escaping hell and doesn't allow you to de-dup and order the scripts just prior to rendering.
I'd like to make this work in a way that allows the Visual Studio Editor to edit the JavaScript as JavaScript.  It seems like I should be able to do something like this:

    label id="@labelId">@Model.DisplayFormat

@using (Html.BeginNamedScript($"StatDisplay{Model.UniqueId}"))
{

}

HtmlHelperExtension:
public static NamedScript BeginNamedScript(this IHtmlHelper htmlHelper, string name, params string[] dependancies)
    {
        return new NamedScript(htmlHelper.ViewContext, name, htmlHelper, dependancies);
    }

And class NamedScript:
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewFeatures;

namespace WebUIB8.Helpers
{
    public class NamedScript : IDisposable
    {
        private bool _disposed;
        private readonly FormContext _originalFormContext;
        private readonly ViewContext _viewContext;
        private readonly TextWriter _writer;
        private readonly string _name;
        private readonly HtmlHelper _helper;
        private readonly string[] _dependsOn;

        public NamedScript(ViewContext viewContext, string name, params string[] dependsOn):this(viewContext, name, null, dependsOn)
        {
        }

        internal NamedScript(ViewContext viewContext, string name, IHtmlHelper helper, params string[] dependsOn)
        {
            if (viewContext == null)
            {
                throw new ArgumentNullException(nameof(viewContext));
            }
            _name = name;
            _dependsOn = dependsOn;
            _helper = helper as HtmlHelper;
            _viewContext = viewContext;
            _writer = viewContext.Writer;
            Debug.WriteLine("Beginning:\r\n" + _viewContext);
            _originalFormContext = viewContext.FormContext;
            viewContext.FormContext = new FormContext();

            Begin();
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        public void Begin()
        {
            //No beginning action needed
        }

        private void End()
        {
            Debug.WriteLine("Ending:\r\n" + _writer);
            //NOTE: This chunk doesn't work
            //This is supposed to render the script to a string and
            // pass it to the helper method that accumulates them, orders
            // them, dedups them, and renders them at the proper location
            // in the _Layout file so JavaScript loads last, and in dependancy order.
            _helper?.AddJavaScript(_name, _writer.ToString(), _dependsOn);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                _disposed = true;
                End();

                if (_viewContext != null)
                    //NOTE: This chunk doesn't work either.
                    //This is supposed to prevent the code from rendering here.
                    _viewContext.FormContext = _originalFormContext;
            }
        }

        public void EndForm()
        {
            Dispose(true);
        }
    }
}

I've tried the below to render the script to string, but it throws an exception inside the .RenderAsync call and aborts the page with a 503.2 error:
private async Task<string> RenderView(ViewContext viewContext)
{
    using (var sw = new StringWriter())
    {
        var newViewContext = new ViewContext(viewContext, viewContext.View, viewContext.ViewData, sw);
        var razorView = newViewContext.View as RazorView;
        razorView.RenderAsync(newViewContext).Wait();
        sw.Flush();

        return sw.ToString();
    }
}

*

*Am I missing a simpler solution?  Is there an easier way to render the result of Razor markup and pass it into an html helper method?

*How can I render the ViewContext of inside the @using block into text?

*How can I prevent that ViewContext from rendering with the rest of it's view?  (So that I can render it later on the page)

A: You can implement this behavior using tag helpers.
Let's say you create a tag helper InlineScriptConcatenatorTagHelper targetting the

...

Then add a single script element in your _Layout.cshtml that will render the concatenated output of all the inline scripts with the same bundle name:
    ...

The rendered output will contain a single script element concatenating all the scripts you included in the inline bundle:
    ...

Don´t forget to register the tag helpers in your assembly by adding a @addTagHelper directive to the _ViewImports.cshtml file
EDIT
Check out the github project created by @SvdSinner. It has taken the approach described here and created a tag helper that supports deduplication and dependency ordering. (With the aim of supporting minification and provide a nuget package)


text:
Q: Copy DynamoDB table while modifying key attribute I have a DynamoDB table with hundreds of thousands of data, which I need it duplicated, with one catch that the key needs to be modified. The current key is a combination of 2 fields, e.g. attr1:attr2. I need the new table to have the key consisted only from attr1.
I know copying the table with Data pipelines is pretty straight forward, but how do I do the new key creation according to the use case I have?
Note: the data size is between 500K and 1M items.

A: Use Elastic Map Reduce in order to manipulate the data. This article explains how to handle DynamoDB data with EMR. Create a UDF which will parse and manipulate the key and use that in a comprehensive
    SELECT UDF(id), all, other, columns FROM your_table

Which will be saved in another DynamoDB table.


text:
Q: Pass WAVE PCM byte array to FFT for pitch detection I did the code up to finding the PCM Data from a audio file. How should i apply these data to the Fast Fourier Transform Algorithm? Are there more things to consider before applying the byte array to FFT algorithm.
public static void main(String[] args) throws FileNotFoundException, IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    BufferedInputStream in = new BufferedInputStream(new FileInputStream("adios.wav"));

    int read;
    byte[] buff = new byte[1024];
        while ((read = in.read(buff)) > 0)
        {
            out.write(buff, 0, read);
        }
        out.flush();
        byte[] audioBytes = out.toByteArray();

        for(int i=0; i<audioBytes.length;i++){
            System.out.println(audioBytes[i]);
        }
}

A: You need to skip the wav header and transform the PCM samples to float values between -1 and 1. For example for a byte array with PCM wav with 16 bits per sample and little endian the following conversion is needed (from com.sun.media.sound.AudioFloatConverter):
public float[] toFloatArray(byte[] in_buff, int in_offset,
  float[] out_buff, int out_offset, int out_len) {
        int ix = in_offset;
        int len = out_offset + out_len;
        for (int ox = out_offset; ox < len; ox++) {
            out_buff[ox] = ((short) ((in_buff[ix++] & 0xFF) |
                       (in_buff[ix++] << 8))) * (1.0f / 32767.0f);
        }
        return out_buff;
    }

After this call you end up with a float[] that can be used for an FFT analysis.
To make this more easy the JVM includes the AudioSystem and AudioInputStream classes.
The source code of TarsosDSP, a Java audio processing library, is full of examples. The TarosDSP manual explains the relation between PCM data and workable samples.


text:
Q: How to connect sound output to bluetooth headphones? Which codec? I'm running Kubuntu 21.10. Earlier today I had sound playing through my Bluetooth headphones. But I was also experimenting, trying to figure out how to play sound through my hearing aids (not at the same time, of course). In the course of my experiments. I changed a setting, with the result that I can no longer play sound through the headphones. pavucontrol no  longer shows Bluetooth as a possible output choice. The headphones are paired and connected. I know the problem is simple--nothing to do with configuration files or anything like that. It's  just a matter of redirecting the sound to the right place.  So how can I get the headphones working again?
Update 1: I solved the problem of the headphones not showing up in the volume control: I needed to do a cold restart.  I don't know why that was necessary, though.
But I'm still not out of the woods.  The headphones are muted, and the volume control shows that they are muted.  But clicking on the mute icon for the headphones doesn't unmute them. I don't yet know why it doesn't.
Update 2: In trying to solve the problem, I switched from pavucontrol to pipewire, since that's what all the cool kids seem to be using. I still can't unmute, but now there's another dimension of the problem.
Update 3: I think pipewire, at least in its present state, has been oversold. I don't think I'm the only one to be unable to get to work with Bluetooth headphones.  I don't need to remove it, only deactivate it so pavucontrol, which I never removed, can take over again.


text:
Q: Which TDataSet, TDbGrid events to use for implementing an Un-Do feature I'm planning to write an un-do feature for use in a TDBGrid hooked up to a TTable (BDE). I want it to work at the grid cell level.
I'd like some suggestions on a good way to implement this.
I plan to keep a list of records that changed, the field name, and their former values.
What I need, I believe, are an OnEnter and OnExit for cells.
TDataSet.BeforeEdit is half of what I need, I think. But, TDataSet.AfterEdit is a bit misnamed -- it's called not after the edit is completed, but "after the TDataSet enters the edit mode" (to quote the help system.)
TField.OnChange would work though... I think ...
My thinking is that AfterEdit will grab the contents of the cell. And TField.OnChange will log the change to a stack I keep. (Thank goodness for Delphi's Generics.  I never knew what I was missing before we had them!)
Any suggestions on how my thinking, caveats, or better ways to do this?
PS Standard mea culpa: Yes, yes: the BDE is deprecated, I shouldn't be using it, yada, yada, yada.  Tell that to my boss who has me maintaining 1.5 million lines of legacy code. Yes, yes: someday the BDE will go away and we should be proactive and make the move now. We know. Thank you.

A: *

*If to implement Undo / Redo functionality for BDE datasets, then best will be to inherit your own datasets, and there override some methods, instead of to hook events. Then replace all TQuery with TYourQuery.

*More simple is to use TClientDataSet + TDataSetProvider in the places where Undo / Redo is needed. Set TClientDataSet.LogChanges to True. To Undo editing call UndoLastChange. Sorry, you cannot Redo, although.

*Migration from BDE to some 3d party data access components may be simple and straightforward. Eg, AnyDAC has API compatible with BDE, well documented migration procedure, tool for automating migration. Also, after migration you will get (2) right out of the box.

A: As per Robert's request, my comment(s) rewritten as an asnwer.
Don't cells already support undo by typing Ctrl-Z or Esc?
Or if you want to keep a stack of edits to multiple cells and have "undo" revert them one by one then you could combine dataset and field events. The dataset OnBeforeEdit will give you the base for all cells, each field's onchange will give you its OnAfterEdit which would render the same value as an (imaginary) Field.OnBeforeEdit when the user comes back to edit the same cell again.


text:
Q: Getting data from multiple tables which has no direct connection I have an interesting question. I need to get data from 3 tables. These tables has no direct relationship with each other. I run the below 3 queries to get the data.
SELECT Name FROM Student WHERE idStudent=5
SELECT Name FROM Vehicle WHERE idVehicle = 1
SELECT Marine from Soldiers WHERE idSoldier = 51

Now, instead of running these 3 queries, is there a way to run one query and get the data?

A: Hopefully this is what you're looking for.
SELECT st.Name as StudentName, v.name as VehicleName, so.Marine
FROM Student st
INNER JOIN Vehicle v ON v.idVehicle = 1
INNER JOIN Soldiers so ON so.idSoldier = 51
WHERE st.idStudent=5


text:
Q: Error: After upgrading from xcode 9 to xcode 10.1 I uploaded a build before one week from xcode 9, it didn't have any problem and was successfully uploaded to the testflight. But I upgraded to Xcode 10 , and now when I upload build then it starts complaining as:
 ERROR ITMS-90725: "SDK Version Issue. This app was built with the iOS
    '${appSDKVersion}' SDK. All iOS apps submitted to the App Store must be built
    with the iOS '11.0' SDK or later, included in Xcode [9.0] or later. Please
    update Xcode and rebuild your app."


text:
Q: Wireless Time Synchronization IC In my application I need a clock that is synchronized across several devices. (A detailed description of my system is given in an earlier question)
It appears achieving precision timing at a software level is not practical, therefore I am looking for a complete hardware solution. In this case I am looking for some sort of hardware that emits a clock that is completely synchronized across several nodes over the air.
Therefore, Are there low cost, short range (up to 20-30 meters) ICs that emit a clock synchronized across several wireless nodes? I cannot use GPS since my system will work mostly indoors.


text:
Q: OAuth Implementation for JS based frontend application So, I was looking at building a JS based front-end (probably with Vue.js) when I encountered a problem.
The backend already has OAuth based APIs, where I would need to authenticate all the API calls using an access token. So I went looking for ways to do so and found out that I should use Client Credentials grant.
The problem is that a frontend application would expose the client ID and secret. These can simply be tracked through the "Network" tab of the Browser's inspector. This makes it possible for anyone to obtain an access token and make dangerous API calls (like deleting stuff).
I also found that PKCE flows dont use client secrets.
However, I have 2 problems with PKCE as well:

*

*Authorization is not needed for these APIs to call as these are very adminy (like user management) APIs.

*PKCE will also expose the client ID.

Assuming that my understanding is correct, how should I implement the OAuth APIs such that it is secure and does not expose any credentials?
Also, if there needs to be more information, please let me know.


text:
Q: Mariadb SQL Select count with group by and select values not null from another I've a problem to realize my query maybe someone of you can help me :)
I have 3 tables :
1) Documents
DocRef  CustRef
Doc1    Cust1
Doc2    Cust2
Doc3    Cust1

2) LinkInter
DocRef  InterRef
Doc1    Inter1
Doc2    Inter2
Doc3    Inter3

3) Inter
id  InterRef    deliverychannel email   mobilenb    date    status
1   Inter1      Email           email1@email.be     2013-01-14T00:00:00Z    ok
2   Inter1      SMS                     0444111111  2013-01-12T00:00:00Z    ko
3   Inter1      Other           email5@email.be     2013-02-21T00:00:00Z    ko
4   Inter2      Email   email2@email.be 044456465465    2013-01-21T00:00:00Z    ko
5   Inter3      Email                               2013-01-21T00:00:00Z    ko
6   Inter3      SMS                                 2013-01-22T00:00:00Z    ko
7   Inter3      Other   email3@mail.be              2013-01-22T00:00:00Z    ko

to have a best view go here: sqlfiddle
The result that I want is the following:
CustRef | number of InterRef SMS KO| Last email known| Last mobilenb known
Cust1   | 2                        | email5@email.be | 0444111111

I want to have all the Customers where the deliverychannel = 'SMS' and the status = 'ko', the number of Inter (Interactions) with the status 'KO', the last email known and the last mobile number known.
I've tried with 2 functions getLastEmailKnown & getLastmobilenbKnown but with my tables that count more than 10.000.000 of records it takes a lot of times
I can have this result with php page but it's not the solution, I want to have  only one query
If I execute 3 queries sepately, it works but i want only one
SELECT d.CustRef, count(DISTINCT i.InterRef) , i.email, i.mobilenb
FROM Documents d
    INNER join LinkInter link on link.DocRef = d.DocRef
    INNER join Inter i on i.InterRef = link.InterRef
          and i.deliverychannel = 'SMS'
          and i.status = 'ko'
group by d.CustRef
Order by d.CustRef DESC;

SELECT distinct i.email as lastEmailKnown, d.CustRef
FROM Inter i
    INNER join LinkInter link on link.InterRef = i.InterRef
    INNER join Documents d on d.DocRef = link.DocRef
where d.CustRef = 'Cust1' AND email is not NULL and email <> '' ORDER by date DESC LIMIT 1;

SELECT distinct i.mobilenb as lastmobileKnown, d.CustRef
FROM Inter i
    INNER join LinkInter link on link.InterRef = i.InterRef
    INNER join Documents d on d.DocRef = link.DocRef
where d.CustRef = 'Cust1' AND mobilenb is not NULL and mobilenb <> '' ORDER by date DESC LIMIT 1;


text:
Q: Background color in GridView In my GridView I have the column name Switch which can contain in each row, three different values; L, B and T.
You can associate a different background color according to values L, B and T ?
For example when the row contain in column name Switch the value L the background color is yellow, when the value B the background color on the row is green and the value T the background color on the row is red.
Can you help me?

A: You can do something like this, if the grid is present in a windows form,
dataGridView1.Rows.OfType<DataGridViewRow>()
                  .Where(x => Convert.ToString(x.Cells["Switch"].Value) == "L").ToList()
                  .ForEach(x => x.DefaultCellStyle.BackColor = Color.Yellow);

Hope this helps...

A: You can try this in RowsAdded Event
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
    {
        var row = dataGridView1.Rows[e.RowIndex];
        if (String.CompareOrdinal(row.Cells["Switch"].Value.ToString(), "L") == 0)
        {
            row.DefaultCellStyle.BackColor = Color.Yellow;
        }
        else if (String.CompareOrdinal(row.Cells["Switch"].Value.ToString(), "B") == 0)
        {
            row.DefaultCellStyle.BackColor = Color.Blue;
        }
    }


text:
Q: Make selected string of text view Bold, Italic, Underline like native "Notes" app of iOS Is there any help to make selected string of text view Bold, Italic, Underline like native "Notes" app of iOS. Please give me helpful links. I am tired of searching for the whole day. Many Thanks.
I have attached my code, to make attributed string Bold and Italic both like native app of iPhone "Notes".
attributedString.beginEditing()
attributedString.addAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: CGFloat(app_delegate.settings.chatFontSize))], range: range)
attributedString.addAttributes([NSFontAttributeName: UIFont.italicSystemFont(ofSize: CGFloat(app_delegate.settings.chatFontSize))], range: range)
attributedString.endEditing()

But its giving only Italic string, not also Bold. I need both Italic and Bold. Thanks.

A: The problem in your code is that you are setting the italic font and overwriting the bold one you've just set. What you need is to use  UIFontDescriptor with Symbolic Traits as you can see in this SO answer. So just initialize your system font, get its font descriptor and add traitBold and traitItalic to it. Then you just need to initialize your new Font using UIFont initializer init(descriptor: UIFontDescriptor, size pointSize: CGFloat):
Swift 4 code:
attributedString.beginEditing()
let systemFont: UIFont = .systemFont(ofSize: 32)
if let descriptor = systemFont.fontDescriptor.withSymbolicTraits([.traitBold, .traitItalic]) {
    let systemFontBoldAndItalic = UIFont(descriptor: descriptor, size: 32)
    attributedString.addAttributes([.font: systemFontBoldAndItalic, .underlineStyle: NSUnderlineStyle.styleSingle.rawValue], range: NSRange(location: 0, length: attributedString.length))
}
attributedString.endEditing()

A: Take a look at NSAttributedString. You can use that to create strings that have mixed attributes at different ranges.
In Objective-C, the mutable version, NSMutableAttributedString has methods like setAttributes(_:range:) that let you change the attributes of an attributed string in a specified range.
So you'd initialize an NSMutableAttributedString starting from a normal String object, and then use setAttributes(_:range:) function to set different attributes like Bold, Italic, etc on a range of the string.
(No, I don't have sample code handy.)

A: Although the question is old but it may helps someone.
Using NSMutableAttributedString won't solve the problem, because if you type any where before the customised text the range will be different. Therefore, the customisation will shift to satisfy the updated range.
I think using HTML is better solution if you would have a very long string.
You may consider using some open source libraries, like ZSSRichTextEditor
Hope that help.


text:
Q: How To Extract Complex Parcel Numbers & Strings Using PHP I was wondering what is the safest and the most efficient way to extract Parcels/AIN Numbers using Reg Exp via PHP.  These parcel numbers are coming from a HUGE text file that are surrounded by addresses, characters and strings. When I use php's reg exp, I dont get any accurate parcels that I want. I'm not sure how to extract the parcel numbers being that they come in a varieties of ways. A snippet of the text, and the regular expression im using is below.
(Parcels usually come in a variety of ways, to many to list here, but here are a few

*

*130.1-8-13,

*01-00603-0000-00002-0000-C-0410,

*01-0AVB-0000-00002-0000-C-0410,

*01-00603-0000-00002-0000-BFB-0101,

*412001216.39-2-22,

*412089214.-1-3.12,

*412001216.41-1-12.6,
)
The php code im currently using..
   $pattern = '/[0-9A-Z.\-]{9,30}/';

   $reg_exp = preg_match_all($pattern, 'text below' , $matches,   PREG_PATTERN_ORDER);

12020                                                                         200800031620700
412001216.41-1-11.1            JOE JACKSON L               555 EASTERN AVE               BALLSTON SPA, NY 12020                                                                                200800059632500
412001216.41-1-11.2            MICHEAL JORDAN              555 YELLOW AVE               BALLSTON SPA, NY 12020                                                                                200800007874700
412001216.41-1-12.6            BRITTNEY SPEARS         PO BOX 139                    ESOPUS, NY 12429-0139                                                                                200800057794400
412001216.47-2-17              MAROON 5             686 BALLYY AVE              BALLSTON SPA, NY 12020                                                                                200800031662900
412001216.48-1-21             LADY J GAGA SMIT           FORNOTX ROBERT                 999 N HIGH ST                 GILLMORE SPA, NY 12020                                                                         200800065014500
412001216.55-1-8               BILLY RODGER LIL JOSEPH A JR

A: I think you're close. All of the parcel numbers in the above sample code are preceded by a 15-digit number, so you could do:
$pattern = '/\d{15} [\dA-Z.\-]{9,30}/';

or if all you want is the second part:
$pattern = '/\d{15} ([\dA-Z.\-]{9,30})/';

This pattern avoids accidentally grabbing zipcodes like the pattern you were using does.


text:
Q: spark cluster svm mllib predict slow and hangs I have simple Java code to predict labels using MLLib svm predict method on AWS EMR. I broadcast the model and then score with the model in a map. The predict just hangs on a large cluster with just 1000 observations. Details of cluster:

*

*r3.8xlarge type 10 node cluster

*driver-memory 64g

*executor-memory 64g

*num-executors 15

*executor-cores 5

*master type yarn-cluster

*deploy mode cluster

The code is as follows:
final Broadcast<SVMModel> svmModel = sc.broadcast(model);

// Compute raw scores on the test set.
JavaRDD<Tuple2<Double, VectorAndLabeledPoint>> scoreAndLabels = test.map(
    new Function<VectorAndLabeledPoint, Tuple2<Double, VectorAndLabeledPoint>>() {
        public Tuple2<Double, VectorAndLabeledPoint> call(VectorAndLabeledPoint p) {

               SVMModel modelin = svmModel.value();
               System.out.println("model file loaded in map:"+modelin.toString());
               Double score = modelin.predict(p.getVector());
               return new Tuple2<Double, VectorAndLabeledPoint>(score, p);
        }
    }
);

Why would predict be so slow on cluster and simply hang when its very fast on single node? 2 minute on single node versus over 1 hour on cluster when its still running.


text:
Q: `time` benchmarking utility: What does `user`+`sys` = 0 actually mean? One comparison I felt that was missing from the Why is this C++ program so incredibly fast? discussion is Fortran.  I translated Sven Hager's C++ benchmark:
#include <iostream>
#include <cstdlib>
#include <cstdint>

int main(int argc, char* argv[]) {
  uint32_t s = 0;
  uint32_t outer = atoi(argv[1]);
  uint32_t inner = atoi(argv[2]);
  for (uint32_t i = 0; i < outer; ++i) {
    for (uint32_t j = 0; j < inner; ++j)
      ++s;
    s -= inner;
  }
  std::cout << s << std::endl;
  return 0;
}

to its Fortran equivalent:
PROGRAM Benchmark
  IMPLICIT NONE
  INTEGER :: i,j,s
  INTEGER, PARAMETER :: outer=1000,inner=1000000
  s = 0
  DO i = 1, outer
    DO j = 1, inner
      s = s + 1
    END DO
    s = s - inner
  END DO
PRINT *, s
END PROGRAM Benchmark

and compiled a fully optimized version with gfortran -g -std=f2008 -Wall -Wextra -O3 Benchmark.f08.  I expected to acheive similar performance as Herr Hager:
real    0m0.003s
user    0m0.002s
sys 0m0.002s

What I got was a little puzzling:
real    0m0.003s
user    0m0.000s
sys 0m0.000s

Digging more deeply, I found this discussion on What do 'real', 'user' and 'sys' mean in the output of time(1)?.  In it they say that user+sys gives the actual CPU time the process used.  So, what does a user+sys of zero actually mean?

A: In this case, "zero" means "less than a millisecond" (or half a millisecond, depending on how it's rounded), since that's the resolution of the times given by time.
It's only useful for measuring programs that take considerably longer than a millisecond to run.
The reason that the Fortran version is much faster is probably because the loop bounds are hard-coded constants, so that the entire calculation can be done at compile time, leaving just PRINT 0 to do at runtime.


text:
Q: Drawing a line between a logo and text I am using bootstrap 5 and I need to draw a thin line after the logo.png below. There should be no spaces between the line and logo
and still no spaces between the text and line.

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

Zombie Testing

How can i achieve this?

A: simply add a border-top to the text by adding the border-top-class

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

Zombie Testing

A: Use margin: 0 to get rid of the space between the elements

h2, hr {
  margin: 0;
}

Zombie Testing

A: This will do :

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

Zombie Testing

check at this:https://jsfiddle.net/sugandhnikhil/t6p4dubo/12/


text:
Q: .htaccess rewriterule "loop" I currently have this line in my .htaccess file making URLs "pretty" for pages.
RewriteRule ^([A-Za-z0-9-]+)/$ /directory/?type=page&title=$1 [L]

However, I sometimes have sub-pages (/page/sub-page/sub-page/), yet this line only supports one level (/page/).
How can I alter this code to support sub-pages (any amount) and make the title variable something like:
&title=page/sub-page/sub-page

/ being the seperator.
I know that this will definitely be a huge help:
RewriteRule loop in .htaccess not working
However, due to my lack of knowledge with regex and mod-rewrite, I don't know how to make it properly work with what I already have.

A: Try this:
AllowEncodedSlashes On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([/a-z0-9-]+)/?$ /directory/?type=page&title=$1 [NC,B,L]

Don't worry about A-Z because of the NC flag.

A: After doing some regex research, and doing some testing, it seems like this is the answer to my problem:
RewriteRule ^(([a-zA-Z0-9-]+)/(([a-zA-Z0-9-]+)\/?)+)$ /directory/?type=page&title=$1 [L]

I altered my previous code and allowed support for multiple sub-directories. Then I placed it into a capture group and placed that data into the title variable.