Consider option to remove blank space around signature

I need to use the sig image later in my app and the blank space around the sig can be a bit of a pain. I added an option to remove this blank space so that the image returned when I get the data is the cropped signature. I'm not sure if this would be useful to others, and I am not able to git at the moment, so I'll just offer it here in case it proves helpful.
    SignaturePad.prototype.removeBlanks = function () {
        var imgWidth = this._ctx.canvas.width;
        var imgHeight = this._ctx.canvas.height;
        var imageData = this._ctx.getImageData(0, 0, imgWidth, imgHeight),
        data = imageData.data,
        getAlpha = function(x, y) {
            return data[(imgWidth*y + x) * 4 + 3]
        },
        scanY = function (fromTop) {
            var offset = fromTop ? 1 : -1;

            // loop through each row
            for(var y = fromTop ? 0 : imgHeight - 1; fromTop ? (y < imgHeight) : (y > -1); y += offset) {

                // loop through each column
                for(var x = 0; x < imgWidth; x++) {
                    if (getAlpha(x, y)) {
                        return y;
                    }
                }
            }
            return null; // all image is white
        },
        scanX = function (fromLeft) {
            var offset = fromLeft? 1 : -1;

            // loop through each column
            for(var x = fromLeft ? 0 : imgWidth - 1; fromLeft ? (x < imgWidth) : (x > -1); x += offset) {

                // loop through each row
                for(var y = 0; y < imgHeight; y++) {
                    if (getAlpha(x, y)) {
                        return x;
                    }
                }
            }
            return null; // all image is white
        };

        var cropTop = scanY(true),
        cropBottom = scanY(false),
        cropLeft = scanX(true),
        cropRight = scanX(false);

        var relevantData = this._ctx.getImageData(cropLeft, cropTop, cropRight-cropLeft, cropBottom-cropTop);
        this._canvas.width = cropRight-cropLeft;
        this._canvas.height = cropBottom-cropTop;
        this._ctx.clearRect(0, 0, cropRight-cropLeft, cropBottom-cropTop);
        this._ctx.putImageData(relevantData, 0, 0);
    };

FYI, credit for most of this code goes to http://stackoverflow.com/questions/12175991/crop-image-white-space-automatically-using-jquery
I imagine my need for this feature also grows from my using signature_pad on a larger tablet instead of a phone-size device.

This can also be done easily in PHP using the Intervention library...  http://image.intervention.io/api/trim

Could this be merged in? It's not a bad idea to have an additional utility function. If someone needs client side trimming (as I do), they can use this method. Currently I rely on a fork, but having it in the main repository makes upgrading straightforward.

@BasitAli It won't be merged. You don't have to rely on a fork - you can simply use the function provided by @efc. It doesn't access any data from the library - only the canvas, so it doesn't even have to be on SignaturePad class. You can simply add it as e.g. window.imageUtils.trim or something similar and use that.

Ah, yes, ofcourse. Thanks :).

I've just added info about trimming images to readme file and linked to code provided by @efc (thanks!), so I'm finally closing this issue.

I disagree that this funcionality should be handled by a separate code/library/component. Don't get me wrong, please. But the signature pad exists to capture a users' signature, and the blank space around it is not part of the signature. Also, in many development teams this is a job for a frontend developer, and most times a frontend developer doesn't have access to backend funcionality to trim the imagem server-side. Signature-pad should handle it, in my opinion.
As I said, please don't get me wrong!

I was able to implement this in my project, it crops the image as it should and sends the cropped image to the server. The problem is that my canvas content gets distorted on screen. I only want to send the cropped image to my server; the changes cannot be made on screen.
I'm trying to create a temporary canvas and crop this instead, but I'm having a hard time.
Can someone help me? Maybe @efc ?

The removeBlanks method simply resizes your canvas element.  So, after you call it and submit your data to wherever, you need to resize your canvas back to normal size.  Here is how I accomplished it in Angular.  I know you probably aren't using Angular, but maybe this will give you an idea of how to potentially tack this problem...
In this implementation, a button triggers the submit() method, which trims the canvas, saves the data, clears the canvas, and then resizes the canvas.  The same function that is used to size the canvas on page load, is re-used to size after saving the data.
Hope this helps...
Javascript
angular
    .module('app')
    .directive('psSignature', psSignature);

  function psSignature($window, $timeout) {
    return {
      restrict: 'E',
      scope: {
        onCancel: '&',
        onSubmit: '&',
        submitting: '='
      },
      templateUrl: 'widgets.signature',
      link: function (scope, element, attrs) {
        var canvas = element.find('canvas')[0];
        var canvasWrapper = element.find('.signature__body')[0];
        var signaturePad = new SignaturePad(canvas, {onEnd: makeDirty});
        var dirty = false;

        scope.cancel = scope.onCancel;
        scope.clear = clear;
        scope.submit = submit;
        scope.isDirty = isDirty;
        scope.showCancel = showCancel;

        activate();

        ////////////

        function activate() {
          addListeners();
          $timeout(resizeCanvas, 500);
        }

        function addListeners() {
          // Add
          angular.element($window).on('resize', resizeCanvas);
          // Clean up
          scope.$on('$destroy', function () {
            angular.element($window).off('resize', resizeCanvas);
          });
        }

        function makeDirty() {
          scope.$apply(function () {
            dirty = true;
          });
        }

        function clear() {
          signaturePad.clear();
          dirty = false;
        }

        function submit() {
          signaturePad.removeBlanks();
          scope.onSubmit({contents: signaturePad.toDataURL()});
          clear();
          resizeCanvas();
        }

        function isDirty() {
          return dirty;
        }

        function showCancel() {
          return !!(attrs.onCancel);
        }

        function resizeCanvas() {
          canvas.width = canvasWrapper.offsetWidth;
          canvas.height = canvasWrapper.offsetHeight;
        }
      }
    };
  }

HTML

            <button ng-click="cancel()" ng-show="showCancel()">
                 Cancel
            </button>

            <button ng-click="clear()" ng-disabled="!isDirty()">
                Clear
            </button>

            <button ng-click="submit()" ng-disabled="!isDirty()">
                 Submit
            </button>

Please Sign Here

        <canvas class="signature__pad"></canvas>

Looks like @mikemclin provided a great answer, @rodrigovallades. I don't have to bother resizing the canvas in my app since it loads a whole new HTML page with a fresh canvas, so I'm afraid I can't really improve on Mike's suggestion.

@mikemclin @efc
Actually I'm using angular in my project, indeed. I managed to accomplish what I wanted by duplicating the canvas and trimming the new one.
But I'll try your suggestion later @mikemclin , thank you!

thanks for this. it seemed that @efc solution has a lil problem. i found it when tried to fill the canvas with text - fillText() method. faded/shaded area of text is being removed. so ive decided to use the original code from stackoverflow's thread instead - getRGB() + isWhite() combination and worked pretty well :)

@mikemclin
Can you give a few more instructions on setting this up? I presume

AngularJS added above head
Create a new Angular file with your sample code
Add <ng-controller="app"> and your code to HTML

That's what I've done so far- and but it does not work (no error, but the controller doesn't seem to get "used"- I can use anything in "ng-controller" and I wont get an error).
I made a plunker- https://plnkr.co/edit/NOZG5Y4dgrpCZKU5Xkja?p=preview

It can be done by simply adjusting the canvas size in the css. Worked for me.

Just adjusted the canvas size and signature pad size in the CSS. Worked for me. :)

@yarnball I modified my answer slightly to better describe what the code snippets are for.  The JavaScript is my Angular directive.  The HTML provided was the HTML template for the directive.
Now I would use that directive in my code; something like this...
<ps-signature on-submit="vm.submit(contents)" submitting="vm.submitting">Please sign here...</ps-signature>

You're going to need to have a good understanding of Angular directives to actually use my code in your app. And realistically, it was built for my app's purposes and might not be very flexible for reusability.

For anyone who's looking for a tiny library that does this, I've created one here: https://github.com/agilgur5/trim-canvas based off @efc's code
Side note:
It's also used in my React implementation of signature_pad, in case you're looking for one of those: https://github.com/agilgur5/react-signature-canvas (based off https://github.com/blackjk3/react-signature-pad)

Thanks, @agilgur5. That's great!

+1 @agilgur5

I agree. Since this is for a signature in some respects it makes sense that the white space should be trimmed, or added as a flag: trimWhiteSpace: true.
Just seems so sensible to do it client-side and within the library.

Here's what we ended up using.
The big difference and thing to note is that running this does NOT modify the primary canvas. It duplicates it, then trims the signature on the duplicate, and returns the data url. This is because I didn't want to modify the canvas the user sees.
Our use case is we have the signature field and a hidden field, which is for the data URL. Every time onEnd fires, we run the signature through the crop function (which returns the trimmed data) and then insert it/update the hidden field.
Works very well. Hopefully it helps someone, took a bit of fiddling to get worked out :)
		/**
		 * Crop signature canvas to only contain the signature and no whitespace.
		 *
		 * @since 1.0.0
		 */
		cropSignatureCanvas: function(canvas) {

			// First duplicate the canvas to not alter the original
			var croppedCanvas = document.createElement('canvas'),
				croppedCtx    = croppedCanvas.getContext('2d');

				croppedCanvas.width  = canvas.width;
				croppedCanvas.height = canvas.height;
				croppedCtx.drawImage(canvas, 0, 0);

			// Next do the actual cropping
			var w         = croppedCanvas.width,
				h         = croppedCanvas.height,
				pix       = {x:[], y:[]},
				imageData = croppedCtx.getImageData(0,0,croppedCanvas.width,croppedCanvas.height),
				x, y, index;

			for (y = 0; y < h; y++) {
				for (x = 0; x < w; x++) {
					index = (y * w + x) * 4;
					if (imageData.data[index+3] > 0) {
						pix.x.push(x);
						pix.y.push(y);

					}
				}
			}
			pix.x.sort(function(a,b){return a-b});
			pix.y.sort(function(a,b){return a-b});
			var n = pix.x.length-1;

			w = pix.x[n] - pix.x[0];
			h = pix.y[n] - pix.y[0];
			var cut = croppedCtx.getImageData(pix.x[0], pix.y[0], w, h);

			croppedCanvas.width = w;
			croppedCanvas.height = h;
			croppedCtx.putImageData(cut, 0, 0);

			return croppedCanvas.toDataURL();
		},

this save my life thank you @efc
signaturePad.removeBlanks();
$('#base64Data').val(signaturePad.toDataURL());

https://github.com/szimek/signature_pad/issues/49#issuecomment-260976909 This is exactly what I'm looking for. Thanks for sharing!

Hi,
I have to store signatures (base64) in a database using SignaturePad. To big ! (60ko)
This script seems perfect to solve a part of my problem but i don't know how to use it ! :o( (not a js expert)
can you explain how to integrate this  ? Where should I copy this great code ? Where should I call it ? A small tuto Please

I translated @jaredatch's solution to Angular 2 / Typescript:
let canvas: HTMLCanvasElement = document.getElementsByTagName("canvas")[0];
let croppedCanvas:HTMLCanvasElement = document.createElement('canvas');
let croppedCtx:CanvasRenderingContext2D = croppedCanvas.getContext("2d");

