Posts

Showing posts from April, 2018

Access Array Element Arduino Code Example

Example 1: array arduino int myArray[6]; int myArray[] = {2, 4, 8, 3, 6}; int myArray[6] = {2, 4, -8, 3, 2}; Example 2: variable array arduino var myArray[] = {d1,d2,d3,d4,d4}; var myArray[3]:

Angular Unit Test Input Value

Answer : Inputs don't have textContent, only a value. So expect(field.textContent).toBe('someValue'); is useless. That's probably what's failing. The second expectation should pass though. Here's a complete test. @Component({ template: `<input type="text" [(ngModel)]="user.username"/>` }) class TestComponent { user = { username: 'peeskillet' }; } describe('component: TestComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [FormsModule], declarations: [ TestComponent ] }); }); it('should be ok', async(() => { let fixture = TestBed.createComponent(TestComponent); fixture.detectChanges(); fixture.whenStable().then(() => { let input = fixture.debugElement.query(By.css('input')); let el = input.nativeElement; expect(el.value).toBe('peeskillet'); el.value = 'someValue'; el.d

Android Resource Linking Failed Unity Code Example

Example: android resource linking failed Change the following settings in build . gradle file to : classpath 'com.android.tools.build:gradle:3.4.2'

BLOB To String, SQL Server

Answer : Problem was apparently not the SQL server, but the NAV system that updates the field. There is a compression property that can be used on BLOB fields in NAV, that is not a part of SQL Server. So the custom compression made the data unreadable, though the conversion worked. The solution was to turn off compression through the Object Designer, Table Designer, Properties for the field (Shift+F4 on the field row). After that the extraction of data can be made with e.g.: select convert(varchar(max), cast(BLOBFIELD as binary)) from Table Thanks for all answers that were correct in many ways! The accepted answer works for me only for the first 30 characters. This works for me: select convert(varchar(max), convert(varbinary(max),myBlobColumn)) FROM table_name It depends on how the data was initially put into the column. Try either of these as one should work: SELECT CONVERT(NVarChar(40), BLOBTextToExtract) FROM [NavisionSQL$Customer]; Or if it was just varchar ...

Can I Play Among Us On Ubuntu?

Image
Answer : Yes, at least on my machine. Install Steam and buy the game. Force the use of Proton. Configure the Launch Options (from here, step 4): PROTON_NO_ESYNC=1 PROTON_USE_WINED3D=1 %command% Install the game. Start the game -- may download additional dependencies (e.g. Proton).

Clear Git Local Cache

Image
Answer : All .idea files that are explicitly ignored are still showing up to commit you have to remove them from the staging area git rm --cached .idea now you have to commit those changes and they will be ignored from this point on. Once git start to track changes it will not "stop" tracking them even if they were added to the .gitignore file later on. You must explicitly remove them and then commit your removal manually in order to fully ignore them. When you think your git is messed up, you can use this command to do everything up-to-date. git rm -r --cached . git add . git commit -am 'git cache cleared' git push Also to revert back last commit use this : git reset HEAD^ --hard if you do any changes on git ignore then you have to clear you git cache also > git rm -r --cached . > git add . > git commit -m 'git cache cleared' > git push if want to remove any particular folder or file then git rm --cached fi

Clear Consoe Python Code Example

Example 1: python clear console import sys , os os . system ( 'cls' ) Example 2: clear console in python As you mentioned , you can do a system call : For Windows >> > import os >> > clear = lambda : os . system ( 'cls' ) >> > clear ( ) For Linux the lambda becomes >> > clear = lambda : os . system ( 'clear' )

Add Id Autoincrement Column To Existing Table Mysql Code Example

Example 1: add auto_increment column to existing table mysql ALTER TABLE ` users ` ADD ` id ` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ALTER TABLE ` users ` ADD ` id ` INT NOT NULL AUTO_INCREMENT UNIQUE FIRST Example 2: mysql add auto increment id existing table ALTER TABLE ` users ` ADD ` id ` INT NOT NULL AUTO_INCREMENT PRIMARY KEY

Colspan And Rowspan In Html Code Example

Example 1: html table span 2 rows < td colspan = " 2 " > Content here </ td > // or... < td rowspan = " 2 " > Content here </ td > Example 2: html table colspan and rowspan < td colspan = " 4 " > Content </ td > < td rowspan = " 4 " > Content </ td >

Change Figure Numbering For Appendix

Image
Answer : Redefine \thefigure when your appendices start, and set the figure counter to zero at the beginning of each appendix. \documentclass{article} \begin{document} \begin{figure} \centering\rule{1cm}{1cm} \caption{This is a figure} \end{figure} \appendix \renewcommand\thefigure{\thesection.\arabic{figure}} \section{A nice appendix} \setcounter{figure}{0} \begin{figure} \centering\rule{1cm}{1cm} \caption{This is a figure in appendix A} \end{figure} \end{document} You can use the chngcntr package which includes the command \counterwithin . Using this as \counterwithin{figure}{section} changes the figure numbering from that point on so that the section number is included and resets the numbering of figures at the beginning each subsequent section. An example is: \documentclass{article} \usepackage{chngcntr} \begin{document} \section{Introduction} \subsection{Problem description} \begin{figure}[htp] \centering Figure \caption{Call this figure 1.} \labe

Base64 Java Encode And Decode A String

Answer : You can use following approach: import org.apache.commons.codec.binary.Base64; // Encode data on your side using BASE64 byte[] bytesEncoded = Base64.encodeBase64(str.getBytes()); System.out.println("encoded value is " + new String(bytesEncoded)); // Decode data on other side, by processing encoded data byte[] valueDecoded = Base64.decodeBase64(bytesEncoded); System.out.println("Decoded value is " + new String(valueDecoded)); Hope this answers your doubt. Java 8 now supports BASE64 Encoding and Decoding. You can use the following classes: java.util.Base64 , java.util.Base64.Encoder and java.util.Base64.Decoder . Example usage: // encode with padding String encoded = Base64.getEncoder().encodeToString(someByteArray); // encode without padding String encoded = Base64.getEncoder().withoutPadding().encodeToString(someByteArray); // decode a String byte [] barr = Base64.getDecoder().decode(encoded); The accepted answer uses the Apache Commons p

Change Font Size Visual Studio 2019 Code Example

Example 1: shortcut to increase visuals studio text size ctrl + shift + . Zoom IN ctrl + shift + , Zoom OUT Example 2: shortcut to increase visuals studio text size ctrl + MouseWheel Forward : Zoom IN ctrl + MouseWheel Backward : Zoom OUT

Bootstrap Class For Font Weight Code Example

Example 1: font weight bootstrap class < p class = " font-weight-bold " > Bold text. </ p > < p class = " font-weight-normal " > Normal weight text. </ p > < p class = " font-weight-light " > Light weight text. </ p > < p class = " font-italic " > Italic text. </ p > Example 2: bootstrap 4 font bold font-weight-bold

Cmd Taskkill By Process Name Code Example

Example 1: taskkill in cmd taskkill /f /im notepad.exe /t taskkill /f /im chrome.exe /t Example 2: script to kill a process in windows taskkill /PID 1234

Auto Increment Primary Key In SQL Server Management Studio 2012

Image
Answer : Make sure that the Key column's datatype is int and then setting identity manually, as image shows Or just run this code -- ID is the name of the [to be] identity column ALTER TABLE [yourTable] DROP COLUMN ID ALTER TABLE [yourTable] ADD ID INT IDENTITY(1,1) the code will run, if ID is not the only column in the table image reference fifo's When you're creating the table, you can create an IDENTITY column as follows: CREATE TABLE ( ID_column INT NOT NULL IDENTITY(1,1) PRIMARY KEY, ... ); The IDENTITY property will auto-increment the column up from number 1. (Note that the data type of the column has to be an integer.) If you want to add this to an existing column, use an ALTER TABLE command. Edit: Tested a bit, and I can't find a way to change the Identity properties via the Column Properties window for various tables. I guess if you want to make a column an identity column, you HAVE to use an ALTER TABLE command. You have to

Bash Sudo Command Not Found Windows Code Example

Example: how to run sudo in windows Simply specify the user and command to run as follows: runas /user:Admin cmd