Posts

Showing posts from January, 2011

Create Git Branch With Current Changes

Answer : If you hadn't made any commit yet, only (1: branch) and (3: checkout) would be enough. Or, in one command: git checkout -b newBranch As mentioned in the git reset man page: $ git branch topic/wip # (1) $ git reset --hard HEAD~3 # (2) NOTE: use $git reset --soft HEAD~3 (explanation below) $ git checkout topic/wip # (3) You have made some commits, but realize they were premature to be in the " master " branch. You want to continue polishing them in a topic branch, so create " topic/wip " branch off of the current HEAD . Rewind the master branch to get rid of those three commits. Switch to " topic/wip " branch and keep working. Note: due to the "destructive" effect of a git reset --hard command (it does resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded), I would rather go with: $ git reset --soft HEAD~3 # (2) This would make sure I'm not losing any

Montserrat Medium Font Android Code Example

Example: montserrat font <link rel= "preconnect" href= "https://fonts.gstatic.com" > <link href= "https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel= "stylesheet" >

Exponents Python Code Example

Example 1: how to power in python 2 ** 3 == 8 Example 2: exponent in python # You can use exponents in python using double stars ( ** ) 2 ** 3 # Output : 8 9 ** 0.5 # Output : 3 Example 3: python exponentiation print ( 5 ** 3 ) #125 Example 4: python exponent operator #python exponent operator num = 2 new_num = num** 2 #answer would be 4

Font Awesome Delete Icon Code Example