croppedCanvas.width = 556;
croppedCanvas.height = 150;
croppedCtx.drawImage(canvas, 0, 0);

let w = croppedCanvas.width;
let h = croppedCanvas.height;
let pix = {x:[], y:[]};
let imageData = croppedCtx.getImageData(0,0,w,h);
let index = 0;

for (let y = 0; y < h; y++) {
	for (let x = 0; x < w; x++) {
		index = (y * w + x) * 4;
		if (imageData.data[index+3] > 0) {
			pix.x.push(x);
			pix.y.push(y);
		}
	}
}

pix.x.sort((a,b) => a-b);
pix.y.sort((a,b) => a-b);
let n = pix.x.length-1;

w = pix.x[n] - pix.x[0];
h = pix.y[n] - pix.y[0];
var cut = croppedCtx.getImageData(pix.x[0], pix.y[0], w, h);

croppedCanvas.width = w;
croppedCanvas.height = h;
croppedCtx.putImageData(cut, 0, 0);

return croppedCanvas.toDataURL();

Works great!

Thank you very much for a cool solution to removeBlanks(). I have successfully saved signature without extra blanks. The problem I am encountering is re-loading the signature from database and displaying on signaturePad. The trimmed signature is auto stretching to fit the canvas. This looks not too good. Is there a way to add blanks to the trimmed signature so it will display correctly on the canvas? Thank you very much.

Running into issues with tests for all non-angular versions of this program... is it still up-to-date? Been a late night, so sorry for any potentially major oversights...
For all the images, the loops don't seem to be catching where "text" is -- anything that's white seems to be text. It's simply cropping the canvas by 1 pixel for each iteration. Any help would be appreciated :)

croppedCanvas

Here's what we ended up using.
The big difference and thing to note is that running this does NOT modify the primary canvas. It duplicates it, then trims the signature on the duplicate, and returns the data url. This is because I didn't want to modify the canvas the user sees.
Our use case is we have the signature field and a hidden field, which is for the data URL. Every time onEnd fires, we run the signature through the crop function (which returns the trimmed data) and then insert it/update the hidden field.
Works very well. Hopefully it helps someone, took a bit of fiddling to get worked out :)
        /**
         * Crop signature canvas to only contain the signature and no whitespace.
         *
         * @since 1.0.0
         */
        cropSignatureCanvas: function(canvas) {

            // First duplicate the canvas to not alter the original
            var croppedCanvas = document.createElement('canvas'),
                croppedCtx    = croppedCanvas.getContext('2d');

                croppedCanvas.width  = canvas.width;
                croppedCanvas.height = canvas.height;
                croppedCtx.drawImage(canvas, 0, 0);

            // Next do the actual cropping
            var w         = croppedCanvas.width,
                h         = croppedCanvas.height,
                pix       = {x:[], y:[]},
                imageData = croppedCtx.getImageData(0,0,croppedCanvas.width,croppedCanvas.height),
                x, y, index;

            for (y = 0; y < h; y++) {
                for (x = 0; x < w; x++) {
                    index = (y * w + x) * 4;
                    if (imageData.data[index+3] > 0) {
                        pix.x.push(x);
                        pix.y.push(y);

                    }
                }
            }
            pix.x.sort(function(a,b){return a-b});
            pix.y.sort(function(a,b){return a-b});
            var n = pix.x.length-1;

            w = pix.x[n] - pix.x[0];
            h = pix.y[n] - pix.y[0];
            var cut = croppedCtx.getImageData(pix.x[0], pix.y[0], w, h);

            croppedCanvas.width = w;
            croppedCanvas.height = h;
            croppedCtx.putImageData(cut, 0, 0);

            return croppedCanvas.toDataURL();
        },

It doesn't work for me. The base64 string is broken and can not display on the browser.

I need to use the sig image later in my app and the blank space around the sig can be a bit of a pain. I added an option to remove this blank space so that the image returned when I get the data is the cropped signature. I'm not sure if this would be useful to others, and I am not able to git at the moment, so I'll just offer it here in case it proves helpful.
    SignaturePad.prototype.removeBlanks = function () {
        var imgWidth = this._ctx.canvas.width;
        var imgHeight = this._ctx.canvas.height;
        var imageData = this._ctx.getImageData(0, 0, imgWidth, imgHeight),
        data = imageData.data,
        getAlpha = function(x, y) {
            return data[(imgWidth*y + x) * 4 + 3]
        },
        scanY = function (fromTop) {
            var offset = fromTop ? 1 : -1;

            // loop through each row
            for(var y = fromTop ? 0 : imgHeight - 1; fromTop ? (y < imgHeight) : (y > -1); y += offset) {

                // loop through each column
                for(var x = 0; x < imgWidth; x++) {
                    if (getAlpha(x, y)) {
                        return y;
                    }
                }
            }
            return null; // all image is white
        },
        scanX = function (fromLeft) {
            var offset = fromLeft? 1 : -1;

            // loop through each column
            for(var x = fromLeft ? 0 : imgWidth - 1; fromLeft ? (x < imgWidth) : (x > -1); x += offset) {

                // loop through each row
                for(var y = 0; y < imgHeight; y++) {
                    if (getAlpha(x, y)) {
                        return x;
                    }
                }
            }
            return null; // all image is white
        };

        var cropTop = scanY(true),
        cropBottom = scanY(false),
        cropLeft = scanX(true),
        cropRight = scanX(false);

        var relevantData = this._ctx.getImageData(cropLeft, cropTop, cropRight-cropLeft, cropBottom-cropTop);
        this._canvas.width = cropRight-cropLeft;
        this._canvas.height = cropBottom-cropTop;
        this._ctx.clearRect(0, 0, cropRight-cropLeft, cropBottom-cropTop);
        this._ctx.putImageData(relevantData, 0, 0);
    };

FYI, credit for most of this code goes to http://stackoverflow.com/questions/12175991/crop-image-white-space-automatically-using-jquery
I imagine my need for this feature also grows from my using signature_pad on a larger tablet instead of a phone-size device.

Can someone please explain how to actually call this function?
I am trying to call it this way:
var data = signaturePad.toDataURL('image/png').removeBlanks();
but it does not work. It gives me an error:

Uncaught TypeError: signaturePad.toDataURL(...).removeBlanks is not a function at

HTMLButtonElement.

How should I use it?

@crypto789 you have to do two separate statements to achieve that:
signaturePad.removeBlanks();
var data = signaturePad.toDataURL('image/png');

NOTES: toDataURL method returns a string, so you can't chain any method/props of signaturePad prototype (though any valid String prop/method will do)

@crypto789 you have to do two separate statements to achieve that:
signaturePad.removeBlanks();
var data = signaturePad.toDataURL('image/png');

NOTES: toDataURL method returns a string, so you can't chain any method/props of signaturePad prototype (though any valid String prop/method will do)

Maybe I am not getting something...is it supposed to remove white space around the signature?

Yes @crypto789, it is supposed to remove as much of the bounding rectangle as possible without removing any of the signature itself.

not working on ipad. is there any solution or am i miss something?

@shaangidwani my example demo works fine on my iPad. Uses trim-canvas under the hood.

I translated @jaredatch's solution to Angular 2 / Typescript:
let canvas: HTMLCanvasElement = document.getElementsByTagName("canvas")[0];
let croppedCanvas:HTMLCanvasElement = document.createElement('canvas');
let croppedCtx:CanvasRenderingContext2D = croppedCanvas.getContext("2d");

croppedCanvas.width = canvas.width;
croppedCanvas.height = canvas.height;
croppedCtx.drawImage(canvas, 0, 0);

let w = croppedCanvas.width;
let h = croppedCanvas.height;
let pix = {x:[], y:[]};
let imageData = croppedCtx.getImageData(0,0,w,h);
let index = 0;

for (let y = 0; y < h; y++) {
	for (let x = 0; x < w; x++) {
		index = (y * w + x) * 4;
		if (imageData.data[index+3] > 0) {
			pix.x.push(x);
			pix.y.push(y);
		}
	}
}

pix.x.sort((a,b) => a-b);
pix.y.sort((a,b) => a-b);
let n = pix.x.length-1;

w = pix.x[n] - pix.x[0];
h = pix.y[n] - pix.y[0];
var cut = croppedCtx.getImageData(pix.x[0], pix.y[0], w, h);

croppedCanvas.width = w;
croppedCanvas.height = h;
croppedCtx.putImageData(cut, 0, 0);

return croppedCanvas.toDataURL();

Works great!

PERFECT!!!!

Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source width is 0.
I am getting this error using above code @jaredatch

@hariomdebut that error is a bit cryptic, but it means the canvas has 0 width. That probably means your original canvas (that is cloned) is incorrectly sized

@agilgur5 I tried many solutions for this but none worked. I don't know it works for some guys. Still the best solution which works for me :
trimCanvas(c) {
const ctx = c.getContext('2d');
const copy = document.createElement('canvas').getContext('2d');
const pixels = ctx.getImageData(0, 0, c.width, c.height);
const l = pixels.data.length;
let i;
const bound = {
top: null,
left: null,
right: null,
bottom: null
};
let x;
let y;
// Iterate over every pixel to find the highest
// and where it ends on every axis ()
for (i = 0; i < l; i += 4) {
if (pixels.data[i + 3] !== 0) {
x = (i / 4) % c.width;
// tslint:disable-next-line: no-bitwise
y = ~~((i / 4) / c.width);
if (bound.top === null) {
bound.top = y;
}
if (bound.left === null) {
bound.left = x;
} else if (x < bound.left) {
bound.left = x;
}
if (bound.right === null) {
bound.right = x;
} else if (bound.right < x) {
bound.right = x;
}
if (bound.bottom === null) {
bound.bottom = y;
} else if (bound.bottom < y) {
bound.bottom = y;
}
}
}
// Calculate the height and width of the content
const trimHeight = bound.bottom - bound.top;
const trimWidth = bound.right - bound.left;
const trimmed = ctx.getImageData(bound.left, bound.top, trimWidth, trimHeight);
copy.canvas.width = trimWidth;
copy.canvas.height = trimHeight;
copy.putImageData(trimmed, 0, 0);
// Return trimmed canvas
return copy.canvas;
}

@hariomdebut it work perfectly, in my code I replaced:
return this._signaturePad.toDataURL(type);
with:
return this.trimCanvas(this._canvas).toDataURL('image/png');

Please consider merging this in since the whitespace is not part of a signature. Trying to use this within React client-side pdf generation. Third-party packages like trim-canvas are outdated and fail to load @babel/core correctly.

@ustincameron hi, dude who made trim-canvas here, which was built from this thread (see the comments). All of the comments in this thread are virtually identical to it and each other.

Third-party packages like trim-canvas are outdated

Just because a package (like trim-canvas) hasn't published a new version in years, doesn't mean it's outdated. trim-canvas gets ~37k downloads every single week and is used inside of react-signature-canvas (also made by me) and vue-signature-canvas among others, which are actively used as well. It has 100% test coverage as does react-signature-canvas, which also has a few live, working examples.

