Posts

Showing posts from October, 2011

Copy Paste Values Only( XlPasteValues )

Answer : If you are wanting to just copy the whole column, you can simplify the code a lot by doing something like this: Sub CopyCol() Sheets("Sheet1").Columns(1).Copy Sheets("Sheet2").Columns(2).PasteSpecial xlPasteValues End Sub Or Sub CopyCol() Sheets("Sheet1").Columns("A").Copy Sheets("Sheet2").Columns("B").PasteSpecial xlPasteValues End Sub Or if you want to keep the loop Public Sub CopyrangeA() Dim firstrowDB As Long, lastrow As Long Dim arr1, arr2, i As Integer firstrowDB = 1 arr1 = Array("BJ", "BK") arr2 = Array("A", "B") For i = LBound(arr1) To UBound(arr1) Sheets("Sheet1").Columns(arr1(i)).Copy Sheets("Sheet2").Columns(arr2(i)).PasteSpecial xlPasteValues Next Application.CutCopyMode = False End Sub since you only want values copied, you can pass the values of arr1 directly to arr2 and avoid c

Convert HSV To Grayscale In OpenCV

Answer : The conversion from HSV to gray is not necessary: you already have it. You can just select the V channel as your grayscale image by splitting the HSV image in 3 and taking the 3rd channel: Mat im = imread("C:/local/opencv248/sources/samples/c/lena.jpg", CV_LOAD_IMAGE_COLOR); Mat imHSV; cvtColor(im, imHSV, CV_BGR2HSV); imshow("HSV", imHSV); //cvtColor(imHSV, imHSV, CV_BGR2GRAY); Mat hsv_channels[3]; cv::split( imHSV, hsv_channels ); imshow("HSV to gray", hsv_channels[2]); imshow("BGR", im); cvtColor(im, im, CV_BGR2GRAY); imshow("BGR to gray", im); waitKey(); hsv1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2HSV) h, s, v1 = cv2.split(hsv1) cv2.imshow("gray-image",v1)

Flex Stretch Items Height Code Example

Example: flexbox stretch height .flex-2 { display : flex ; align-items : stretch ; }

C Char Array Initialization

Answer : This is not how you initialize an array, but for: The first declaration: char buf[10] = ""; is equivalent to char buf[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; The second declaration: char buf[10] = " "; is equivalent to char buf[10] = {' ', 0, 0, 0, 0, 0, 0, 0, 0, 0}; The third declaration: char buf[10] = "a"; is equivalent to char buf[10] = {'a', 0, 0, 0, 0, 0, 0, 0, 0, 0}; As you can see, no random content: if there are fewer initializers, the remaining of the array is initialized with 0 . This the case even if the array is declared inside a function. Edit: OP (or an editor) silently changed some of the single quotes in the original question to double quotes at some point after I provided this answer. Your code will result in compiler errors. Your first code fragment: char buf[10] ; buf = '' is doubly illegal. First, in C, there is no such thing as an empty char . You can use double quote

Can A Js Script Get A Variable Written In A EJS Context/page Within The Same File

Answer : Edit : this Half considers you are using EJS on server side 1) You can pass an ejs variable value to a Javascript variable <% var test = 101; %> // variable created by ejs <script> var getTest = <%= test %>; //var test is now assigned to getTest which will only work on browsers console.log(getTest); // successfully prints 101 on browser </script> simply create an ejs variable and assign the value inside the script tag to the var getTest Ex: var getTest = <%= test %>; 2) You can't pass an javascript variable value to a ejs variable Yes, you cant: if it is on server. Why: The EJS template will be rendered on the server before the Javscript is started execution(it will start on browser), so there is no way going back to server and ask for some previous changes on the page which is already sent to the browser. Edit : this Half considers you are using EJS on Client

Textarea Resize: None Code Example

Example 1: disable textarea resize textarea { /* for all text* area elements */ resize : none ; } #foo { /* for particular id */ resize : none ; } Example 2: textarea resize off <textarea class="myTextArea" > </textarea > <style > .myTextArea { resize : none ; } </style> Example 3: textarea disable resize <textarea style= "resize: none;" ></textarea>

Amazon S3 Console: Download Multiple Files At Once

Image
Answer : It is not possible through the AWS Console web user interface. But it's a very simple task if you install AWS CLI. You can check the installation and configuration steps on Installing in the AWS Command Line Interface After that you go to the command line: aws s3 cp --recursive s3://<bucket>/<folder> <local_folder> This will copy all the files from given S3 path to your given local path. If you use AWS CLI, you can use the exclude along with --include and --recursive flags to accomplish this aws s3 cp s3://path/to/bucket/ . --recursive --exclude "*" --include "things_you_want" Eg. --exclude "*" --include "*.txt" will download all files with .txt extension. More details - https://docs.aws.amazon.com/cli/latest/reference/s3/ Selecting a bunch of files and clicking Actions->Open opened each in a browser tab, and they immediately started to download (6 at a time).

CSS Transform Skew

