Posts

Showing posts from September, 2015

Programiz C Code Example

Example: basic cpp programs // Your First C++ Program # include <iostream> int main ( ) { std :: cout << "Hello World!" ; return 0 ; }

Boolean Field In Oracle

Answer : I found this link useful. Here is the paragraph highlighting some of the pros/cons of each approach. The most commonly seen design is to imitate the many Boolean-like flags that Oracle's data dictionary views use, selecting 'Y' for true and 'N' for false. However, to interact correctly with host environments, such as JDBC, OCCI, and other programming environments, it's better to select 0 for false and 1 for true so it can work correctly with the getBoolean and setBoolean functions. Basically they advocate method number 2, for efficiency's sake, using values of 0/1 (because of interoperability with JDBC's getBoolean() etc.) with a check constraint a type of CHAR (because it uses less space than NUMBER). Their example: create table tbool (bool char check (bool in (0,1)); insert into tbool values(0); insert into tbool values(1);` Oracle itself uses Y/N for Boolean values. For completeness it should be noted th

How To Input String With Spaces In C Using Scanf Code Example

Example: how to store a user input with spaces in c # include <stdio.h> int main ( ) { char name [ 20 ] ; printf ( "Enter a name : " ) ; scanf ( "%[^\n]%*c" , & name ) ; printf ( "the name entered is: %s\n" , name ) ; return 0 ; }

Color For Unicode Emoji

Answer : Yes, you can color them! div { color: transparent; text-shadow: 0 0 0 red; } <div></div> Not every emoji works the same. Some are old textual symbols that now have an (optional or default) colorful representation, others were explicitly (only) as emojis. That means, some Unicode codepoints should have two possible representations, text and emoji . Authors and users should be able to express their preference for one or the other. This is currently done with otherwise invisible variation selectors U+FE0E ( text , VS-15) and U+FE0F ( emoji , VS-16), but higher-level solutions (e.g. for CSS) have been proposed. The text-style emojis are monochromatic and should be displayed in the foreground color, i.e. currentcolor in CSS, just like any other glyph. The Unicode Consortium provides an overview of emojis by style (beta version). You should be able to append &#xFE0E; in HTML to select the textual variant with anything in the columns labeled “De

ASCII To Binary And Binary To ASCII Conversion Tools?

Answer : $ echo AB | perl -lpe '$_=unpack"B*"' 0100000101000010 $ echo 0100000101000010 | perl -lpe '$_=pack"B*",$_' AB -e expression evaluate the given expression as perl code -p : sed mode. The expression is evaluated for each line of input, with the content of the line stored in the $_ variable and printed after the evaluation of the expression . -l : even more like sed : instead of the full line, only the content of the line (that is, without the line delimiter) is in $_ (and a newline is added back on output). So perl -lpe code works like sed code except that it's perl code as opposed to sed code. unpack "B*" works on the $_ variable by default and extracts its content as a bit string walking from the highest bit of the first byte to the lowest bit of the last byte. pack does the reverse of unpack . See perldoc -f pack for details. With spaces: $ echo AB | perl -lpe '$_=join " ", unpack&q

Apt Command To Download Jdk 14 Ubuntu Code Example

Example: sudo apt install openjdk-14-jdk $ apt search openjdk

20 Lakh Rs To Usd Code Example

Example: 11 lakh to usd hmmm.... i know you are going to get this amount in your future... best of luck

Border Radius Only Top Left Flutter Code Example

Example 1: flutter container rounded corners Container( decoration: BoxDecoration( border: Border.all( color: Colors.red[500], ), borderRadius: BorderRadius.all(Radius.circular(20)) ), child: ... ) Example 2: flutter container border radius only left borderRadius: BorderRadius.only( topRight: Radius.circular(10.0), bottomRight: Radius.circular(10.0)), Example 3: column round border flutter Container( decoration: BoxDecoration( border: Border.all( color: Colors.red[500], ), color: Colors.green[500], borderRadius: BorderRadius.all(Radius.circular(20)) ), child: ... )

Collect() Or ToPandas() On A Large DataFrame In Pyspark/EMR

Answer : TL;DR I believe you're seriously underestimating memory requirements. Even assuming that data is fully cached, storage info will show only a fraction of peak memory required for bringing data back to the driver. First of all Spark SQL uses compressed columnar storage for caching. Depending on the data distribution and compression algorithm in-memory size can be much smaller than the uncompressed Pandas output, not to mention plain List[Row] . The latter also stores column names, further increasing memory usage. Data collection is indirect, with data being stored both on the JVM side and Python side. While JVM memory can be released once data goes through socket, peak memory usage should account for both. Plain toPandas implementation collects Rows first, then creates Pandas DataFrame locally. This further increases (possibly doubles) memory usage. Luckily this part is already addressed on master (Spark 2.3), with more direct approach using Arrow serialization

Clear Variable In Python

Answer : The del keyword would do. >>> a=1 >>> a 1 >>> del a >>> a Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'a' is not defined But in this case I vote for self.left = None What's wrong with self.left = None ? var = None "clears the value", setting the value of the variable to "null" like value of "None", however the pointer to the variable remains. del var removes the definition for the variable totally. In case you want to use the variable later, e.g. set a new value for it, i.e. retain the variable, None would be better.

Can I Loop Through A Table Variable In T-SQL?

Answer : Add an identity to your table variable, and do an easy loop from 1 to the @@ROWCOUNT of the INSERT-SELECT. Try this: DECLARE @RowsToProcess int DECLARE @CurrentRow int DECLARE @SelectCol1 int DECLARE @table1 TABLE (RowID int not null primary key identity(1,1), col1 int ) INSERT into @table1 (col1) SELECT col1 FROM table2 SET @RowsToProcess=@@ROWCOUNT SET @CurrentRow=0 WHILE @CurrentRow<@RowsToProcess BEGIN SET @CurrentRow=@CurrentRow+1 SELECT @SelectCol1=col1 FROM @table1 WHERE RowID=@CurrentRow --do your thing here-- END DECLARE @table1 TABLE ( idx int identity(1,1), col1 int ) DECLARE @counter int SET @counter = 1 WHILE(@counter < SELECT MAX(idx) FROM @table1) BEGIN DECLARE @colVar INT SELECT @colVar = col1 FROM @table1 WHERE idx = @counter -- Do your work here SET @counter = @counter + 1 END Believe it or not, this is actually more efficient and performant than using a cursor.

Cloudflare Ipv6 Dns Code Example

Example: ip cloudflare dns IPv4: 1.1.1.1 & 1.0.0.1 IPv6: 2606:4700:4700::1111 & 2606:4700:4700::1001

Add A Horizontal Line To Plot And Legend In Ggplot2

Image
Answer : (1) Try this: cutoff <- data.frame( x = c(-Inf, Inf), y = 50, cutoff = factor(50) ) ggplot(the.data, aes( year, value ) ) + geom_point(aes( colour = source )) + geom_smooth(aes( group = 1 )) + geom_line(aes( x, y, linetype = cutoff ), cutoff) (2) Regarding your comment, if you don't want the cutoff listed as a separate legend it would be easier to just label the cutoff line right on the plot: ggplot(the.data, aes( year, value ) ) + geom_point(aes( colour = source )) + geom_smooth(aes( group = 1 )) + geom_hline(yintercept = 50) + annotate("text", min(the.data$year), 50, vjust = -1, label = "Cutoff") Update This seems even better and generalizes to mulitple lines as shown: line.data <- data.frame(yintercept = c(50, 60), Lines = c("lower", "upper")) ggplot(the.data, aes( year, value ) ) + geom_point(aes( colour = source )) + geom_smooth(aes( group

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

Code Color Transparent Css Code Example

Example: css transparent background color div { opacity : 25 % ; }

Youtube 2 Mp3 Converter Code Example

Example: yt to mp3 Youtube - DL works great . Download from https : //youtube-dl.org/. To use, type youtube-dl <url> --audio-format mp3

Checking Pip Version Code Example

Example 1: python pip version check pip --version Example 2: how to know the python pip module version pip show module name

48inch In Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Angular Cli Ng G Component Code Example

Example 1: angular generate component ng g component componentname Example 2: ng g c ng generate component < name > [options]

Bungeecord 1.15 Maven Code Example

Example: bungeecord api maven < repositories > < repository > < id > bungeecord-repo </ id > < url > https://oss.sonatype.org/content/repositories/snapshots </ url > </ repository > </ repositories > < dependencies > < dependency > < groupId > net.md-5 </ groupId > < artifactId > bungeecord-api </ artifactId > < version > 1.16-R0.4-SNAPSHOT </ version > < type > jar </ type > < scope > provided </ scope > </ dependency > < dependency > < groupId > net.md-5 </ groupId > < artifactId > bungeecord-api </ artifactId > < version > 1.16-R0.4-SNAPSHOT </ version > < type > javadoc </ type > < scope &g

Conditional Or Ternary Operator In C Code Example

Example 1: how to use ternary operator in c programming int a = 10 , b = 20 , c ; c = ( a < b ) ? a : b ; printf ( "%d" , c ) ; Example 2: ternary operator in c c = ( a < b ) ? a : b ;

Charcodes Js Code Example

Example 1: javascript charcode const sentence = 'The quick brown fox jumps over the lazy dog.' ; const index = 4 ; console . log ( ` The character code ${ sentence . charCodeAt ( index ) } is equal to ${ sentence . charAt ( index ) } ` ) ; // expected output: "The character code 113 is equal to q" Example 2: charcodeAt javascript const sentence = 'The quick brown fox jumps over the lazy dog.' ; const index = 4 ; // return the chartcode of the character with index N°4 const charcode = sentence . charCodeAt ( index ) ; console . log ( charcode ) ; // expected output: "The character code 113 is equal to q" // remember that charCodeAt return the code on ♦ keypress event ♦

Parseint Js Code Example

Example 1: intval js parseInt ( value ) ; let string = "321" console . log ( string ) ; // "321" <= string let number = parseInt ( string ) ; console . log ( number ) // 321 <=int Example 2: Javascript string to int var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 3: parseint javascript var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 4: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42 let myNumber = Number ( "5.25" ) ; //5.25 Example 5: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42 Example 6: parseint js parseInt ( " 0xF" , 16 ) ; parseInt ( " F" , 16 ) ; parseInt ( "17" , 8 ) ; parseInt ( 021 , 8 ) ; parseInt ( &qu

Arduino Turn Pin On And Off On Setup Code Example

Example 1: arduino digital io pins void setup ( ) { pinMode ( 13 , OUTPUT ) ; // sets the digital pin 13 as output } void loop ( ) { digitalWrite ( 13 , HIGH ) ; // sets the digital pin 13 on delay ( 1000 ) ; // waits for a second digitalWrite ( 13 , LOW ) ; // sets the digital pin 13 off delay ( 1000 ) ; // waits for a second } Example 2: arduino pinMode pinMode ( Pin_number , State ) ; ex : pinMode ( 2 , HIGH ) ;

Add A Class To The HTML Tag With React?

Answer : TL;DR use document.body.classList.add and document.body.classList.remove I would have two functions that toggle a piece of state to show/hide the modal within your outer component. Inside these functions I would use the document.body.classList.add and document.body.classList.remove methods to manipulate the body class dependant on the modal's state like below: openModal = (event) => { document.body.classList.add('modal-open'); this.setState({ showModal: true }); } hideModal = (event) => { document.body.classList.remove('modal-open'); this.setState({ showModal: false }); } With the new React (16.8) this can be solved with hooks: import {useEffect} from 'react'; const addBodyClass = className => document.body.classList.add(className); const removeBodyClass = className => document.body.classList.remove(className); export default function useBodyClass(className) { useEffect( () => { // Se

Axios Cdn Code Example

Example 1: axios cdn < script src = " https://unpkg.com/axios/dist/axios.min.js " > </ script > Example 2: AXIOS CDN < script src = " https://unpkg.com/axios/dist/axios.min.js " > </ script >

Sleep Cpp Code Example

Example 1: cpp thread sleep // this_thread::sleep_for example # include <iostream> // std::cout, std::endl # include <thread> // std::this_thread::sleep_for # include <chrono> // std::chrono::seconds int main ( ) { std :: cout << "countdown:\n" ; for ( int i = 10 ; i > 0 ; -- i ) { std :: cout << i << std :: endl ; std :: this_thread :: sleep_for ( std :: chrono :: seconds ( 1 ) ) ; } std :: cout << "Lift off!\n" ; return 0 ; } Example 2: c++ sleep function # include <chrono> # include <thread> std :: this_thread :: sleep_for ( std :: chrono :: milliseconds ( x ) ) ; Example 3: sleep c++ windows # include <Windows.h> Sleep ( number of milliseconds ) ; Example 4: sleep in c++ linux # include <unistd.h> sleep ( 10 ) ; Example 5: sleep c++ # include <unistd.h> unsigned int sleep ( unsigned int