and fail to load @babel/core correctly.

Well trim-canvas was built before @babel/core (Babel 7) existed, so it doesn't use it. babel-core (Babel 6) is a dev dependency and there are no (prod) dependencies. Can look at the build on UNPKG which doesn't make any imports/requires
If you've got a problem with trim-canvas, I'd recommend filing an issue in that repo with a detailed reproduction or failing test case.

Here's what we ended up using.
The big difference and thing to note is that running this does NOT modify the primary canvas. It duplicates it, then trims the signature on the duplicate, and returns the data url. This is because I didn't want to modify the canvas the user sees.
Our use case is we have the signature field and a hidden field, which is for the data URL. Every time onEnd fires, we run the signature through the crop function (which returns the trimmed data) and then insert it/update the hidden field.
Works very well. Hopefully it helps someone, took a bit of fiddling to get worked out :)
        /**
         * Crop signature canvas to only contain the signature and no whitespace.
         *
         * @since 1.0.0
         */
        cropSignatureCanvas: function(canvas) {

            // First duplicate the canvas to not alter the original
            var croppedCanvas = document.createElement('canvas'),
                croppedCtx    = croppedCanvas.getContext('2d');

                croppedCanvas.width  = canvas.width;
                croppedCanvas.height = canvas.height;
                croppedCtx.drawImage(canvas, 0, 0);

            // Next do the actual cropping
            var w         = croppedCanvas.width,
                h         = croppedCanvas.height,
                pix       = {x:[], y:[]},
                imageData = croppedCtx.getImageData(0,0,croppedCanvas.width,croppedCanvas.height),
                x, y, index;

            for (y = 0; y < h; y++) {
                for (x = 0; x < w; x++) {
                    index = (y * w + x) * 4;
                    if (imageData.data[index+3] > 0) {
                        pix.x.push(x);
                        pix.y.push(y);

                    }
                }
            }
            pix.x.sort(function(a,b){return a-b});
            pix.y.sort(function(a,b){return a-b});
            var n = pix.x.length-1;

            w = pix.x[n] - pix.x[0];
            h = pix.y[n] - pix.y[0];
            var cut = croppedCtx.getImageData(pix.x[0], pix.y[0], w, h);

            croppedCanvas.width = w;
            croppedCanvas.height = h;
            croppedCtx.putImageData(cut, 0, 0);

            return croppedCanvas.toDataURL();
        },

Sorry for this late reply, but is there an option to use this for SVG?
For me this always exports a PNG even if I replace the last line with:
return croppedCanvas.toDataURL('image/svg+xml');

@MartinH0 that's not really possible as no browser natively supports Canvas to SVG. signature_pad non-trimmed can only do it because it records the raw point data and has an algorithm to output SVG from that.
Can see https://github.com/agilgur5/react-signature-canvas/issues/49#issuecomment-627726585 for more details

@agilgur5 hm ok, thank you. Maybe a bit offtopic, but do you know how to (in JS, or PHP) trim normal SVGs?
I really cant find anything related to trim SVGs. As when I download the SVG if will always have white-borders as the SVG which gets exported was bigger of course.

@MartinH0 I found a good few results in a quick search, basically all pertaining to changing the SVG's viewBox. Off the top of my head, not sure if that's the best answer as I haven't done raw SVG manipulation in like 4-6 years (Data Visualization / D3 work).

This then also could (should) be implemented in signature_pad as I think this will be a good feature. But maybe just as option.

The above code is only a few lines of user-land code. Theoretically I could make trim-svg as a counterpart to trim-canvas and would be supportive of either making it into signature_pad, but that's previously been rejected.
react-signature-canvas has a trimCanvas method built-in because of the frequency of these requests. Trimming SVG out-of-the-box is a bit more of a clunky API since one is Canvas => Canvas and the other SVG => SVG, but trimCanvasAsSVG or something could work.

@MartinH0 thanks for your trim canvas code, I'm using that in angular component https://github.com/ghwrivas/ngx-signature-pad/blob/master/projects/ngx-signature-pad/src/lib/ngx-signature-pad.component.ts

When using Signature pad in a form, what is the best way to return the completed signature base64 data to an input?
Looking at a jquery on submit or maybe it's put in a hidden text input once there's a exit from the canvas. I don't want to chase my tail if that's not it. I have a ton of other information going through this form.
Sending it to a MySQL database as BLOB. This isn't going to be a database called upon daily so I'm not worried about the weight. It's more important to keep the signature with the other submitted info.

handler: "TypeError: Cannot read property 'width' of undefined"     why?

handler: "TypeError: Cannot read property 'width' of undefined"     why?

jaredatch's code with small modifications becomes 3-4x faster
function getCroppedCanvasImage(canvas: HTMLCanvasElement) {

	let originalCtx = canvas.getContext('2d');

	let originalWidth = canvas.width;
	let originalHeight = canvas.height;
	let imageData = originalCtx.getImageData(0,0, originalWidth, originalHeight);

	let minX = originalWidth + 1, maxX = -1, minY = originalHeight + 1, maxY = -1, x = 0, y = 0, currentPixelColorValueIndex;

	for (y = 0; y < originalHeight; y++) {
		for (x = 0; x < originalWidth; x++) {
			currentPixelColorValueIndex = (y * originalWidth + x) * 4;
			let currentPixelAlphaValue = imageData.data[currentPixelColorValueIndex + 3];
			if (currentPixelAlphaValue > 0) {
				if (minX > x) minX = x;
				if (maxX < x) maxX = x;
				if (minY > y) minY = y;
				if (maxY < y) maxY = y;
			}
		}
	}

	let croppedWidth = maxX - minX;
	let croppedHeight = maxY - minY;
	if (croppedWidth < 0 || croppedHeight < 0) return null;
	let cuttedImageData = originalCtx.getImageData(minX, minY, croppedWidth, croppedHeight);

	let croppedCanvas = document.createElement('canvas'),
		croppedCtx    = croppedCanvas.getContext('2d');

	croppedCanvas.width = croppedWidth;
	croppedCanvas.height = croppedHeight;
	croppedCtx.putImageData(cuttedImageData, 0, 0);

	return croppedCanvas.toDataURL();
}

Thanks.
To center the signature without cropping (works for my need):
Replace the code:
    this._canvas.width = cropRight-cropLeft;
    this._canvas.height = cropBottom-cropTop;
    this._ctx.clearRect(0, 0, cropRight-cropLeft, cropBottom-cropTop);
    this._ctx.putImageData(relevantData, 0, 0);

with:
    this._ctx.clearRect(0, 0, imgWidth, imgHeight);
    this._ctx.putImageData(relevantData, (imgWidth - (cropRight-cropLeft))/2, (imgHeight - (cropBottom-cropTop))/2);

Fantastic @Riba-Kit : many thanks!
One question, should the line:
if (croppedWidth < 0 || croppedHeight < 0) return null;
...include the zero also?   I modified it to:
if (croppedWidth <= 0 || croppedHeight <= 0) return null;
...because I found documentation which says that getImageData will throw an exception if either of those is zero.

@larrymcp Thanks! You found a bug in my production)

jaredatch's code with small modifications becomes 3-4x faster
function getCroppedCanvasImage(canvas: HTMLCanvasElement) {

	let originalCtx = canvas.getContext('2d');

	let originalWidth = canvas.width;
	let originalHeight = canvas.height;
	let imageData = originalCtx.getImageData(0,0, originalWidth, originalHeight);

	let minX = originalWidth + 1, maxX = -1, minY = originalHeight + 1, maxY = -1, x = 0, y = 0, currentPixelColorValueIndex;

	for (y = 0; y < originalHeight; y++) {
		for (x = 0; x < originalWidth; x++) {
			currentPixelColorValueIndex = (y * originalWidth + x) * 4;
			let currentPixelAlphaValue = imageData.data[currentPixelColorValueIndex + 3];
			if (currentPixelAlphaValue > 0) {
				if (minX > x) minX = x;
				if (maxX < x) maxX = x;
				if (minY > y) minY = y;
				if (maxY < y) maxY = y;
			}
		}
	}

	let croppedWidth = maxX - minX;
	let croppedHeight = maxY - minY;
	if (croppedWidth < 0 || croppedHeight < 0) return null;
	let cuttedImageData = originalCtx.getImageData(minX, minY, croppedWidth, croppedHeight);

	let croppedCanvas = document.createElement('canvas'),
		croppedCtx    = croppedCanvas.getContext('2d');

	croppedCanvas.width = croppedWidth;
	croppedCanvas.height = croppedHeight;
	croppedCtx.putImageData(cuttedImageData, 0, 0);

	return croppedCanvas.toDataURL();
}

