Posts

Showing posts from December, 2002

Add User To Mysql Database Code Example

Example 1: mysql create user CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost'; FLUSH PRIVILEGES; Example 2: mysql add user with all privileges CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES; Example 3: create user mysql CREATE USER 'norris'@'localhost' IDENTIFIED BY 'password'; Example 4: mysql create user CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; #grant permissions to a specic database and/or table GRANT ALL PRIVILEGES ON database.table TO 'newuser'@'localhost'; #Or grant wildcar permission to any DB/table GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost'; Example 5: create user mysql CREATE USER 'newuser'@'localhost' IDENTIFIED BY 

Noindent Latex Global Code Example

Example: latex noindent for whole document % In preamble : \setlength\parindent { 0 pt }

Css Remove Number Input Arrows Code Example

Example 1: remove arrows from input type number /* Chrome, Safari, Edge, Opera */ input ::-webkit-outer-spin-button , input ::-webkit-inner-spin-button { -webkit-appearance : none ; margin : 0 ; } /* Firefox */ input [ type = number ] { -moz-appearance : textfield ; } Example 2: html css number input field don't show arrows input ::-webkit-outer-spin-button , input ::-webkit-inner-spin-button { -webkit-appearance : none ; margin : 0 ; } input [ type = number ] { -moz-appearance : textfield ; } Example 3: remove arrows input number input [ type = number ] ::-webkit-inner-spin-button , input [ type = number ] ::-webkit-outer-spin-button { -webkit-appearance : none ; }

Arduino Mills Code Example

Example 1: arduino millis() /*Description Returns the number of milliseconds passed since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. Syntax */ time = millis ( ) ; Example 2: arduino millis /*Description Returns the number of milliseconds passed since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. Syntax */ time = millis ( ) /* Returns Number of milliseconds passed since the program started. Return Data type: unsigned long. */

Convert Youtube To Mp3 Ringtone Online Code Example

Example: youtube mp3 converter You can use WebTools , it's an addon that gather the most useful and basic tools such as a synonym dictionary , a dictionary , a translator , a youtube convertor , a speedtest and many others ( there are ten of them ) . You can access them in two clics , without having to open a new tab and without having to search for them ! - Chrome Link : https : //chrome.google.com/webstore/detail/webtools/ejnboneedfadhjddmbckhflmpnlcomge/ Firefox link : https : //addons.mozilla.org/fr/firefox/addon/webtools/

Amc Stock Stocktwits Code Example

Example 1: amc stock There once was a stock that put to sea The name of the stock was $AMC The price blew up , the shorts dipped down Hold my bully boys hold Soon may the tendieman come to send our rocket into the sun One day when the trading is done we'll take our gains and go She had not been two weeks from shore When Ryan Cohen joined the board The captain called all hands and swore He'll take his shares and hold Soon may the tendieman come to send our rocket into the sun One day when the trading is done we'll take our gains and go Before the news had hit the market Wall Street Bets came up and bought it with diamond hands they knew they'd profit if they could only hold Soon may the tendieman come to send our rocket into the sun One day when the trading is done we'll take our gains and go No deals were cut , no shorts were squeezed The captain's mind was not on greed But he belonged to the autist's creed He took the risk to h

Python Short If Then Else Code Example

Example 1: python if else short version x = 10 if a > b else 11 Example 2: shorthand python if # Traditional Ternary Operatorcan_vote = ( age >= 18 ) true : false ; # Python Ternary Operatorcan_vote = True if age >= 18 else False

Css Flexbox W3schools Code Example

Example 1: display flex css .class { display : flex ; } /* use display: flex to turn CSS element into a flexbox */ Example 2: what is the flex box flexbox definition

Count Unique Values With Pandas Per Groups

Answer : You need nunique : df = df.groupby('domain')['ID'].nunique() print (df) domain 'facebook.com' 1 'google.com' 1 'twitter.com' 2 'vk.com' 3 Name: ID, dtype: int64 If you need to strip ' characters: df = df.ID.groupby([df.domain.str.strip("'")]).nunique() print (df) domain facebook.com 1 google.com 1 twitter.com 2 vk.com 3 Name: ID, dtype: int64 Or as Jon Clements commented: df.groupby(df.domain.str.strip("'"))['ID'].nunique() You can retain the column name like this: df = df.groupby(by='domain', as_index=False).agg({'ID': pd.Series.nunique}) print(df) domain ID 0 fb 1 1 ggl 1 2 twitter 2 3 vk 3 The difference is that nunique() returns a Series and agg() returns a DataFrame. Generally to count distinct values in single column, you can use Series.value_counts : df.domain.value_counts() #'vk.com&#

Round Buttons In Css Code Example

Example: round button css .btn { display : block ; height : 300 px ; width : 300 px ; border-radius : 50 % ; border : 1 px solid red ; }

Border Radius For Card In Flutter Code Example