Example 1: trash icon font awesome <i class= "fa fa-trash" aria-hidden= "true" ></i> Example 2: font awesome trash icon For Font Awesome 5 : <i class= "fas fa-trash" ></i> Example 3: fontawecome dellete <form action="" method="POST" > <!-- fields -- > <button type="submit" name="action" value="save" > Save</button > <button type="submit" name="action" value="preview" > Preview</button > <button type="submit" name="action" value="advanced_edit" > Advanced edit</button > </form > public function store ( Request $request ) { switch ( $request- > input ( 'action' ) ) { case 'save' : // Save model break ; case 'preview' : // Preview model break ; case &#

Convert Categorical Variable To Numeric Python Sklearn Code Example

Example 1: pandas categorical to numeric #this will label the different catagories as 0,1,2,3.... dataset [ "sex" ] = dataset [ "sex" ] . astype ( 'category' ) . cat . codes Example 2: transform categorical variables python from sklearn . preprocessing import LabelEncoder lb_make = LabelEncoder ( ) obj_df [ "make_code" ] = lb_make . fit_transform ( obj_df [ "make" ] ) obj_df [ [ "make" , "make_code" ] ] . head ( 11 ) Example 3: how to convert categorical data to binary data in python MedInc False HouseAge False AveRooms False AveBedrms False Population False AveOccup False Latitude False Longitude False Price False dtype : bool

Cannot Download, $GOPATH Not Set

Answer : [Update: as of Go 1.8, GOPATH defaults to $HOME/go , but you may still find this useful if you want to understand the GOPATH layout, customize it, etc.] The official Go site discusses GOPATH and how to lay out a workspace directory. export GOPATH="$HOME/your-workspace-dir/" -- run it in your shell, then add it to ~/.bashrc or equivalent so it will be set for you in the future. Go will install packages under src/ , bin/ , and pkg/ , subdirectories there. You'll want to put your own packages somewhere under $GOPATH/src , like $GOPATH/src/github.com/myusername/ if you want to publish to GitHub. You'll also probably want export PATH=$PATH:$GOPATH/bin in your .bashrc so you can run compiled programs under $GOPATH . Optionally, via Rob Pike, you can also set CDPATH so it's faster to cd to package dirs in bash: export CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/golang.org/x means you can just type cd net/html instead of cd $GOPATH/src/golang.

Android Toolbar Code Example

Example 1: android toolbar with menus @Override public boolean onCreateOptionsMenu ( Menu menu ) { getMenuInflater ( ) . inflate ( R . menu . main_menu , menu ) ; return true ; } Example 2: android toolbar example < ? xml version = "1.0" encoding = "utf-8" ? > < LinearLayout xmlns : android = "http://schemas.android.com/apk/res/android" android : layout_width = "match_parent" android : layout_height = "match_parent" android : background = "@android:color/white" > < android . support . v7 . widget . Toolbar android : id = "@+id/toolbar" android : layout_width = "match_parent" android : layout_height = "58dp" android : background = "?attr/colorPrimary" android : minHeight = "?attr/actionBarSize" android : titleTextColor = "#ffffff" > < / android . support . v7 . widget . Toolbar > < / LinearLayout >

Change Transform.position Unity Code Example

Example: unity c# transform position GameObject myObject ; // Change the position of myObject like this: myObject . transform . position = new Vector3 ( x , y , z ) ; // Change position of GameObject that this script is attatched to: transform . position = new Vector3 ( x , y , z ) ; // Read the x, y and z positions of myObject: Debug . Log ( "x : " + myObject . transform . position . x ) ; Debug . Log ( "y : " + myObject . transform . position . y ) ; Debug . Log ( "z : " + myObject . transform . position . z ) ;

Cpp Vector Push Back Another Vector Code Example

Example 1: how to append one vector to another c++ vector a; vector b; // Appending the integers of b to the end of a a.insert(a.end(), b.begin(), b.end()); Example 2: how to append to a vector c++ //vector.push_back is the function. For example, if we want to add //3 to a vector, it is just vector.push_back(3) vector vi; vi.push_back(1); //[1] vi.push_back(2); //[1,2]

Android WebView Not Loading URL

Answer : Did you added the internet permission in your manifest file ? if not add the following line. <uses-permission android:name="android.permission.INTERNET"/> hope this will help you. EDIT Use the below lines. public class WebViewDemo extends Activity { private WebView webView; Activity activity ; private ProgressDialog progDailog; @SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); activity = this; progDailog = ProgressDialog.show(activity, "Loading","Please wait...", true); progDailog.setCancelable(false); webView = (WebView) findViewById(R.id.webview_compontent); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(t

Convert Object To Array Javascript Es6 Code Example

Example 1: javascript object to array //ES6 Object to Array const numbers = { one : 1 , two : 2 , } ; console . log ( Object . values ( numbers ) ) ; // [ 1, 2 ] console . log ( Object . entries ( numbers ) ) ; // [ ['one', 1], ['two', 2] ] Example 2: javascript object to array //Supposing fooObj to be an object fooArray = Object . entries ( fooObj ) ; fooArray . forEach ( ( [ key , value ] ) => { console . log ( key ) ; // 'one' console . log ( value ) ; // 1 } ) Example 3: convert object to array javascript var object = { 'Apple' : 1 , 'Banana' : 8 , 'Pineapple' : null } ; //convert object keys to array var k = Object . keys ( object ) ; //convert object values to array var v = Object . values ( object ) ; Example 4: object to array javascript Object . values ( obj ) Example 5: converting object to array in js const numbers = { one : 1 , } ; const objectArray = Object . entries ( numbers ) ; objectAr

Create Laravel 7 Project Code Example

Example 1: create laravel 6 project using composer composer create - project -- prefer - dist laravel / laravel blog "6.*" Example 2: install laravel composer create - project -- prefer - dist laravel / laravel blog Example 3: composer create project laravel 7 composer create - project -- prefer - dist laravel / laravel : ^ 7.0 blog Example 4: laravel create project // To install and use a specific version, you can enter it at the end of the command. // For example using version 5.8 ==> composer create - project -- prefer - dist laravel / laravel projectName "5.8.*" Example 5: how to install new project in laravel You can create project by 2 ways : First is installing it without defining version : composer create - project laravel / laravel yourProjectName Secondly you can install by defining version : composer create - project laravel / laravel = "VersionOfYourChoice" yourProjectName Example 6: laravel install composer global require laravel /

Country Roads Accordi Code Example

Example: country roads accordi LA FA#m Almost heaven, West Virginia, MI RE LA Blue Ridge Mountains, Shenandoah River FA#m Life is old there, older than the trees, MI RE LA younger than the mountains, growing like a breeze LA MI Country roads, take me home FA#m RE to the place I belong LA MI West Virginia, mountain mamma, RE LA take me home, country roads LA FA#m All my memories gather round her, MI RE LA miner's lady, stranger to blue water FA#m Dark and dusty, painted on the sky, MI RE LA misty taste of moonshine, teardrop in my eye LA MI Country roads, take me home FA#m RE to the place I belong LA MI West Virginia, mountain mamma, RE LA take m

Diff Between String Isnullorempty Vs String.isnullorwhitespace Code Example

Example: string isnullorempty vs isnullorwhitespace /* IsNullOrWhiteSpace is a convenience method that is similar to the following code, except that it offers superior performance: */ return String . IsNullOrEmpty ( value ) || value . Trim ( ) . Length == 0 ; /* White-space characters are defined by the Unicode standard. The IsNullOrWhiteSpace method interprets any character that returns a value of true when it is passed to the Char.IsWhiteSpace method as a white-space character. */

Can I Use Dispensers Or Droppers To Auto-replant Crops?

Answer : In vanilla Minecraft, wheat, carrots, and potatoes must be planted by hand, although they can be automatically harvested with water or pistons. You might be able to get the functionality you want with a mod, but I don't know of any. Sorry! No, dispenser nor droppers can plant seeds. However, as an alternative you can put a villager farmer there and he will automatically plant seeds.

Div Next To Each Other Html Css Code Example

Example: display div next to eachother display : inline-block ;

Poppins Google Font Family Url Code Example

Example: css poppins font <style> @import url ( 'https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap' ) ; </style>

Python Ceiling Division Code Example

Example: python floor import math x = 3.86356 math. floor ( x ) # Returns : 3 math. ceil ( x ) # Returns : 4

Create A Text File Using Python Code Example

Example 1: python make txt file file = open ( "text.txt" , "w" ) file . write ( "Your text goes here" ) file . close ( ) 'r' open for reading ( default ) 'w' open for writing , truncating the file first 'x' open for exclusive creation , failing if the file already exists 'a' open for writing , appending to the end of the file if it exists Example 2: open text file in python f = open ( "Diabetes.txt" , 'r' ) f . read ( ) Example 3: python file handling with open ( 'filename' , 'a' ) as f : # able to append data to file f . write ( var1 ) # Were var1 is some variable you have set previously f . write ( 'data' ) f . close ( ) # You can add this but it is not mandatory with open ( 'filename' , 'r' ) as f : # able to read data from file ( also is the default mode when opening a file in python ) with open ( 'filename'