This returns it as .png :(

This returns it as .png :(

If you need a jpg image, you must change :
return croppedCanvas.toDataURL();
to :
return croppedCanvas.toDataURL('image/jpeg', 1.0);

If exporting SVG are required, @efc 's solution is still the only one works without other dependencies.  For signature_pad.umd.min.js v 4.0.7, it needs to modified two lines, from
this._canvas.width = cropRight-cropLeft;
this._canvas.height = cropBottom-cropTop;

to
this._ctx.canvas.width = cropRight-cropLeft;
this._ctx.canvas.height = cropBottom-cropTop;

If other file formats are allowed, you can check first which MIME types are working in browsers before using canvas solution such as @Riba-Kit 's.
https://kangax.github.io/jstests/toDataUrl_mime_type_test/

Hi Jared @jaredatch,
Could you please tell us what is the license for the above function? :)
Regards,
Andrei

It would be really helpful for the signature object to also return the bounding rectangle of the signature (no need to actually crop the image).  Then we could do the processing ourselves.  Something like signature.bounds() which returns { left, top, width, height } of the actual signature image. This could be calculated while the user is drawing the sig, thus eliminating the need to scan the entire image afterward.

@efc Thanks for your modification, this modification works perfectly if the background is transparent, but if we change the background color of the canvas, it doesn't work. Can you please help me?

Here's the function I use to get a cropped SVG. First call signaturePad.toSVG(), then pass the result to this function, which returns a cropped result.
It manipulates the svg's viewBox attribute to "zoom in" on the appropriate area. It determines the appropriate area by calling the builtin getBBox() function on the SVG element.
function cropSVG(svgText: string): string {
  // First convert the svg string into an html element so we can
  // call getBBox() on it.
  const tempElement = document.createElement('div');
  tempElement.setAttribute('style', 'visibility: hidden');
  // getBBox() only works if the element is rendered into the page.
  document.body.appendChild(tempElement);
  tempElement.innerHTML = svgText;
  const svgElement = tempElement.getElementsByTagName('svg')[0]
  // This gets the bounding box around the signature.
  const bbox = svgElement.getBBox();
  // Use the bounding box's coordinates as the svg's viewBox.
  // This eliminates the whitespace by "zooming in" on the
  // bounding box.  Include 5px extra, as the signature's
  // edges get slightly clipped otherwise.
  const viewBox = [bbox.x - 5, bbox.y - 5, bbox.width + 10, bbox.height + 10].join(" ");
  svgElement.setAttribute("viewBox", viewBox);
  // Let the svg have the size and aspect ratio of the
  // cropped result, not the original canvas.
  svgElement.removeAttribute("width");
  svgElement.removeAttribute("height");
  const croppedSVG = svgElement.outerHTML;
  document.body.removeChild(tempElement);
  return croppedSVG;
}

Use as follows:
const croppedSVGString = cropSVG(signaturePad.toSVG());

Hi,
Im using @jaredatch function and facing a weird issue..
ive this error from error reports from users but i can't really reproduce it by myself :
TypeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': Value is not of type 'long'.: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': Value is not of type 'long'.
from : var cut = croppedCtx.getImageData(pix.x[0], pix.y[0], w, h);.
The only thing i can find if that : either pix.x[0], pix.y[0], w or h is undefined or NaN..
but i can't find why.
Of course, i only run this function when canvas has been touched by user and has pixel on it.
Anyone had this issue before ?
thanks


Roll Flutter Engine from a565cea256c7 to 578ececb993e (1 revision)

https://github.com/flutter/engine/compare/a565cea256c7...578ececb993e
2023-12-14<EMAIL_ADDRESS>Roll Skia from 4170fba2d89f to 0d5356a0f3cb (1 revision) (flutter/engine#49036)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jsimmons@google.com,rmistry<EMAIL_ADDRESS>on the revert to ensure that a human
is aware of the problem.
To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Commit queue failed; closing this roll.


prepare-iwslt14.sh: chars are replaced with @. Why?

❓ Questions and Help
After running the script prepare-iwslt14.sh the resulting files contain many @ symbols. The file valid.en begins like this:
it had two@@ -@@ to-@@ three-@@ to-@@ 400 times the toxic lo@@ ads ever allowed by the ep@@ a .
often what j@@ ams us up is se@@ wa@@ ge .
what do you do when you have this sort of disrup@@ ted flow ?
stephen pal@@ um@@ b@@ i : following the mer@@ cur@@ y tra@@ il

Is this really the correct behavior? That's garbage, isn't it? Or did I miss something?

It's no wonder these things come out during fairseq-generate after the training is done:
S-220	ich musste nicht mehr mit dem bor@@ d@@ personal reden .
T-220	i didn 't have to talk to the f@@ light atten@@ d@@ ant anymore .

Why is the data lowercased during the prepare script? Doesn't this mean that valuable information is lost in some/many cases? Doesn't that also mean that only lowercase words can be generated? Why are words not lowercased when I look at the example usage?

The original data contains lines like this:
train.tags.de-en.en:

Rolf Bolin, who was a professor at the Hopkin's Marine Station where I work, wrote in the 1940s that "The fumes from the scum floating on the inlets of the bay were so bad they turned lead-based paints black."

train.tags.de-en.de:

Rolf Bolin, ein ehemaliger Professor an der Hopkin's Marine Station, wo ich arbeite schrieb in den 40er Jahren: "Die Dämpfe des Schaums, der in den Zugängen zur Bucht trieb waren so schlimm, dass sie bleihaltige Farbe schwarz färbten."

What I actually want is to train a model for a translation task with my own sentence pairs of languages that are not offered as pretrained models. But removing the capitalization and replacing chars with @ does not help to achieve the goal. Any ideas how to reach the goal with fairseq?

Thanks in advance for any assistance. :+1:
What's your environment?

fairseq: 0.9.0
PyTorch: 1.4.0
OS: Ubuntu 18.04
How you installed fairseq: pip

This is called BPE-tokenization. It splits infrequent words into more frequent tokens. @@ is used to show when multiple tokens are a part of the same word.
For example:
antidisestablishmentarianism -> anti@@ dis@@ est@@ ablishment@@ arism


Add support for CodeDeploy Commands (non-botocore)

The AWS CodeDeploy service has two public APIs, the standard control plane which is already present in Rusoto, and an agent control plane which is used by the CodeDeploy agent software to pull deployment work and report back the status of the work. Because the command service is only of use to the agent software, it is not published in the official AWS SDKs. I would like to add support for the CodeDeploy command service to Rusoto.
In addition to the standard work of adding support for a new service, this will also be the first service that is not backed by JSON service file loaded from botocore. My plan is to check in the new service's JSON definition file directly into Rusoto's repository, and update the service_crategen code to know that it can pull files from the new in-repository location as well as through botocore. This will require the minimal possible work because the Rust code will still be generated by service_crategen - the only thing that will need to change is the path at which service_crategen loads the definition JSON file.
Tasks:

[x] File this issue to get Rusoto maintainers' sign off on how I plan to do this.
[x]  Generate service.json file for CodeDeployCommands service. This is actually already done, you can see the definition in the CodeDeploy agent repository (in that repo, its used for a Ruby SDK).
[x] Decide on new location in Rusoto repository to store non-botocore services in, and copy the service.json file for the new service there.
[x] Update service_crategen to know to check the new location as well as existing botocore location.
[x] Generate the new service.
[x] Testing

I've got service_crategen working with what I'm calling "embedded" services - feedback on name welcome.

Added an integration test for the new generated create in this commit. Apart from some minor code cleanup, this issue is close to being ready for a pull request.

I've written an integration test in https://github.com/drake-amz/rusoto/commit/f0bfb9092786634a40ebfc3f95f8ae2c05a02782 which performs a full CodeDeploy deployment to a simulated on-premise instance. The newly generated rusoto_codedeploy_commands crate is used to poll the CodeDeploy command service in place of the standard agent.
Apart from some code cleanup, I'm pretty close to being ready to submit a pull request.

Thanks for your effort on this, the work is well executed. 👍
Can you help me understand CodeDeploy Commands (CDC) better? I've read a few official docs on it and am still not entirely sure of the use of CDC. From what I understand the CodeDeploy control plane Rusoto currently supports is used for communicating to AWS which manages state and provides information to the CodeDeploy client on machines, where the client polls to get events such as a "do a deploy."
Does CDC communicate to an intermediate service that CodeDeploy usually talks to? So CDC cuts out the middleman and can tell AWS commands to pass to the CodeDeploy agents?
I've read the nice integration test linked but am still confused as to how this fits into CodeDeploy.
Thanks!

Ping @drake-amz . Would love more info. This is an AWS service I haven't had a chance to use so I'm a bit in the dark about it. 😄

@drake-amz anything else I can provide for this?

@matthewkmayer Unfortunately since opening this issue I've left AWS, and am unable to continue working on this due to my new employer being a competitor to Amazon. I was working on rewriting the CodeDeploy agent from Ruby to Rust as a side project, and I don't expect anyone else on the team to continue the work, so feel free to close this.

Thanks for getting back to us and best wishes on your next adventure. 👍


Kernel PCA  section added to the Quantum Kernel tutorial

Summary
We added Kernel Principal Component Analysis section in the quantum kernel tutorial, which is located in docs/tutorials/03_quantum_kernel.ipynb.  We use an ad-hoc dataset and calculate a kernel matrix using ZZFeatureMap.  This approach tranlates the original features into a new space, where axes are chosen along principal components. We keep the number of dimensions and employ kernel PCA mostly for visualization purposes. It was shown that classification on the transformed dataset becomes easily tractable by linear methods, like logistic regression. We also demonstrated that gaussian kernel-based Kernel PCA models fail to make the dataset linearly separable, while the quantum kernel successfully transforms the initial dataset into a linearly separable one.
Details and comments
This section was made as a result of the QAMP project.

 Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

 Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

Pull Request Test Coverage Report for Build<PHONE_NUMBER>

0 of 0   changed or added relevant lines in 0 files are covered.
No unchanged relevant lines lost coverage.
Overall coverage remained the same at 90.892%

Totals

Change from base Build<PHONE_NUMBER>:
0.0%

Covered Lines:
3423

Relevant Lines:
3766

💛  - Coveralls

@woodsp-ibm can you please take a look at the section added? I'm happy with the content, but writing to be verified. Thanks.

@woodsp-ibm Hello, Steve! Now it should be fine. I put the table of contents at the end of that cell.


HydroServer Website:  Preview Maps Do Not Display Correctly in IE8

horsburgh[CodePlex] The preview maps on the HIS Regions, Observational Data, and GIS Data pages of the HydroServer website do not display correctly in Internet Explorer 8 unless the compatibility view is turned on. These all seem to work correctly in Firefox.

horsburgh[CodePlex] Re-opening with a status of fixed.

ravivegiraju[CodePlex] Issue has been resolved
** Closed by ravivegiraju 1/26/2011 5:51 AM

horsburgh[CodePlex] Related to Issue number 7697.


Investigate HTML Linting support

We currently recommend vscode-htmlhint which is based on htmlhint for linting html files. Since linters will need to migrate to support multiple root folders it is a good time to investigate what HTML linter we want to recommend and help migrate to multi root support.
@mrmlnc I've seen your comment https://github.com/Microsoft/vscode/issues/30209#issuecomment-321357615, what is your opinion/recommendation.
FYI @aeschli @ramya-rao-a

https://github.com/yaniswang/HTMLHint/issues/214 😞

Yeap, HTMHint seems to be mostly dead. Besides, because it does not support nor Stylelint, nor ESLint, it is problematic tool for inline CSS and JavaScript.
Few my notes here https://github.com/LotusTM/Kotsu/issues/268 might be helpful too.

There's another one here.
Not really very active either.

Closing this investigation as out of date


Viewport shifted on secondary Monitor

Description:
When rendering inside a LwjglCanvas + JFrame, the viewport gets shifted, when the secondary monitor has a different scale.

Go to the Display settings.
Change primary Monitor to 250% and secondary Monitor to 125% scaling.
When you drag the application from the primary monitor to the secondary monitor, the cross that visualizes the center
gets shifted. -> By half the screen width which might relate to the fact that 125% = 1/2 * 250%

Here is the MCVE on my main monitor:

Here is the MCVE when i drag it to the secondary monitor

MCVE:
import com.badlogic.gdx.backends.lwjgl.LwjglCanvas;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

import javax.swing.JFrame;

/**
 * This app demonstrates a bug that is currently within libGdx. It appears when you add a LwjglCanvas
 * into a JFrame.
 *
 * It was found on Windows 10. Other OS's might not be impacted, as it could be something specific
 * about windows system scaling.
 *
 * Follow the steps to reproduce:
 * 1. Main Monitor should have a Scaling of 250%
 * 2. Secondary Monitor should have a Scaling of 125%
 * 3.:
 * When the application starts on the main monitor everything looks fine.
 * When you drag it onto the second monitor the cross that marked the middle of the view
 * gets shifted to the bottom-right corner. That is half the screen width and half the screen height.
 * This would fit the scaling as 125% = 1/2 * 250%
 */
public class MinimalBugPreview extends ApplicationAdapter {

    private ShapeRenderer sr;
    private OrthographicCamera camera;

    public MinimalBugPreview() {
        JFrame frame = new JFrame();
        frame.setSize(1024,768);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        LwjglCanvas lwjglCanvas = new LwjglCanvas(this);

        frame.getContentPane().add(lwjglCanvas.getCanvas());
        frame.setVisible(true);
    }

    @Override
    public void create() {
        //just create some utilities to visualize the issue
        camera = new OrthographicCamera(1920, 1080);
        sr = new ShapeRenderer();
        sr.setColor(Color.WHITE);
    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void render() {
        //just render a cross through the middle of the viewport
        sr.setProjectionMatrix(camera.combined);
        sr.begin(ShapeRenderer.ShapeType.Filled);
        sr.setColor(1.f, 1.f, 1.f, 1.f);
        sr.rect(-100, -2, 200, 4);
        sr.rect(-2, -100, 4, 200);
        sr.end();
    }

    @Override
    public void dispose() {
        //release the Shape Renderer
        sr.dispose();
    }
}

Tested in Version:
1.10.0
Affected Platforms:

[x] Windows (verified/tested)
[ ] Linux        (n.a.)
[ ] MacOS     (n.a.)

Summary:
I just tested a bit more and found out, that in fact my MCVE isn't even needed, as you can replicate the bug in libGdx's ParticleEditor. As you can see the particle preview is also in the bottom right corner:

It would be great if this bug could be fixed.
Keep up the great work!

It's unlikely this will ever be fixed, as LWJGL2 has reached EOL. You can try running with LWJGL3, but may need to do something special to get it working with AWT/Swing. You might try:
https://github.com/LWJGLX/lwjgl3-awt

It's unlikely this will ever be fixed, as LWJGL2 has reached EOL. You can try running with LWJGL3, but may need to do something special to get it working with AWT/Swing. You might try:
https://github.com/LWJGLX/lwjgl3-awt

Thanks for your reply. Does that also mean that down the road the existing LwjglCanvas will be deprecated & removed in future versions of libGdx?
LWJGL2 currently fits my requirements. Then I may just write a workaround, to find out on which monitor the JFrame is on and how the camera has to be transformed. Offscreenrendering might be a possibility too, if it doesn't impact the performance too much.

There is PR #6247 for a lwjgl3 awt canvas

I use LWJGL2 in Spine, so I'd like to see it continue to work. Maybe someday I'll change to LWJGL3, but that's a lot of work. If LWJGL2 is removed, the old code will continue to work the same and could just be extracted from libgdx and hosted elsewhere or locally.
Oh, you might try -Dsun.java2d.uiScale=1 and see if it solves your problem. You may then need to scale any AWT/Swing UI you use, if any, or at least set the font sizes appropriately. I use this so I don't forget:
AffineTransform transform = lwjglFrame.getGraphicsConfiguration().getDefaultTransform();
if (transform.getScaleX() != 1 || transform.getScaleY() != 1)
	throw new RuntimeException("Invalid Swing DPI scale! Use: -Dsun.java2d.uiScale=1");

There is PR #6247 for a lwjgl3 awt canvas

Thanks for the info. That would be fabulous, if the pull request would make it into the master some day.


Traffic between Control plane and Cluster VM

Looks like when creating cluster, a VM with public IP address is created in the public subnet, how does Control plane communicate with these cluster VMs? Is that through public internet? If so is it possible to make the traffic private?

Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: 93bd5c16-e0ec-5064-9bc0-1c527c328a7e
Version Independent ID: 5342d01e-c2da-f7a8-d22e-86995a17af79
Content: Deploy Azure Databricks in your Azure virtual network (VNet injection) - Azure Databricks
Content Source: databricks/administration-guide/cloud-configurations/azure/vnet-inject.md
Service: azure-databricks
GitHub Login: @mamccrea
Microsoft Alias: mamccrea

@CharmanderJieniJieni  Thanks for the question! We are investigating and will update you shortly.

I hope this information has been helpful. I will now proceed to close this issue. Please reopen the issue if you have any additional questions.
#please-close


Production build fails on 8.1.0

Bug report
Describe the bug
Since trying to use 8.1.0, I can no longer perform a production build. It seems that during build, Next.js is actually importing and running the code for my pages – not simply trying to compile them. This is impossible to do in a build step, since some of my components depend on some environmental setup performed in our custom server. If that setup isn't performed, then config properties we expect to exist will not have been loaded.
Thus, the build exits with an error that could only occur if it's actually importing my runtime code.
Expected behavior
Next.js should not try to actually execute my app code during build.
System information

OS: macOS
Version of Next.js: 8.1.0

I`ve met the same problem, it seems like dynamic srr:false not working.
eventhough I set like this
const Video = dynamic(() => import('./video'), {
  ssr: false,
  loading: () => <Loading />,
})

it still caused error
ReferenceError: window is not defined
    at Object.<anonymous> (/xxxxx/index.js:1:260)

I'm getting such error on<EMAIL_ADDRESS>(caused by using dynamic import):
I logged chunk id, it is 0 (zero)
(node:28924) UnhandledPromiseRejectionWarning: TypeError: Data must be a string or a buffer
at Hash.update (crypto.js:99:16)
at ids.forEach.id (/node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:30:41)
at Array.forEach ()
at compilation.hooks.beforeChunkIds.tap.chunks (/node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:30:25)
at SyncHook.eval [as call] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:19:10), :7:1)
at SyncHook.lazyCompileHook (/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeTree.callAsync.err (/node_modules/webpack/lib/Compilation.js:1275:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/node_modules/tapable/lib/Hook.js:154:20)
at Compilation.seal (/node_modules/webpack/lib/Compilation.js:1244:27)
(node:28924) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:28924) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 7.43s.

I'm getting such error on<EMAIL_ADDRESS>(caused by using dynamic import):
I logged chunk id, it is 0 (zero)
(node:28924) UnhandledPromiseRejectionWarning: TypeError: Data must be a string or a buffer
at Hash.update (crypto.js:99:16)
at ids.forEach.id (/node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:30:41)
at Array.forEach ()
at compilation.hooks.beforeChunkIds.tap.chunks (/node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:30:25)
at SyncHook.eval [as call] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:19:10), :7:1)
at SyncHook.lazyCompileHook (/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeTree.callAsync.err (/node_modules/webpack/lib/Compilation.js:1275:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/node_modules/tapable/lib/Hook.js:154:20)
at Compilation.seal (/node_modules/webpack/lib/Compilation.js:1244:27)
(node:28924) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:28924) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 7.43s.

I removed dynamic import part but I also get this problem; how to resolve it, thanks

Had similar issue with UnhandledPromiseRejectionWarning messages. Not sure which patch fixed it but if you install the latest canary version it seems to run as expected.

Can confirm that 8.1.1-canary.34 fixes my issue with UnhandledPromiseRejectionWarning: TypeError: Data must be a string or a buffer during production builds.


Fix/extend INTERVAL, TIMESTAMP(TZ), DATE and TIME

Background: https://airtable.com/tblD3oZPLJgGhCmch/viw5Jsp2TrY3it9Yr/recvfLqLfmKdeQpfL
PM: @awoods187
Eng: @knz

Related:

INTERVAL uses microseconds (not nanoseconds): #4375

in https://www.cockroachlabs.com/docs/v2.1/interval.html#main-content we see an output of:
SELECT * FROM intervals;
+---+------------------+
| a |        b         |
+---+------------------+
| 1 | 1h2m3.004005006s |
| 2 | 14m3d4h5m6s      |
| 3 | 14m3d4h5m6s      |
+---+------------------+
(3 rows)

In master (v19.1.0-beta.20190304-458-g70e3468), I see:
root@localhost:26257/tpcc> SELECT * FROM intervals;
  a |               b
+---+-------------------------------+
  1 | 01:02:03.004005
  2 | 1 year 2 mons 3 days 04:05:06
  3 | 1 year 2 mons 3 days 04:05:06
(3 rows)

Time: 3.590604ms

The commit that you link to is mainly about improving our compatibility with documented date-time formats.
@mjibson did remove support for nanosecond-precision intervals in https://github.com/cockroachdb/cockroach/pull/34202 , changing it to be more in line with pgsql's microsecond precision.  That one could have some user-visible impact if someone is relying on maintaining nanosecond values in cockroach.

@mjibson did remove support for nanosecond-precision intervals in cockroachdb/cockroach#34202 , changing it to be more in line with pgsql's microsecond precision. That one could have some user-visible impact if someone is relying on maintaining nanosecond values in cockroach.

Ok cool, we already documented that change in https://github.com/cockroachdb/docs/pull/4432.  Thanks Bob!
In that case I will close this issue since (AFAICT) it is a broad compatibility item from the roadmap that does not have specific docs impact.
@knz or @awoods187 please shout if you disagree and I'll re-open

makes sense to me


Update console version to 2.9.33

$subject

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/7055901062
Status: failure


get() is including extra object path information in the local path after upgrading to version 2023.3.0

After upgrading from 2022.11.0 to 2023.3.0, I am seeing different behavior when copying a list of remote paths to a local directory via get. Specifically, it seems to be including extra object path data in the final local path (looks like only one level up).
As an example, assume I am copying a set of files to local.
import os

import s3fs

remote_objs_to_copy = [
    "s3://my-bucket/path/to/some_data/data1.parquet",
    "s3://my-bucket/path/to/some_data/data2.parquet",
]
target_local_dir = "/tmp/testing_s3fs/"

s3fs.S3FileSystem(...).get(remote_objs_to_copy, target_local_dir)

Running os.listdir(target_local_dir).
v2022.11.0 returns:
["/tmp/testing_s3fs/data1.parquet", "/tmp/testing_s3fs/data2.parquet"]
v2023.3.0 returns:
[some_data]
Listing files under some_data, os.listdir(f"{target_local_dir}/some_data"), I do see the files.

I cannot reproduce this, see new PR (https://github.com/fsspec/s3fs/pull/718) that behaves as expected, i.e. does not include an extra directory.
@gmweaver:

Can you post your pip list or conda list to confirm that you have consistent versions of fsspec and s3fs installed?
Your v2022.11.0 listing in your original post is of the s3 filesystem not the local one. Can you check this please.

We use pip-compile and the generated requirements file has:

fsspec==2023.3.0

Apologies, that is a typo, updated initial post with correct file paths.

Can a test be added where there is an ending slash: target = os.path.join(tmpdir, "target/")

Also, tried to run the suggested test above locally, but I run into errors that look related to mocking boto/s3:
python -m venv venv
pip install -r requirements.txt -r test_requirements.txt
pytest

I see ERROR s3fs/tests/test_mapping.py::test_simple - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://<IP_ADDRESS>:5555/test"

Ah yes, my mistake. With the trailing slash on the target directory I can reproduce this, the some_data directory is created and it shouldn't be.
We've done quite a bit of work recently to ensure that cp, get and put are correct and consistent. I am reasonably sure that this is all correct for single file and single directory copying but we haven't got round to the multiple file cases yet. Evidently we don't have an explicit test for this situation and it has changed as a result of the other changes.

I have a different reproducible example for what I think is the same issue. The behavior changed between s3fs==2023.1.0 and s3fs==2023.3.0.
from pathlib import Path
import s3fs
import tempfile
fs = s3fs.S3FileSystem()

# 1. Upload files to the bucket destination.
bucket_destination = 'my-bucket/storage_test'
with tempfile.TemporaryDirectory() as tmpdir:
    output_file = Path(tmpdir) / 'file.txt'
    with output_file.open('w') as fout:
        fout.write('hi\n')
    fs.put(str(output_file), bucket_destination + '/file.txt')
    fs.put(str(output_file), bucket_destination + '/file2.txt')

# 2. Download files from the bucket destination into the current directory.
#  - With s3fs==2023.1.0, files "file1.txt" and "file2.txt" are created in "." (current directory)
#  - With s3fs==2023.3.0, files "file1.txt" and "file2.txt" are created in "./storage_test"
fs.get(bucket_destination, '.', recursive=True)

@ianthomas23 Is there any way to get the came get behaviour in s3fs=2023.6.0 as in 2023.1.0 when it comes to copying the directory tree? In the old version I could pass a list of files in different "subdirectories" on S3 and have the structure recreated locally. In the new version they are all copied to a destination directory, without maintaining the structure (which results for me in overwritten files and lost structure). I thought recursive parameter on get would maintain the structure, but that does not appear to be the case.
Is there a way I can copy multiple files at once with 2023.6.0 while maintaining the source directory structure?

@tracek Copying a list of named files to a directory is working as expected (https://filesystem-spec.readthedocs.io/en/latest/copying.html#multiple-source-to-single-target). Just as with command-line cp the directory structures of the source files is irrelevant, they are all copied into the target directory. recursive makes no difference, it only affects the expansion of wildcards and directories in the source file list.
If you are copying lists of directories and or globs then it is entirely possible that it is not working correctly. If the scenario is not listed at https://filesystem-spec.readthedocs.io/en/latest/copying.html then we make no claim that it is working correctly yet.
Can you post a specific example (with code) of what you are attempting, what the outcome is and what you think it should be? And can you do so in a new issue rather than in this issue that I am about to close as it has been fixed. Thanks!

I am closing this issue as the original report is working as expected, as described at https://filesystem-spec.readthedocs.io/en/latest/copying.html.

@tracek - if you wish to copy your list of paths to specific locations, you can pass a list as the "to" path argument of the same length as the origin list. Perhaps you can create this to list with a simple comprehension
to_path = [p.replace(origin_root, out_root) for p in paths]

Thanks gentleman!
@ianthomas23 Great to know, only now I realised that reading the code & docs of fsspec is instrumental for better understanding how s3fs works. Indeed my case, i.e. multiple destinations, is not listed there.
Still, what @martindurant mentioned (thanks!) works like a charm. Not knowing this, I had to resort to bunch of async _get_file tasks. Maybe it's something worth documenting? If you think it makes sense and could use extra pair of hands, I am happy to make a PR.
BTW, is batch_size a valid parameter for get?

Maybe it's something worth documenting?

The documentation can always be better, and help is appreciated. As you can see, there are lots of possible ways to call methods, so it is tricky to present all the options and information in a coherent manner.

is batch_size a valid parameter for get?

It should be: the number of requests in flight at one time.

is batch_size a valid parameter for get?

It should be: the number of requests in flight at one time.

In my testing it did not matter if I set it batch_size=1 or batch_size=-1, I'd always get unthrottled version (evidenced by all files created and downloaded at the same time). Initially I thought of raising an issue, but then it's not documented in s3fs docs, so hardly an issue in itself.
I understand the need for concise docs. Thanks for help!


Support default working-directory option

See: https://github.com/c-hive/gha-npm-cache/issues/9#issuecomment-912520930
For now, the directory option works as well.

Closing, this functionality is now part of actions/setup-node.


Create memeber page template

Description
We need to create a template for this page  (we can use dummy data for now and get really data later on):

Screenshots
No response
Additional information
No response

I will work on this

How I can see the page? There is need to be link in the header?

In here :

@ronnahmias


Could not find rails-assets-jquery-2.2.1 in any of the sources

Interesting error starting popping up tonight:
Could not find rails-assets-jquery-2.2.1 in any of the sources
Run `bundle install` to install missing gems.

Gemfile:
source 'https://rails-assets.org' do
  gem 'rails-assets-holderjs'
  gem 'rails-assets-linkifyjs'
end

Update
It only happens with..
gem 'rails-assets-linkifyjs'

I had to run bundle update to fix this... Thoughts as to why?

Are you saying that when you ran a command inside of bundle exec (like rails or whatever), and it printed the error:
Could not find rails-assets-jquery-2.2.1 in any of the sources
Run `bundle install` to install missing gems.

Running bundle install didn't work, but bundle update did?

Correct, I had to run bundle update and then bundle install.  It was very odd...

What were the gemfile.lock versions for jquery and linkifyjs before and after?

Currently it is using:
    rails-assets-holderjs (2.9.3)
    rails-assets-jquery (2.2.1)
    rails-assets-linkifyjs (1.1.7)
      rails-assets-jquery (>= 1.9.0)

Before it was using:
rails-assets-holderjs (2.9.1)

... I am having a hard time locating the commit where I added linkifyjs

Can you give me exact steps to reproduce?
https://rails-assets.org/gems/rails-assets-jquery-2.2.1.gem
That seems to work fine, and it seems to be in the database. Since the server was moved, maybe something else happened but I can't really be sure without more steps.

Closing due to lack of feedback.

I am ok with closing, the issue has since disappeared.

Thanks, @chrishough !


pad_with_graphs written with numpy

Hello! I was wondering if there is any particular reason that the pad_with_graphs function uses the numpy library rather than the jax.numpy library. It looks like every numpy function in there can just be replaced with jax.numpy without any issues, but I could be missing something.

I was also wondering this in the past. Another piece where numpy is used/can be used is batch/batch_np. IIRC the numpy version was much faster in some situations, hinting that there is some unwanted jit compilation happening when using jnp functions. That might also be the case if the numpy functions in pad_with_graphs were replaced with jnp functions. To me it seems that in jax.numpy.sum some jit compiling is always happening, which is not what you want to happen if array sizes change. It would be nice to have some clarification on this though.


fixed export of specific content types

closing this pr, will create a pr to staging branch since we will release this as a hotfix


feat: add changelog file

Checklist:

[x] I have read freeCodeCamp's contribution guidelines.
[x] My pull request has a descriptive title (not a vague title like Update index.md)

Closes #XXXXX

IMHO, It doesn't work like that. For starters, the SemVer notation is incorrect, you want this to be automated with proper release management.

I hade no clue the change log could be automated. That is cool. It seems that I have not understood which version this should be.

No worries - The changeset tool helps with a lot of the concepts around release management. Consider taking some time to go through their concepts.

I will close this. Thanks for the tips :).


Complex Builder and JSON Performance. POJOs and Generics.

Same notes as @bodia added. I saw some minor tweaks (e.g. the timeout configs could be moved to Globals or given as parameters) but considering this is WIP we will get there eventually.
On a side note I was thinking that the builders got a little too complicated maybe?
Also it seems to me that we're digging through JSONs a little bit too much and we should rely more on POJOs and maybe generics in the future?

Yeah, I have a feeling about complex builders as well. It's convenient, but also limits the flexibility to add certain changes


[5514] - Don't show discarded users in system admin UI

Context
Discarded users show up on the system-admin/users index when searching (via the API). They can also be accessed via their show
Changes proposed in this pull request

API searches only kept users
a user is retrieved using kept when they are shown

Guidance to review

delete a non admin user and try to search for them
try accessing their show page by visiting their /system-admin/users/:id

 [s] don't show discarded users in UI


getTrackSources for undefined track

https://github.com/benwiley4000/cassette/blob/da848c2d42c471343622d25262f6ef1cc23be63e/packages/core/src/PlayerContextProvider.js#L348
I think I found another case when this can happen, we discussed it on #318. If you have a playlist with 3 tracks, and activeIndex: 2, and the playlist is changed to only have one track, it would try to access the activeIndex of the new playlist, which would be undefined and throw an error.

Good catch! Thank you.
Check out this part of static getDerivedStateFromProps:
    // the sources if we stay on the same track index
    const currentSources = getTrackSources(
      newPlaylist,
      prevState.activeTrackIndex
    );
    // non-comprehensive but probably accurate check
    if (prevSources[0].src === currentSources[0].src) {
      // our active track index already matches
      return baseNewState;
    }

I think we can wrap all of that in an if statement and if it's false then we automatically find a new activeTrackIndex afterward:
    if (newPlaylist[prevState.activeTrackIndex]) {
	    // the sources if we stay on the same track index
	    const currentSources = getTrackSources(
	      newPlaylist,
	      prevState.activeTrackIndex
	    );
	    // non-comprehensive but probably accurate check
	    if (prevSources[0].src === currentSources[0].src) {
	      // our active track index already matches
	      return baseNewState;
	    }
    }

I haven't tested this though so it's hard to be sure.
I will probably have time to deal with this sometime later this week, unless you want to submit a PR. 🙂

I'll create the PR, and test it locally


[camera] Add availableCameras() to CameraX plugin

One functionality that the camera plugin provides is allow users to query the available cameras.
Implement availableCameras() in the CameraX plugin to enable this functionality.

Done with https://github.com/flutter/plugins/pull/6945.
Just FYI @gmackall, if you use magic words like "Fixes ", it will close the issue automatically :)


Tailwind CSS Intellisense Support Missing Critical Information in the docs

I have just spent forever trying to get Tailwind CSS Intellisense to work in .templ files
I know it may sound obvious in hindsight.
In the end, turns out that I was missing the tailwind config file (tailwind.config.{js,cjs,mjs,ts}) in my project.
Please add a little note to the docs about having a tailwind config file.

@Jatin-MYST I think this is what were asking for https://github.com/a-h/templ/blob/d61470219c74a0bfc3a2a7f18f937fd943b68c30/docs/docs/09-commands-and-tools/02-ide-support.md?plain=1#L98
https://templ.guide/commands-and-tools/ide-support#tailwind-css-intellisense

@Khalid-Nowaf Not quite.
I did read the docs and did exactly what it told me.
The issue is that the docs doesn't mention to have a tailwind.config.js file in your project.
So, it didn't work for me.
After spending a long time I found out that I was missing the config file.
It worked right away after adding that file.
Having the info about the required config file in the docs will help any future devs not waste their time.

@Jatin-MYST I think this is what were asking for
https://github.com/a-h/templ/blob/d61470219c74a0bfc3a2a7f18f937fd943b68c30/docs/docs/09-commands-and-tools/02-ide-support.md?plain=1#L98
https://templ.guide/commands-and-tools/ide-support#tailwind-css-intellisense
I have a similar problem with the autocomplete for tailwind
I did what the documentation said but it didn't seem to work
am I missing something?

The issue is 3 here.  Tailwind's lsp looks for a file listed here. If it doesn't find one it doesn't know where to start.
It's not a templ specific issue but a note about this could be helpful to making sure it's easy to get going with templ. I can get around to writing it at some point.

There is a note in the docs now for the tailwind config #367

Just needs a docs PR to add an extra paragraph or note block to remind people to add the tailwind.config.js file. Happy to take a PR for it.


Element with v-model not found

This warning Element with v-model not found prints on the console when I try to watch formstate.
v-model is present on both email and password field.
watch: {
    formState (f) {
     // prints upon loading of component
     // but not whenever I type on the fields
      console.log('dirty', f.email)
      console.log('error', f.password)
    }
  },

Does it warn but everything still works? Sometimes it can give a false positive. I'll remove it in next release

Yes everything works, but not during watch event. I'm using vuetifyjs by the way, do you think there's a conflict with props?

Deep watch seems to work fine:
https://jsfiddle.net/g2enqy08/3/

@fergaldoyle It did. Thanks.


Composer binds to <IP_ADDRESS> address

Description:
Ballerina composer binding to <IP_ADDRESS> IP address which is a loopback address. Therefore the composer is not accessible from a network. Also, it is not possible to access the composer via docker container. We need to fix the composer to bind to <IP_ADDRESS>.
Steps to reproduce:

Start the ballerina composer.
Use ifconfig command to find the local IP address and try to access the console.
eg: - http://<IP_ADDRESS>:9091/

Affected Versions:
0.970.0
OS, DB, other environment details and versions:
MacOS
Related Issues (optional):
Suggested Labels (optional):
Bug
Suggested Assignees (optional):

@hemikak
You can't set "msf4j.host" as an environment variable as the variable name is not valid.
$ export msf4j.host=<IP_ADDRESS>
-bash: export: `msf4j.host=<IP_ADDRESS>': not a valid identifier

But this can be done as an argument to composer command.
composer --host <IP_ADDRESS>
Composer started successfully at http://<IP_ADDRESS>:9091

Shouldn't the default host be <IP_ADDRESS>?


Add link to content store in taxons list

It's convenient to see the content store representation for these
taxons. The content ID values aren't currently linked to anything so
let's have them point to the content store until a better alternative
emerges.

:shipit:


fixed missing system-settings references

Pull Request Type

[ ] ✨ feat
[ x] 🐛 fix
[ ] ♻ refactor
[ ] 💄 style
[ ] 🔨 chore
[ ] 📝 docs

Relevant Issues
The server project would not compile, as some of the vector database component implementations were missing a reference to the SystemSettings model.
What is in this change?
I simply added a reference to SystemSettings to all the vector database component code:
const {SystemSettings} = require("../../../models/systemSettings");

Additional Information
Add any other context about the Pull Request here that was not captured above.
Developer Validations

[x ] I ran yarn lint from the root of the repo & committed changes
[ ] Relevant documentation has been updated
[ x] I have tested my code functionality
[ x] Docker build succeeds locally

THe patch was correct but it was missing the patch for chroma as well as had some, what appeared to be, user-specific files for how you use the tool.
Happy to give a contributor badge in discord if you want one though, of course.

Yes I would like that badge.
TRAVIS JAMES: Chief Technology Officer at TribeMedia.io
https://www.tribemedia.io
phone:<PHONE_NUMBER>
web: www.tribemedia.io
twitter: @GQAdonisCTO http://twitter.com/GQAdonisCTO
On Sun, Apr 7, 2024 at 4:42 PM Timothy Carambat @.***>
wrote:

THe patch was correct but it was missing the patch for chroma as well as
had some, what appeared to be, user-specific files for how you use the tool.
Happy to give a contributor badge in discord if you want one though, of
course.
—
Reply to this email directly, view it on GitHub
https://github.com/Mintplex-Labs/anything-llm/pull/1064#issuecomment-2041618038,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAYU7RBIPLXJ5O2PCYMN6DY4G4THAVCNFSM6AAAAABF3OHWNKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGYYTQMBTHA
.
You are receiving this because you authored the thread.Message ID:
@.***>

I dont know your discord handle, what is it? You can also @ me in the discord

It is @babyice6818!  I sent you a message.
TRAVIS JAMES: Chief Technology Officer at TribeMedia.io
https://www.tribemedia.io
phone:<PHONE_NUMBER>
web: www.tribemedia.io
twitter: @GQAdonisCTO http://twitter.com/GQAdonisCTO
On Mon, Apr 8, 2024 at 10:43 AM Timothy Carambat @.***>
wrote:

I dont know your discord handle, what is it? You can also @ me in the
discord
—
Reply to this email directly, view it on GitHub
https://github.com/Mintplex-Labs/anything-llm/pull/1064#issuecomment-2043090409,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAYU7QU4675BZJ347C4EQDY4K3IZAVCNFSM6AAAAABF3OHWNKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBTGA4TANBQHE
.
You are receiving this because you authored the thread.Message ID:
@.***>


[$1000] Chat - SMS domain shown in mentions

If you haven’t already, check out our contributing guidelines for onboarding and email<EMAIL_ADDRESS>to request to join our Slack channel!

Action Performed:

Have some previous chats with phone number
Go to any chat
Start mentioning phone number

Expected Result:
Phone number alone should be shown
Actual Result:
Phone number is shown with expensify sms domain
Workaround:
Unknown
Platforms:

Which of our officially supported platforms is this issue occurring on?

[ ] Android / native
[ ] Android / Chrome
[ ] iOS / native
[ ] iOS / Safari
[x] MacOS / Chrome / Safari
[x] MacOS / Desktop

Version Number: <IP_ADDRESS>
Reproducible in staging?: yes
Reproducible in production?: yes
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Expensify/Expensify Issue URL:
Issue reported by: @abdulrahuman5196
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1686239745633599
View all open jobs on GitHub
Upwork Automation - Do Not Edit

Upwork Job URL: https://www.upwork.com/jobs/~01180378586a3144b1
Upwork Job ID:<PHONE_NUMBER>669092352
Last Price Increase: 2023-06-16

Proposal
Please re-state the problem that we are trying to solve in this issue.
SMS domain shown in mentions
What is the root cause of that problem?
We are not removing the sms domain from the alternetText here.
https://github.com/Expensify/App/blob/38fe17f8a299692966777a53f1b305419d8384c2/src/pages/home/report/ReportActionCompose.js#L465
What changes do you think we should make in order to solve the problem?
Call removeSMSDomain here from the alternetText with Str.removeSMSDomain(detail.login)
https://github.com/Expensify/App/blob/38fe17f8a299692966777a53f1b305419d8384c2/src/pages/home/report/ReportActionCompose.js#L465

Couple of proposals ready for review @Santhosh-Sellavel

@bfitzexpensify I'll post my review comments tomorrow. Need to check this further.

@tienifr's Proposal here look good to me. Both proposals are mostly similar, but @tienifr's proposal mentioned the highlighting of the phone number which will be missing, so we should go with them.

(Optional) In case we want to completely eliminate the SMS domain while searching for mentions as in the above proposal, we need to remove SMS domain from detail.login here too:

I think we need to exclude the results while searching with SMS domain
C+ Reviewed
🎀 👀 🎀

@puneetlath can you check this please? It has to do with mentions (and some of it came from https://github.com/Expensify/App/pull/19221)

This isn't really a bug. This is how it will have to be until we implement handles.


The title conditions

Is there any good reson why some things are only shown if there is a title set?
https://github.com/TheDahoom/Sveltekit-seo/blob/bcc9433a15e5a93f29ee8f47cee1757c9f22886f/SEO.svelte#L28-L36
To me, it would make more sense if it looked like this:
<!-- Only the tilte is depending on the title to be set -->
{#if title !== ""}
    <title>{title}</title>
{/if}

<!-- This should not be dependent on the title -->
{#if imageURL}
    <meta name="robots" content={index ? "index, follow, max-image-preview:large" : "noindex"}>
{:else}
    <meta name="robots" content={index ? "index, follow" : "noindex"}>
{/if}

<!-- This should defineltey not be dependent on the title -->
<link rel="canonical" content="{canonical === '' ? $page.url : canonical}">

The plan is for <SEO> to be reusable across multiple components/pages. The title element is like a buffer so that when reusing SEO for different elements, the  and  tag isn't duplicated multiple times with it.
I attempted to add javascript checks to have this more streamlined but that broke either ssr or prerendered pages, cant remember which to be honest. I also tried a bunch of other ideas but nothing worked without breaking something else. I found using this modular approach to be best for now.
If you have any ideas to fix the duplication issue I'd love to give them a shot.


[Messages] The value "NULL" is displayed next to the first and last name in the "Повідомлення" tab.

Environment: Windows 10, 64-bit, Google Chrome 107.0.5304.107.
Reproducible: always.
Preconditions
1.Follow the link https://oos.dmytrominochkin.cloud/#/
2.Log into system as a Parent (e.g<EMAIL_ADDRESS>'Password'="Qazwsx789!").
3.Parent has some messages in his chat.
4.When registering the Parent, the "По-батькові" field was not filled in.
Steps to reproduce

Go to the "Повідомлення" tab of personal cabinet by clicking "Мої повідомлення" button on the top right corner drop down list.
Pay attention to the Parent`s full name.

Actual result
The value "NULL" is displayed next to the first and last name in the "Повідомлення" tab.

Expected result
If there are no data "По-батькові" field, the value "NULL" is not displayed next to the name and surname in the "Повідомлення" tab.
User story and test case links
E.g.: "User story #242
[Test case](#242 Story)"
Labels to be added
"Bug", Priority ("medium"), Severity ("low"), Type ("UI").

Might be fixed, can't reproduce


Recurrent Neural Network

@KacheFlowe @joobei  Hey guys, sorry for my apparent lack of communication over the last little while.    Definitely haven't left Swift AI behind though, and in fact it's finally made its way back up my priority list.
It's been some time since we've discussed Recurrent Neural Networks - any progress or thoughts from you guys?  I've decided that it's the next component I want to tackle, partly because it would be particularly useful for some side projects that I have in mind.  I definitely don't want to duplicate any effort that people have already made, if any, so I'd love to hear what you guys think about the idea.

Hey Colin. I've Ben working on this but I've been quiet because of been
applying to jobs. We can tag team if you'd like. I've been working on an
actual demo that makes use of NLP.
On Monday, May 2, 2016, Collin Hundley<EMAIL_ADDRESS>wrote:

@KacheFlowe https://github.com/KacheFlowe @joobei
https://github.com/joobei Hey guys, sorry for my apparent lack of
communication over the last little while.  Definitely haven't left Swift AI behind
though, and in fact it's finally made its way back up my priority list.
It's been some time since we've discussed Recurrent Neural Networks - any
progress or thoughts from you guys? I've decided that it's the next
component I want to tackle, partly because it would be particularly useful
for some side projects that I have in mind. I definitely don't want to
duplicate any effort that people have already made, if any, so I'd love to
hear what you guys think about the idea.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/collinhundley/Swift-AI/issues/50

@KacheFlowe Awesome, NLP is exactly what I want to do with it.  I won't be able to put quite the full-time effort into this as I was before, so don't worry about being busy.  We all have normal lives too.

Perfect. Sounds like we're on the same page. Originally I wanted to build
it from the ground up but I may have to make use of NSLinguistic. We'll
see!
On Monday, May 2, 2016, Collin Hundley<EMAIL_ADDRESS>wrote:

@KacheFlowe https://github.com/KacheFlowe Awesome, NLP is exactly what
I want to do with it. I won't be able to put quite the full-time effort
into this as I was before, so don't worry about being busy. We all have
normal lives too.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/collinhundley/Swift-AI/issues/50#issuecomment-216410160

NSLinguisticTagger might be our best option on iOS/OS X.  I would have preferred a custom solution that could be ported to Linux, but the current state of Swift on Linux is shaky at best so I'd be more inclined to just build it for iOS/OS X now and port it later when needed.  Some ideas I have in mind would probably need to be trained on AWS, but I can just make due with a Mac for now.

Hi guys, sorry if this is not the place for this comment. I am looking around for an open source project to get involved with and this one looks pretty cool. I don't know too much about swift but would love to learn, I do know a bit about machine learning though. Do you guys have any suggestions/recommendations on getting involved?

@AusCoder Hi, we always appreciate more help. What kind of experience do you have with machine learning? As mentioned in this thread, the next component of Swift AI that I'd like to complete is a recurrent neural network - so if you have any knowledge in that area, it would be particularly useful right now.  But I'm also open to working on other components like a convolutional network, genetic algorithms, adding support for deep learning, GPU acceleration, etc.
To familiarize yourself with this library, I'd recommend reading the docs here and checking out the demo app for a fun little example of what the feed-forward neural network can do.
For Swift itself, I'd highly recommend reading The Swift Programming Language.  It's no romance novel, but there's probably no better resource for learning the language.

@collinhundley In terms of machine learning: I have done the Coursera machine learning course and have implemented a couple of the algorithms from that course. I'd love you help out with the recurrent neural network, if I can somehow. Do you guys plan out who will write certain pieces of code?
Thanks for the recommendations with the docs and the Swift reference. I'll have a look at them.

There doesn't seem tp be a written plan. Seems like we just work on it as
we go. Would you like to plan a meetup with me, Sebastian? I could
certainly use your brains! ka c h e @ g m a i l    .c o m
ᐧ
On Tue, May 3, 2016 at 12:37 PM, Sebastian Mueller<EMAIL_ADDRESS>
wrote:

@collinhundley https://github.com/collinhundley In terms of machine
learning: I have done the Coursera machine learning course and have
implemented a couple of the algorithms from that course. I'd love you help
out with the recurrent neural network, if I can somehow. Do you guys plan
out who will write certain pieces of code?
Thanks for the recommendations with the docs and the Swift reference. I'll
have a look at them.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/collinhundley/Swift-AI/issues/50#issuecomment-216624239

I'd love to be involved with that as well, so I don't end up duplicating anybody's work.  My email is in the main readme if you guys wanna do a group message.

I can dig it.
ᐧ
On Tue, May 3, 2016 at 1:19 PM, Collin Hundley<EMAIL_ADDRESS>wrote:

I'd love to be involved with that as well, so I don't end up duplicating
anybody's work. My email is in the main readme if you guys wanna do a group
message.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/collinhundley/Swift-AI/issues/50#issuecomment-216636564

I sent you guys an email. @KacheFlowe it wouldn't deliver to your email address, however.

<EMAIL_ADDRESS>with a lowercase.
On Tuesday, May 3, 2016, Sebastian Mueller<EMAIL_ADDRESS>wrote:

I sent you guys an email. @KacheFlowe https://github.com/KacheFlowe it
wouldn't deliver to your email address, however.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/collinhundley/Swift-AI/issues/50#issuecomment-216654573

maybe this use case / story telling from images would be interesting to tackle for show casing this ai library.  https://github.com/ryankiros/neural-storyteller

Guys I have been busy with some other projects but I'm interested in returning to this. Any progress?

There is--I exist.

Old conversation. See #60

Kind of late here, but what I want to accomplish is doing inference BUT especially also training of a RNN on iOS! Seems like what you guys are building is closest to this. All other libraries are only for inference and not training :/
Any progress? Is it a secret repo? :-p. Would love to contribute/stay in the loop.
Love.

Hey @JoeriBultheel, I don't have an RNN version, but I used Swift-AI's version of FNN to do training and classification on iOS (iPhone 6s) for a project called Swift-HAR. Not sure if it's something you can use, but I figured I'd throw it out there.

@Aneapiy Thnx!
Actually I found this other project https://github.com/jordenhill/Birdbrain which is closer to what I want to achieve. I love swift-ai's code a lot though, would be nice to see an RNN implementation in the future.


fix(eslint): Fixed lint problem about the JSXNode

Overview
I have fixed the lint issue about the serialization of th JSXNode (reported #5940)
Here is the reproduction of the issue. This code crashes.
https://stackblitz.com/edit/qwik-starter-ptzf8r?file=src%2Froutes%2Findex.tsx

What is it?

[ ] Feature / enhancement
[x] Bug
[ ] Docs / tests / types / typos

Description
It was needed to check the symbol name if it is the JSXNode before checking of the callable things
in order to avoid to be checked the internal structures of JSXNode and being kicked out.
Use cases and why

Relating #5940
Checklist:

[x] My code follows the developer guidelines of this project
[x] I have performed a self-review of my own code
[ ] I have made corresponding changes to the documentation
[x] Added new tests to cover the fix / functionality

can you run pnpm api.update so it doesn't have the api changes? Those get added by the build somewhere and we don't know why.

@wmertens
I have misunderstood about the order of execution of tasks api.update and build.full that was api.update then build.full. But the right way was inverse.
Now I did it.


Update mac setup

This requires further testing with Alan, but once done we can merge this into main to publish these setup docs. Thanks for all your help!

@simonrjones Please could we add https://imageoptim.com/mac as a mandatory download for the Dev team? Developers should be using this to optimise image assets. Thanks!

Yes sure @NicolaSaunders - looks like it can be installed via Homebrew: https://formulae.brew.sh/cask/imageoptim#default
Are devs supposed to use on this on the command-line? Would be useful for something on this to be added to the front-end standards Marie is working on.

@simonrjones Not via the command line, no. I call it up via Alfred as the app and drag files to it.
We used to have it in our NPM build scripts but it was removed as there were far too many vulnerabilities. Amplify notes that devs are expected to optimise images manually now and not via the command line.


x/mobile: Multiple warnings when running "go get github.com/golang/mobile/..."

The second GL-related errors are probably because your linux installation is missing the relevant GLES packages. See https://github.com/golang/mobile/blob/master/app/x11.go#L15

Thanks.

@crawshaw I tried second suggestion but still getting same error.

what command did you run? please use golang.org/x/mobile,
not github.com/golang/mobile
On Thu, Sep 17, 2015 at 3:05 PM, Degendra Sivakoti<EMAIL_ADDRESS>
wrote:

@crawshaw https://github.com/crawshaw I tried second suggestion but
still getting same error.
—
Reply to this email directly or view it on GitHub
https://github.com/golang/go/issues/12457#issuecomment-141190952.

--
__

@hyangah I was following https://github.com/golang/go/wiki/Mobile tutorial and executed gomobile install golang.org/x/mobile/example/basic. I was able to install apk in my device but when i run it, i only see black screen. Same thing for audio and network example.
I was getting "work.h:6:23: fatal error: GLES2/gl2.h: No such file or directory" error when i was executing go install golang.org/x/mobile/example/basic

@degendra See https://github.com/golang/mobile/blob/master/app/x11.go#L15

@ip I tried that option already and it was not working. Now it's working. Thank you.
I am still having problem with mobile. I am only getting black screen. It might be the problem with my device.  Thank you @hyangah as well for your time.


Eager for the windows version of inplace_abn!!!

If I want to use inplace_abn in windows environment, how should I do? Please!!!

You got solutions now?


iree/test/e2e/regression/dynamic_add.mlir.test test hangs on windows

ctest -R iree/test/e2e/regression/dynamic_add.mlir.test -V
UpdateCTestConfiguration  from :D:/temp/iree/tests/DartConfiguration.tcl
UpdateCTestConfiguration  from :D:/temp/iree/tests/DartConfiguration.tcl
Test project D:/temp/iree/tests
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 50
    Start 50: iree/test/e2e/regression/dynamic_add.mlir.test

50: Test command: D:\temp\iree\tests\bin\run_lit.bat "iree/test/e2e/regression/dynamic_add.mlir"
50: Test timeout computed to be: 10000000
50: Running test command:
50: iree-run-mlir -export-all -iree-hal-target-backends=vmla -function-input="2x4xf32=[[1.0, 2.0, 3.0, 4.0], [-1.0, -2.0, -3.0, -4.0]]" -function-input="2x4xf32=[[5.0, 6.0, 7.0, 8.0], [-5.0, -6.0, -7.0, -8.0]]" iree/test/e2e/regression/dynamic_add.mlir | IreeFileCheck iree/test/e2e/regression/dynamic_add.mlir

This is because of the spaces in the -function-input and our insanity of bash>cmd>powershell>cmd>bash>bash>etc nesting where at least one of them is not escaping correctly. If you remove the spaces from the -function-input it'll pass. We need to remove a few layers of run_test scripts, ensure the ones remaining escape, and then hopefully kill a lot of the non-check test lit-based tests :P

This is because of the spaces in the -function-input and our insanity of bash>cmd>powershell>cmd>bash>bash>etc nesting where at least one of them is not escaping correctly. If you remove the spaces from the -function-input it'll pass. We need to remove a few layers of run_test scripts, ensure the ones remaining escape, and then hopefully kill a lot of the non-check test lit-based tests :P

So what I'm hearing you say is that we need more python? :)
On Thu, Jan 28, 2021, 9:30 AM Ben Vanik<EMAIL_ADDRESS>wrote:

This is because of the spaces in the -function-input and our insanity of
bash>cmd>powershell>cmd>bash>bash>etc nesting where at least one of them is
not escaping correctly. If you remove the spaces from the -function-input
it'll pass. We need to remove a few layers of run_test scripts, ensure the
ones remaining escape, and then hopefully kill a lot of the non-check test
lit-based tests :P
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/google/iree/issues/4637#issuecomment-769249168, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AADYVABKGGEWHFT6STZIUI3S4GNKTANCNFSM4WWSPGNQ
.

So what I'm hearing you say is that we need more python? :)
On Thu, Jan 28, 2021, 9:30 AM Ben Vanik<EMAIL_ADDRESS>wrote:

This is because of the spaces in the -function-input and our insanity of
bash>cmd>powershell>cmd>bash>bash>etc nesting where at least one of them is
not escaping correctly. If you remove the spaces from the -function-input
it'll pass. We need to remove a few layers of run_test scripts, ensure the
ones remaining escape, and then hopefully kill a lot of the non-check test
lit-based tests :P
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/google/iree/issues/4637#issuecomment-769249168, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AADYVABKGGEWHFT6STZIUI3S4GNKTANCNFSM4WWSPGNQ
.

;P

;P


Error running npm install

I think it's related to this:
https://github.com/EyalAr/lwip/issues/263

I will investigate changing the lwip library for something else and update progress here.

Published 1.0.19 to remove lwip.


convert ERB templates to EPP

rebase against #1396 after merge

You are thinking of a block like these right?

Yes exactly.