Answer : .red.box { background-color: red; transform: perspective( 600px ) rotateY( 45deg ); } Then HTML: <div class="box red"></div> from http://desandro.github.com/3dtransforms/docs/perspective.html I think you mean webkit transform.. please check this URL out http://www.the-art-of-web.com/css/3d-transforms/ it could help you. CSS: #box { width: 200px; height: 200px; background: black; position: relative; -webkit-transition: all 300ms ease-in; } #box:hover { -webkit-transform: rotate(-180deg) scale(0.8); } #box:after, #box:before { display: block; content: "\0020"; color: transparent; width: 211px; height: 45px; background: white; position: absolute; left: 1px; bottom: -20px; -webkit-transform: rotate(-12deg); -moz-transform: rotate(-12deg); } #box:before { bottom: auto; top: -20px; -webkit-transform: rotate(12deg); -moz-transform: rotate(12deg); }​ HTML: <div

Can Google Mock A Method With A Smart Pointer Return Type?

Answer : A feasible workaround for google mock framework's problems with non (const) copyable function arguments and retun values is to use proxy mock methods. Suppose you have the following interface definition (if it's good style to use std::unique_ptr in this way seems to be more or less a philosophical question, I personally like it to enforce transfer of ownership): class IFooInterface { public: virtual void nonCopyableParam(std::unique_ptr<IMyObjectThing> uPtr) = 0; virtual std::unique_ptr<IMyObjectThing> nonCopyableReturn() = 0; virtual ~IFooInterface() {} }; The appropriate mock class could be defined like this: class FooInterfaceMock : public IFooInterface { public: FooInterfaceMock() {} virtual ~FooInterfaceMock() {} virtual void nonCopyableParam(std::unique_ptr<IMyObjectThing> uPtr) { nonCopyableParamProxy(uPtr.get()); } virtual std::unique_ptr<IMyObjectThing> nonCopyableReturn() { r

Convert A Python UTC Datetime To A Local Datetime Using Only Python Standard Library?

Answer : In Python 3.3+: from datetime import datetime, timezone def utc_to_local(utc_dt): return utc_dt.replace(tzinfo=timezone.utc).astimezone(tz=None) In Python 2/3: import calendar from datetime import datetime, timedelta def utc_to_local(utc_dt): # get integer timestamp to avoid precision lost timestamp = calendar.timegm(utc_dt.timetuple()) local_dt = datetime.fromtimestamp(timestamp) assert utc_dt.resolution >= timedelta(microseconds=1) return local_dt.replace(microsecond=utc_dt.microsecond) Using pytz (both Python 2/3): import pytz local_tz = pytz.timezone('Europe/Moscow') # use your local timezone name here # NOTE: pytz.reference.LocalTimezone() would produce wrong result here ## You could use `tzlocal` module to get local timezone on Unix and Win32 # from tzlocal import get_localzone # $ pip install tzlocal # # get local timezone # local_tz = get_localzone() def utc_to_local(utc_dt): local_dt = utc_dt.replace(tzinfo=pytz.utc).astim

C# Bootstrap Pagination In ASP.NET Gridview Pager Style?

Image
Answer : I know this is old, But I found something, which is a css style, simple easy and fast https://sufiawan.wordpress.com/2014/09/26/asp-net-use-bootstrap-pagination-on-gridview/ I hope it will save someone sometime. update: *In case the link is down: You add the CSS .pagination-ys { /*display: inline-block;*/ padding-left: 0; margin: 20px 0; border-radius: 4px; } .pagination-ys table > tbody > tr > td { display: inline; } .pagination-ys table > tbody > tr > td > a, .pagination-ys table > tbody > tr > td > span { position: relative; float: left; padding: 8px 12px; line-height: 1.42857143; text-decoration: none; color: #dd4814; background-color: #ffffff; border: 1px solid #dddddd; margin-left: -1px; } .pagination-ys table > tbody > tr > td > span { position: relative; float: left; padding: 8px 12px; line-height: 1.42857143; text-decoration: non

Android Bottom Navigation Bar With Drop Shadow

Answer : You can draw your own shadow just above the bottom bar using simple View and its background: <View android:layout_width="match_parent" android:layout_height="4dp" android:layout_above="@id/bottom_bar" android:background="@drawable/shadow"/> drawable/shadow.xml: <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#1F000000" android:endColor="@android:color/transparent" android:angle="90" /> </shape> Also, there are no compatibility issues if use this approach. You can use elevation to add shadows to any view <TextView android:id="@+id/myview" ... android:elevation="2dp" android:background="@drawable/myrect" /> Refer this for more information For those using a CoordinatorLayout with the Bottom Navigation Bar (or BottomAppBar ), you can

Angular Material Table Sizing/Scroll

Answer : Add .example-container { overflow-x: scroll; } To the app.component.css to fix the top bar. The bottom will need a similar styling. You can't use width:100% because it is technically outside the table. So it can not pick up the width automatically. I hope this will be help full for others to add Horizontal Scrolling to mat-table and column width according to cell content. .mat-table { overflow-x: scroll; } .mat-cell, .mat-header-cell { word-wrap: initial; display: table-cell; padding: 0px 10px; line-break: unset; width: 100%; white-space: nowrap; overflow: hidden; vertical-align: middle; } .mat-row, .mat-header-row { display: table-row; }