Example 1: card rounded corners flutter Card ( //Card with circular border shape : RoundedRectangleBorder ( borderRadius : BorderRadius . circular ( 15.0 ) , ) , child : Text ( 'Card with circular border' , textScaleFactor : 1.2 , ) , ) , Card ( //Card with beveled border shape : BeveledRectangleBorder ( borderRadius : BorderRadius . circular ( 10.0 ) , ) , child : Text ( 'Card with Beveled border' , textScaleFactor : 1.2 , ) , ) , Card ( shape : StadiumBorder ( //Card with stadium border side : BorderSide ( color : Colors . black , width : 2.0 , ) , ) , child : Text ( 'Card with Beveled border' , textScaleFactor : 1.2 , ) , ) , Example 2: how to give shape to card in flutter Card ( color : Colors . grey [ 900 ] , shape : RoundedRectangleBorder ( side : BorderSide ( color : Colors . white70 , width : 1 ) ,

C Implementation Of Matlab Interp1 Function (linear Interpolation)

Answer : I've ported Luis's code to c++. It seems to be working but I haven't checked it a lot, so be aware and re-check your results. #include <vector> #include <cfloat> #include <math.h> vector< float > interp1( vector< float > &x, vector< float > &y, vector< float > &x_new ) { vector< float > y_new; y_new.reserve( x_new.size() ); std::vector< float > dx, dy, slope, intercept; dx.reserve( x.size() ); dy.reserve( x.size() ); slope.reserve( x.size() ); intercept.reserve( x.size() ); for( int i = 0; i < x.size(); ++i ){ if( i < x.size()-1 ) { dx.push_back( x[i+1] - x[i] ); dy.push_back( y[i+1] - y[i] ); slope.push_back( dy[i] / dx[i] ); intercept.push_back( y[i] - x[i] * slope[i] ); } else { dx.push_back( dx[i-1] ); dy.push_back( dy[i-1] ); slo

Light-grey Background Code Example

Example: css light grey #selector { color : lightgrey ; }

Connect Postgresql DB In Python Code Example

Example 1: how to connect postgres database to python import psycopg2 try: connection = psycopg2.connect(user = "sysadmin", password = "pynative@#29", host = "127.0.0.1", port = "5432", database = "postgres_db") cursor = connection.cursor() # Print PostgreSQL Connection properties print ( connection.get_dsn_parameters(),"\n") # Print PostgreSQL version cursor.execute("SELECT version();") record = cursor.fetchone() print("You are connected to - ", record,"\n") except (Exception, psycopg2.Error) as error : print ("Error while connecting to PostgreSQL", error) finally: #closing database connection. if(connection): cursor.close() connection.close() print("PostgreSQL c

Crontab Every 2 Minute Code Example

Example: cron every 2 minutes */2 * * * *

Install Prettier Vscode Code Example

Example 1: prettier config vscode npm install -- save - dev -- save - exact prettier Example 2: prettier on save vscode // Set the default"editor.formatOnSave": false,// Enable per-language"[javascript]": { "editor.formatOnSave": true} Example 3: enable prettier vscode ext install esbenp . prettier - vscode Example 4: prettier install in vscode Install node . js first

Convert Binary Code To Alphabet Code Example

Example: Binary text A binary-to-text encoding is encoding of data in plain text. More precisely, it is an encoding of binary data in a sequence of printable characters. These encodings are necessary for transmission of data when the channel does not allow binary data (such as email or NNTP) or is not 8-bit clean. PGP documentation (RFC 4880) uses the term "ASCII armor" for binary-to-text encoding when referring to Base64.

Angular2 Watch For Route Change

Answer : In the final version of Angular (e.g. Angular 2/4), you can do this this.router.events.subscribe((event) => { if(event.url) { console.log(event.url); } }); Every time the route changes, events Observable has the info. Click here for docs . If you are using "@angular/router": "3.0.0-alpha.7", "@angular/router-deprecated": "2.0.0-rc.2", then this.router.events.subscribe((event) => { console.log('route changed'); }); Here's what I use in my app. You can subscribe to a Route instance to track changes. class MyClass { constructor(private router: Router) { router.subscribe((val) => /*detect changes*/) } }

Convert Text File Of Bits To Binary File

Answer : Adding the -r option (reverse mode) to xxd -b does not actually work as intended, because xxd simply does not support combining these two flags (it ignores -b if both are given). Instead, you have to convert the bits to hex yourself first. For example like this: ( echo 'obase=16;ibase=2'; sed -Ee 's/[01]{4}/;\0/g' instructions.txt ) | bc | xxd -r -p > instructions.bin Full explanation: The part inside the parentheses creates a bc script. It first sets the input base to binary (2) and the output base to hexadecimal (16). After that, the sed command prints the contents of instructions.txt with a semicolon between each group of 4 bits, which corresponds to 1 hex digit. The result is piped into bc . The semicolon is a command separator in bc , so all the script does is print every input integer back out (after base conversion). The output of bc is a sequence of hex digits, which can be converted to a file with the usual xxd -r -p . Output: $ hexdump -C