From 76550dfa3c5ba1628f06558b6545be1187ec3b1f Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Sun, 19 Sep 2021 12:10:20 +0200 Subject: [PATCH 1/2] Add Godot scripting starting notes --- DotNet/ASP.NET/Blazor.md | 2 +- DotNet/ASP.NET/REST API.md | 27 +++-- DotNet/ASP.NET/WebForms/Page.aspx.cs.md | 26 +++++ DotNet/ASP.NET/WebForms/Page.aspx.md | 58 ++++++++++ DotNet/C#/Async Programming.md | 2 +- DotNet/C#/C#.md | 2 +- DotNet/C#/Reactive Extensions.md | 2 +- DotNet/Godot/Scripting.md | 140 ++++++++++++++++++++++++ 8 files changed, 243 insertions(+), 16 deletions(-) create mode 100644 DotNet/ASP.NET/WebForms/Page.aspx.cs.md create mode 100644 DotNet/ASP.NET/WebForms/Page.aspx.md create mode 100644 DotNet/Godot/Scripting.md diff --git a/DotNet/ASP.NET/Blazor.md b/DotNet/ASP.NET/Blazor.md index a8cff95..8d1975a 100644 --- a/DotNet/ASP.NET/Blazor.md +++ b/DotNet/ASP.NET/Blazor.md @@ -148,7 +148,7 @@ Project ```cs - // for component routing + diff --git a/DotNet/ASP.NET/REST API.md b/DotNet/ASP.NET/REST API.md index a96e6f5..843f3e2 100644 --- a/DotNet/ASP.NET/REST API.md +++ b/DotNet/ASP.NET/REST API.md @@ -48,25 +48,28 @@ namespace .Profiles } ``` -In `StartUp.cs`: +## Controller (No View) + +Uses [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) to recieve a suitable implementation of `IEntityRepo`, + +### Service Lifetimes + +- `AddSingleton`: same for every request +- `AddScoped`: created once per client +- `Transient`: new instance created every time + +In `Startup.cs`: ```cs +// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - // other services - - // let AutoMapper know in what assemblies are the profiles defined - services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); - - // or create a MapperConfiguration - services.AddAutoMapper(cfg => { - cfg.CreateMap(); - cfg.AddProfile(); - }) + services.AddControllers(); + services.AddScoped(); // map the interface to its implementation, needed for dependency injection } ``` -### Controller with DTOs +### Request Mappings ```cs using .Model; diff --git a/DotNet/ASP.NET/WebForms/Page.aspx.cs.md b/DotNet/ASP.NET/WebForms/Page.aspx.cs.md new file mode 100644 index 0000000..c529db2 --- /dev/null +++ b/DotNet/ASP.NET/WebForms/Page.aspx.cs.md @@ -0,0 +1,26 @@ +# Page.aspx.cs + +```cs +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Project +{ + public partial class Default : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void Control_Event(object sender, EventAtgs e) + { + // actions on event trigger + } + } +} +``` diff --git a/DotNet/ASP.NET/WebForms/Page.aspx.md b/DotNet/ASP.NET/WebForms/Page.aspx.md new file mode 100644 index 0000000..d3f505e --- /dev/null +++ b/DotNet/ASP.NET/WebForms/Page.aspx.md @@ -0,0 +1,58 @@ +# Page.aspx + +The fist loaded page is `Default.aspx` and its undelying code. + +```html + +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Project.Default" %> + + + + + + + + + +
+
+
+
+ + +``` + +## ASP.NET Directives + +### Page Directive + +```cs +<%@ Page Language="C#" // define language used (can be C# or VB) + AutoEventWireup="true" // automatically create and setup event handlers + CodeBehind="Default.aspx.cs" // define the underlying code file + Inherits="EmptyWebForm.Default" %> +``` + +## Web Controls + +```xml + + + + + + + + + +LINK TEXT + +BUTTON TEXT + + + + + + + +``` diff --git a/DotNet/C#/Async Programming.md b/DotNet/C#/Async Programming.md index 48a3e39..6981fb9 100644 --- a/DotNet/C#/Async Programming.md +++ b/DotNet/C#/Async Programming.md @@ -160,4 +160,4 @@ protected async void MyButton_Click(object sender, EventArgs e) // We may actually be on another *thread*, but we have the same ASP.NET request context. Response.Write("File downloaded!"); } -``` \ No newline at end of file +``` diff --git a/DotNet/C#/C#.md b/DotNet/C#/C#.md index b11307c..00763b9 100644 --- a/DotNet/C#/C#.md +++ b/DotNet/C#/C#.md @@ -2907,4 +2907,4 @@ In this case, the method must also be declared as `static`. ```cs [DllImport("avifil32.dll")] private static extern void AVIFileInit(); -``` \ No newline at end of file +``` diff --git a/DotNet/C#/Reactive Extensions.md b/DotNet/C#/Reactive Extensions.md index f86eadd..3da0dfc 100644 --- a/DotNet/C#/Reactive Extensions.md +++ b/DotNet/C#/Reactive Extensions.md @@ -12,7 +12,7 @@ of an Rx source demand to be given the next item. Instead, Rx uses a *push* mode Because Rx implements standard LINQ operators, it's possible to write queries against a live source. Rx goes beyond standard LINQ, adding its own operators that take into account the temporal nature of a live event source. -## Foundamental Interfaces +## Fundamental Interfaces The two most important types in Rx are the `IObservable` and `IObserver` interfaces. They are important enough to be in the System namespace. The other parts of Rx are in the `System.Reactive` NuGet package. diff --git a/DotNet/Godot/Scripting.md b/DotNet/Godot/Scripting.md new file mode 100644 index 0000000..8fcf91a --- /dev/null +++ b/DotNet/Godot/Scripting.md @@ -0,0 +1,140 @@ +# Godot Scripting + +## Basics + +```cs +using Godot; + + +public class NodeName : NodeType +{ + [Export] // make variable visible in inspector + Type variable = value; + + + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + GetNode("NodeName"); // fetch a child node in the scene + GetNode("ParentNode/ChildNode"); // fetch a child node in the scene + + AddToGroup("Group"); // add a node to a group (similar to tags) + + GetTree().CallGroup("Group", "Function"); // call Function on all group members + var groupMembers = GetTree().GetNodesInGroup("Group"); + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(float delta) + { + + } + + public void _OnEmitterSignal() { } +} +``` + +### Overridable Functions + +```cs +public override void _EnterTree() +{ + // When the node enters the Scene Tree, it becomes active and this function is called. + // Children nodes have not entered the active scene yet. + // In general, it's better to use _ready() for most cases. + base._EnterTree(); +} + +public override void _Ready() +{ + // This function is called after _enter_tree, but it ensures + // that all children nodes have also entered the Scene Tree, + // and became active. + base._Ready(); +} + +public override void _ExitTree() +{ + // When the node exits the Scene Tree, this function is called. + // Children nodes have all exited the Scene Tree at this point and all became inactive. + base._ExitTree(); +} + +public override void _Process(float delta) +{ + // This function is called every frame. + base._Process(delta); +} + +public override void _PhysicsProcess(float delta) +{ + // This is called every physics frame. + base._PhysicsProcess(delta); +} +``` + +### Creating Nodes + +```cs +private Sprite _sprite; + +public override void _Ready() +{ + base._Ready(); + + _sprite = new Sprite(); // Create a new sprite + + AddChild(_sprite); // Add it as a child of this node + _sprite.Free(); // Immediately removes the node from the scene and frees it. +} +``` + +**Note**: When a node is freed, it also frees all its child nodes. + +The safest way to delete a node is by using `Node.QueueFree()`. This erases the node safely during idle. + +### Instantiating Scenes + +```cs +// STEP 1: load the scene +var scene = GD.Load("res://scene.tscn"); // Will load when the script is instanced. + +// STEP 2: instantiate the scene-node +var node = scene.Instance(); +AddChild(node); +``` + +The advantage of this two-step process is that a packed scene may be kept loaded and ready to use so that it's possible to create as many instances as desired. +This is especially useful to quickly instance several enemies, bullets, and other entities in the active scene. + +## Signals + +Signals are Godot's version of the *observer* pattern. They allow a node to send out a message that other nodes can listen for and respond to. + +Signals are a way to decouple game objects, which leads to better organized and more manageable code. Instead of forcing game objects to expect other objects to always be present, they can instead emit signals that all interested objects can subscribe to and respond to. + +```cs +public override _Ready() +{ + GetNode("Node").Connect("signal", targetNode, nameof(TargetFunction)); // connect node and signal +} + +// Signal Handler +public void OnEmitterSignal() { } +``` + +### Custom Signals + +```cs +public class Node : Node2D +{ + [Signal] + public delegate void CustomSignal(Type arg, ...); + + public override void _Ready() + { + EmitSignal(nameof(CustomSignal), args); + } +} +``` From 51a1738c74c1130d49e9803a0ed7214ce127abfc Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Mon, 20 Sep 2021 19:35:32 +0200 Subject: [PATCH 2/2] Fix typos --- Android/Activity.kt.md | 49 +++--- Android/Adapter.kt.md | 4 +- Android/Gradle & Building.md | 14 +- Android/MapsActivity.md | 6 +- Android/SQLite.md | 12 +- Android/activity.xml.md | 8 +- Bash/Bash Commands.md | 38 ++--- Bash/Bash Scripting.md | 32 ++-- C++/C++.md | 96 +++++------ Database/MongoDB.md | 46 +++--- Database/Redis.md | 6 +- Database/SQL.md | 61 ++++--- DotNet/ASP.NET/App Configuration.md | 4 +- DotNet/ASP.NET/Blazor.md | 6 +- DotNet/ASP.NET/Filters.md | 34 ++-- DotNet/ASP.NET/MVC.md | 16 +- DotNet/ASP.NET/Middleware.md | 14 +- DotNet/ASP.NET/REST API.md | 6 +- DotNet/ASP.NET/Razor Pages.md | 14 +- DotNet/ASP.NET/Razor Syntax.md | 12 +- DotNet/ASP.NET/SignalR.md | 6 +- DotNet/ASP.NET/WebForms.md | 4 +- DotNet/ASP.NET/WebForms/Page.aspx.cs.md | 2 +- DotNet/ASP.NET/WebForms/Page.aspx.md | 4 +- DotNet/C#/C# Collections.md | 40 ++--- DotNet/C#/LINQ.md | 10 +- DotNet/C#/Reactive Extensions.md | 2 +- DotNet/Database/ADO.NET.md | 6 +- DotNet/Database/EntityFramework.md | 2 +- DotNet/Unity/Collisions.md | 28 ++-- DotNet/Unity/Coroutines.md | 4 +- DotNet/Unity/Input Manager.md | 6 +- DotNet/Unity/Prefabs Instantiation.md | 4 +- DotNet/Unity/Raycasting.md | 20 +-- DotNet/Unity/Scripting.md | 28 ++-- DotNet/Unity/Vector, Tranfrorm, Space.md | 22 +-- DotNet/Xamarin/App.xaml.md | 6 +- DotNet/Xamarin/Page.xaml.md | 8 +- DotNet/Xamarin/ViewModel.cs.md | 2 +- GraphQL.md | 40 ++--- HTML/HTML.md | 36 ++-- Java/DAO.md | 6 +- Java/Java Collection Framework.md | 24 +-- Java/Java Web/JSP.md | 115 ------------- Java/Java Web/Servlet.md | 2 +- Java/Java.md | 154 +++++++++--------- .../Spring Project Structure.md | 8 +- JavaScript/AJAX.md | 6 +- JavaScript/DOM.md | 12 +- JavaScript/Events & Animation.md | 6 +- JavaScript/JavaScript.md | 86 +++++----- JavaScript/React/React Router.md | 10 +- JavaScript/React/React Tests.md | 12 +- JavaScript/React/React.md | 16 +- JavaScript/React/Redux Tests.md | 12 +- JavaScript/React/Redux.md | 16 +- JavaScript/Svelte/Svelte.md | 6 +- JavaScript/jQuery.md | 8 +- Kotlin/kotlin.md | 10 +- Markdown.md | 6 +- Node.js/Node.js.md | 2 +- Node.js/Standard Packages/events.md | 4 +- Node.js/Standard Packages/fs.md | 4 +- Node.js/Standard Packages/http(s).md | 6 +- Node.js/Standard Packages/os.md | 2 +- Node.js/Standard Packages/process.md | 2 +- PHP/Composer & Autoloading.md | 6 +- PHP/Database.md | 14 +- PHP/Dependecy Injection.md | 6 +- PHP/PHP.md | 62 +++---- PHP/PSR-7.md | 2 +- PHP/Simple_MVC/Simple_MVC.md | 4 +- PHP/Templates with Plates.md | 10 +- PHP/Unit Testing.md | 22 +-- PHP/Web.md | 18 +- PowerShell/Powershell Commands.md | 4 +- PowerShell/Powershell Scripting.md | 20 +-- RegularExpressions.md | 12 +- Rust/Cargo.md | 20 +-- Rust/Rust.md | 74 ++++----- Swift/Swift.md | 38 ++--- iOS/AppDelegate (XCode 11) .md | 2 +- iOS/ContentView.md | 26 +-- iOS/SceneDelegate (XCode 11).md | 2 +- 84 files changed, 759 insertions(+), 876 deletions(-) delete mode 100644 Java/Java Web/JSP.md diff --git a/Android/Activity.kt.md b/Android/Activity.kt.md index 2168641..508c903 100644 --- a/Android/Activity.kt.md +++ b/Android/Activity.kt.md @@ -50,7 +50,7 @@ class MainActivity : AppCompatActivity() { ### Passing data between activities -In *lauching* activity: +In *laughing* activity: ```kotlin private fun openActivity() { @@ -58,7 +58,7 @@ private fun openActivity() { //target to open Intent(opener, opened) val intent = Intent(this, Activity::class.java) - //pass data to lauched activity + //pass data to launched activity intent.putExtra("identifier", value) startActivity(intent) //launch another activity @@ -76,7 +76,7 @@ val identifier = intent.getExtra("identifier") ### Resources Hooks ```kotlin -R.. //access to reource +R.. //access to resource ContextCompat.getColor(this, colorResource) //extract color from resources getString(stringResource) //extract string from resources @@ -98,14 +98,14 @@ in `Activity.kt`: ```kotlin var element = findViewById(R.id.) //old method -.poperty = value //access and modify view contents +.popery = value //access and modify view contents ``` ## Activity Components ### Snackbar -Componed derived from material design. If using old API material design dependency must be set in gradle. +Component derived from material design. If using old API material design dependency must be set in gradle. In `build.gradle (Module:app)`: @@ -144,10 +144,10 @@ startActivity(intent) val intent = Intent(Intent.ACTION_SEND) intent.setType("text/plain") //specifying shared content type -intent.putExtra(Intent.EXTRA_MAIL, "mail@address") //open mail client and precompile field if share w/ mail +intent.putExtra(Intent.EXTRA_MAIL, "mail@address") //open mail client and pre-compile field if share w/ mail intent.putExtra(Intent.EXTRA_SUBJECT, "subject") intent.putExtra(Intent.EXTRA_TEXT, "text") //necessary since type is text -startActivity(Initent.startChooser(intent, "chooser title")) //let user choose the share app +startActivity(Intent.startChooser(intent, "chooser title")) //let user choose the share app ``` ### App Google Maps @@ -186,21 +186,22 @@ In `AndroidManifest.xml`: //https://developer.android.com/training/permissions/requesting //intercept OS response to permission popup -override fun onRequestPermissionResult(requestCode: Int, permissins: Array, grantResults: IntArray) { +override fun onRequestPermissionResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) } fun checkCallPermission() { //check if permission to make a call has been granted if (ContextCompact.checkSelfPermission(context!!, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { - // i permission has not been granted request it (opens OS popup, no listener aviable) - ActivityCompat.requestPermissions(context!!, arrrayOf(android.Manifest.permission.CALL_PHONE), requestCode) //request code neeeds to be specific for the permission + // if permission has not been granted request it (opens OS popup, no listener available) + // request code needs to be specific for the permission + ActivityCompat.requestPermissions(context!!, arrayOf(android.Manifest.permission.CALL_PHONE), requestCode) } else { call() //if permission has been already given } } -@SuppressLint("MissingPermission") // suppress warnig of unhandled permission (handled in checkCallPermission) +@SuppressLint("MissingPermission") // suppress warning of unhandled permission (handled in checkCallPermission) fun call() { val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel: ")) startActivity(intent) @@ -230,11 +231,11 @@ recycleView.LayoutManager = layoutManager // assign LayoutManager for the recyc // handle adapter var containing null value if (array != null) { - adapter = RecyclerViewItemAdapter(array!!) // valorize adapter with a adaper object - recyclerView.adapter = adapter // assing adapter to the recyclerView + adapter = RecyclerViewItemAdapter(array!!) // valorize adapter with a adapter object + recyclerView.adapter = adapter // assign adapter to the recyclerView } -// add or remom item +// add or remove item // tell the adapter that something is changed adapter?.notifyDataSetChanged() @@ -247,7 +248,7 @@ adapter?.notifyDataSetChanged() ```kotlin webView.webViewClient = object : WebViewClient() { - // avoid openiing browsed by default, open webview instead + // avoid opening browsed by default, open webview instead override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { view?.loadUrl(url) // handle every url return true @@ -261,7 +262,7 @@ webView.webViewClient = object : WebViewClient() { } Intent(Intent.ACTION_VIEW, Uri.parse(url).apply){ - startActivity(this) // open br br owser/app when the website changes to external URL + startActivity(this) // open browser/app when the website changes to external URL } return true } @@ -291,7 +292,7 @@ Import in `build.gradle`: implementation 'com.android.volley:volley:1.1.1' ``` -Perrmissions in `AndroidManifest.xml`: +Permissions in `AndroidManifest.xml`: ```xml @@ -299,7 +300,7 @@ Perrmissions in `AndroidManifest.xml`: ### Make the request -Subsequnt requests sould be delayed to avoid allowing the user to make too frequent requests. +Subsequent requests should be delayed to avoid allowing the user to make too frequent requests. ```kotlin private lateinit var queue: RequestQueue @@ -358,14 +359,14 @@ private fun getJSONArrayRequest(){ override fun onStop() { super.onStop() - queue?.cancellAll("TAG") // delete all request with a particular tag when the activity is closed (avoid crash) + queue?.cancelAll("TAG") // delete all request with a particular tag when the activity is closed (avoid crash) } ``` ### Parse JSON Request ```kotlin -Response.Litener { response -> +Response.Listener { response -> var value = response.getSting("key") } ``` @@ -374,19 +375,19 @@ Response.Litener { response -> ### Singleton -Object instantiated during app init and is destroid only on app closing. It can be used for data persistance since is not affected by the destruction of an activity. +Object instantiated during app init and is destroyed only on app closing. It can be used for data persistance since is not affected by the destruction of an activity. ```kotlin // Context: Interface to global information about an application environment. -class Singleton consturctor(context: Context) { +class Singleton constructor(context: Context) { companion object { @Volatile private var INSTANCE: Singleton? = null - // syncronized makes sure that all instances of the singleton are actually the only existing one - fun getInstance(context: Contecxt) = INSTANCE ?: syncronized(this) { + // synchronized makes sure that all instances of the singleton are actually the only existing one + fun getInstance(context: Context) = INSTANCE ?: synchronized(this) { INSTANCE ?: Singleton(context).also { INSTANCE = it } diff --git a/Android/Adapter.kt.md b/Android/Adapter.kt.md index fc3b74d..0c99941 100644 --- a/Android/Adapter.kt.md +++ b/Android/Adapter.kt.md @@ -26,10 +26,10 @@ class RecipeAdapter : RecyclerView.Adapter { } } - //adapter contructor, takes list of data + //adapter contractor, takes list of data constructor(myDataset: ArrayList/*, mContext: Context?*/){ mDataset = myDataset - //mContenxt = mContext + //mContext = mContext } diff --git a/Android/Gradle & Building.md b/Android/Gradle & Building.md index faca301..464b24e 100644 --- a/Android/Gradle & Building.md +++ b/Android/Gradle & Building.md @@ -18,18 +18,18 @@ android { } ``` -## Distribuiting the app +## Distributing the app ### APK vs Bundle -- APK: android executable, contains all assets of the app (multiplr versions for each device). The user downloads all the assets. -- Bundle: split the assets based on dedvice specs. The users donwloads only the assest needed for the target device. +- APK: android executable, contains all assets of the app (multiple versions for each device). The user downloads all the assets. +- Bundle: split the assets based on device specs. The users downloads only the assets needed for the target device. ### APK generation & [App Signing](https://developer.android.com/studio/publish/app-signing) - **Key store path**: location where the keystore file will be stored. -- **Key store password**: secure password for the keystore (**to be rememberd**). -- **Key alias**: identifying name for the key (**to be rememberd**). -- **Key password**: secure password for the key (**to be rememberd**). +- **Key store password**: secure password for the keystore (**to be remembered**). +- **Key alias**: identifying name for the key (**to be remembered**). +- **Key password**: secure password for the key (**to be remembered**). -The ketstore identifies the app and it's developers. It's needed for APK generation and releases distribution. +The keystore identifies the app and it's developers. It's needed for APK generation and releases distribution. diff --git a/Android/MapsActivity.md b/Android/MapsActivity.md index 060c742..a203aae 100644 --- a/Android/MapsActivity.md +++ b/Android/MapsActivity.md @@ -2,13 +2,13 @@ [Google Maps Docs](https://developers.google.com/maps/documentation/android-sdk/intro) -Activity sould be **Google Maps Activity**. +Activity should be **Google Maps Activity**. In `google_maps_api.xml`: ```xml - API_KEY + API_KEY ``` @@ -63,7 +63,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, mMap.setOnInfoWindowClickListener(this) // Add a marker and move the camera - val location = LatLng(-34.0, 151.0) // set loaction with latitude and longitude + val location = LatLng(-34.0, 151.0) // set location with latitude and longitude mMap.addMarker(MarkerOptions().position(location).title("Marker in ...")) // ad the marker to the map with a name and position mMap.moveCamera(CameraUpdateFactory.newLatLng(location)) // move camera to the marker diff --git a/Android/SQLite.md b/Android/SQLite.md index 2ef2309..e827a42 100644 --- a/Android/SQLite.md +++ b/Android/SQLite.md @@ -31,17 +31,17 @@ class DatabaseHelper( Make data persistent. ```kotlin -class AppSingleton consturctor(context: Context) { +class AppSingleton constructor(context: Context) { - var dataabse: SQLiteDatabase? = null // point to database file in memory + var database: SQLiteDatabase? = null // point to database file in memory companion object { @Volatile private var INSTANCE: AppSingleton? = null - // syncronized makes sure that all instances of the singleton are actually the only existing one - fun getInstance(context: Contecxt) = INSTANCE ?: syncronized(this) { + // synchronized makes sure that all instances of the singleton are actually the only existing one + fun getInstance(context: Context) = INSTANCE ?: synchronized(this) { INSTANCE ?: Singleton(context).also { INSTANCE = it } @@ -75,10 +75,10 @@ override fun onCreate() { Controller to handle data from the objects and interact with the Database ```kotlin -sqLiteDatabse = AppISngleton.getInstance().database // reference to the database from the singleton +sqLiteDatabase = AppISingleton.getInstance().database // reference to the database from the singleton contentValues = ContentValues() // dict like structure to insert data in DB -contentValuest.put("DB_Column", value) // put data in the structure +contentValues.put("DB_Column", value) // put data in the structure // insertion query V1 sqLiteDatabase?.insert("table", null, contentValue) diff --git a/Android/activity.xml.md b/Android/activity.xml.md index 1d53bf9..ee7cb8a 100644 --- a/Android/activity.xml.md +++ b/Android/activity.xml.md @@ -4,7 +4,7 @@ ### Colors, Style, Strings -These resorsces are located in `app/src/main/res/values/.xml` +These resources are located in `app/src/main/res/values/.xml` `@color/colorName` -> access to *color definition* in `colors.xml` `@string/stringName` -> access to *string definition* in `strings.xml` (useful for localization) `@style/styleName` -> access to *style definition* in `styles.xml` @@ -65,7 +65,7 @@ A **View Group** or **Layout** is a container of Views. ``` -`android:layout_width`, `android:layout_heigth`: +`android:layout_width`, `android:layout_height`: * fixed value (dp, sp) * match_parent @@ -141,7 +141,7 @@ Layout that arranges other views either horizontally in a single column or verti ```xml @@ -164,7 +164,7 @@ The scroll view can only have one child. If the child is a layout than the layou ```xml diff --git a/Bash/Bash Commands.md b/Bash/Bash Commands.md index 528f612..274cff8 100644 --- a/Bash/Bash Commands.md +++ b/Bash/Bash Commands.md @@ -4,20 +4,20 @@ ## Basic Commands -### Elevated Priviledges and Users +### Elevated Privileges and Users [sudo vs su](https://unix.stackexchange.com/questions/35338/su-vs-sudo-s-vs-sudo-i-vs-sudo-bash/35342) ```bash -sudo su # login as root (user must be sudoer, root password not required) DANGEROUS -sudo -s # act as root and inherit current user enviroment (env as is now, along current dir and env vars) SAFE (can modify user enviroment) -sudo -i # act as root and and use a clean enviroment (goes to user's home, runs .bashrc) SAFEST +sudo su # login as root (user must be sudoers, root password not required) DANGEROUS +sudo -s # act as root and inherit current user environment (env as is now, along current dir and env vars) SAFE (can modify user environment) +sudo -i # act as root and and use a clean environment (goes to user's home, runs .bashrc) SAFEST sudo COMMAND # run a command w\ root permissions sudo -u USER COMMAND # run command as user su # become root (must know root password) DANGEROUS su - USER # change user and load it's home folder -su USER # change user but dont load it's home folder +su USER # change user but don't load it's home folder ``` ### Getting Info @@ -51,7 +51,7 @@ popd # return to previous directory (before pushd) ```sh touch FILE # change FILE timestamp fi exists, create file otherwise -cat [FILE] # concatenate files and print on statndard output (FD 1) +cat [FILE] # concatenate files and print on standard output (FD 1) cat >> FILE # append following content ot file (Ctrl+D to stop) file FILE # discover file extension and format stat FILE # display file or file system status @@ -60,7 +60,7 @@ tail # output the last part of a file tail [-nNUM] # output the last NUM lines more # filter for paging through text one screenful at a time -less # opposite of more (display big file in pages), navigate with arrow keys or spacebar +less # opposite of more (display big file in pages), navigate with arrow keys or space bar cut # remove sections from each line of files cut -[d --delimiter=DELIM] # use DELIM instead of TAB for field delimiter @@ -74,10 +74,10 @@ rmdir DIRECTORY # remove directory only if is empty mkdir DIRECTORY # make directories -mv SOURCE DESTINATION # move or raneme files +mv SOURCE DESTINATION # move or rename files mv SOURCE DIRECTORY # move FILE to DIRECTORY -cp SOURCE DESTINATION # copy SOURCE to DESTIANTION +cp SOURCE DESTINATION # copy SOURCE to DESTINATION ``` ### Files Permissions & Ownership @@ -125,7 +125,7 @@ chgrp [OPTION]... GROUP FILE... # change group ownership find [path] [expression] # search file in directory hierarchy find [start-position] -type f -name FILENAME # search for a file named "filename" find [start-position] -type d -name DIRNAME # search for a directory named "dirname" -find [path] -exec {} \; # ececute command on found items (identified by {}) +find [path] -exec {} \; # execute command on found items (identified by {}) [ -f "path" ] # test if a file exists [ -d "path" ] # test if a folder exists @@ -140,11 +140,11 @@ command | sudo tee FILE # operate on file w/o using shell as su echo # display a line of text echo "string" > FILE # write lin of text to file -echo "string" >> FILE # append line o ftext to end of file (EOF) +echo "string" >> FILE # append line of text to end of file (EOF) wget URL # download repositories to linux machine -curl # dovnlaod the contents of a URL +curl # download the contents of a URL curl [-I --head] # Fetch the headers only ps [-ax] # display processes @@ -161,8 +161,8 @@ diff FILES # compare files line by line shellcheck FILE # shell linter xargs [COMMAND] # build and execute command lines from standard input -# xargs reads items form the standard input, delimites by blanks or newlines, and executes the COMMAND one or more times with the items as argumests -watch [OPTIONS] COMMAND # execute a program periodically, showing output fullscreen +# xargs reads items form the standard input, delimited by blanks or newlines, and executes the COMMAND one or more times with the items as arguments +watch [OPTIONS] COMMAND # execute a program periodically, showing output full-screen watch -n SECONDS COMMAND # execute command every SECONDS seconds (no less than 0.1 seconds) ``` @@ -172,10 +172,10 @@ watch -n SECONDS COMMAND # execute command every SECONDS seconds (no less than ```bash sed # stream editor for filtering and transforming text -sed -E "s/REGEX/replacement/" # subsitute text ONCE (-E uses modern REGEX) -sed -E "s/REGEX/replacement/g" # subsitute text multiple times (every match) +sed -E "s/REGEX/replacement/" # substitute text ONCE (-E uses modern REGEX) +sed -E "s/REGEX/replacement/g" # substitute text multiple times (every match) -wc [FILE] # print newline, word and byte countd for each file +wc [FILE] # print newline, word and byte count for each file wc [-m --chars] FILE # print character count wc [-c --bytes] FILE # print bytes count wc [-l --lines] FILE # print lines count @@ -185,8 +185,8 @@ sort [FILE] # sort lines of a text file uniq [INPUT [OUTPUT]] # report or omit repeated lines (from INPUT to OUTPUT) uniq [-c --count] # prefix lines w/ number of occurrences -uniq [-d --repeated] # plrint only duplicare lines, one for each group -uniq [-D] # plrint only duplicare lines +uniq [-d --repeated] # print only duplicare lines, one for each group +uniq [-D] # print only duplicare lines paste [FILE] # merge lines of files paste [-d --delimiters=LIST] # use delimiters from LIST diff --git a/Bash/Bash Scripting.md b/Bash/Bash Scripting.md index 77cd8be..fc2f92d 100644 --- a/Bash/Bash Scripting.md +++ b/Bash/Bash Scripting.md @@ -10,7 +10,7 @@ Interactive mode --> shell waits for user's commands Non-interactive mode --> shell runs scripts -## File & Directories Permissons +## File & Directories Permissions File: @@ -35,12 +35,12 @@ Bash gets commands by reading lines. As soon as it's read enough lines to compose a complete command, bash begins running that command. Usually, commands are just a single line long. An interactive bash session reads lines from you at the prompt. Non-interactive bash processes read their commands from a file or stream. -Files with a hashbang as their first line (and the executable permission) can be started by your system's kernel like any other program. +Files with a shebang as their first line (and the executable permission) can be started by your system's kernel like any other program. ### First Line Of Bash `#!/bin/env bash` -Hashbang indicating whitch interpreter to use +shebang indicating which interpreter to use ### Simple Command @@ -73,7 +73,7 @@ command_1 || command_2 || ... # execute successive commands only if preceding o {command_1; command_2; ...} # sequence of commands executed as one ``` -### Functions (blocks of easely reusable code) +### Functions (blocks of easily reusable code) `function_name () {compound_command}` Bash does not accept func arguments, parentheses must be empty @@ -125,7 +125,7 @@ x>&-, x<&- # close FD x (stream disconnected from FD x) `*` matches any kind of text (even no text). `?` matches any single character. -`[characters]` mathces any single character in the given set. +`[characters]` matches any single character in the given set. `[[:classname:]]` specify class of characters to match. `{}` expand list of arguments (applies command to each one) @@ -137,7 +137,7 @@ x>&-, x<&- # close FD x (stream disconnected from FD x) `@(pattern [| pattern ...])` matches when any of the patterns in the list appears just once. ("one of ..."). `!(pattern [| pattern ...])` matches only when none of the patterns in the list appear. ("none of ..."). -## Command Substituition +## Command Substitution With Command Substitution, we effectively write a command within a command, and we ask bash to expand the inner command into its output and use that output as argument data for the main command. @@ -148,9 +148,9 @@ $(inner_command) # $ --> value-expansion prefix ## Shell Variables ```bash -varname=value # variable assignement -varname="$(command)" # command sobstituition, MUST be double-quoted -"$varname", "${varname}" # variable expansion, MUST be double-quoted (name substituited w/ varaible content) +varname=value # variable assignment +varname="$(command)" # command substitution, MUST be double-quoted +"$varname", "${varname}" # variable expansion, MUST be double-quoted (name substituted w/ variable content) $$ # pid $# # number of arguments passed @@ -158,7 +158,7 @@ $@ # all arguments passed ${n} # n-th argument passed to the command $0 # name of the script $_ # last argument passed to the command -$? # error message of the last (previous) comman +$? # error message of the last (previous) command !! # executes last command used (echo !! prints the last command) ``` @@ -173,7 +173,7 @@ $? # error message of the last (previous) comman `${parameter/#pattern/replacement}` replaces the string that matches the pattern at the beginning of the value with the replacement. `${parameter/%pattern/replacement}` replaces the string that matches the pattern at the end of the value with the replacement. `${#parameter}` expands the length of the value (in bytes). -`${parametr:start[:length]}` expands a part of the value, starting at start, length bytes long. +`${parameter:start[:length]}` expands a part of the value, starting at start, length bytes long. Counts from the end rather than the beginning by using a (space followed by a) negative value. `${parameter[^|^^|,|,,][pattern]}` expands the transformed value, either upper-casing or lower-casing the first or all characters that match the pattern. Omit the pattern to match any character. @@ -195,7 +195,7 @@ fi ### Test Command -`[[ arggument_1 argument_2 ]]` +`[[ argument_1 argument_2 ]]` ### Arithmetic expansion and evaluation @@ -212,7 +212,7 @@ fi [[ "$a" -le "$b" ]] # less than or equal to ``` -### Arithmetic Comperison Operators +### Arithmetic Comparison Operators ```bash (("$a" > "$b")) # greater than @@ -221,10 +221,10 @@ fi (("$a" <= "$b")) # less than or equal to ``` -### String Compatison Operators +### String Comparison Operators ```bash -[ "$a" = "$b" ] # is equal to (whitespace atoun operator) +[ "$a" = "$b" ] # is equal to (whitespace around operator) [[ $a == z* ]] # True if $a starts with an "z" (pattern matching) [[ $a == "z*" ]] # True if $a is equal to z* (literal matching) @@ -244,7 +244,7 @@ fi ```bash command_1 || command_2 # if command_1 fails executes command_2 -command_1 && command_2 # executes command_2 only if command_1 succedes +command_1 && command_2 # executes command_2 only if command_1 succeeds ``` ## Loops diff --git a/C++/C++.md b/C++/C++.md index 0e6ffeb..4992021 100644 --- a/C++/C++.md +++ b/C++/C++.md @@ -34,12 +34,12 @@ const type constant_name = value; ```cpp #include system("pause"); -getchar(); // waits imput from keyboard, if is last instruction will prevent closing console until satisfied +getchar(); // waits input from keyboard, if is last instruction will prevent closing console until satisfied ``` ### Namespace definition -Can be omitted and replaced by namespce`::` +Can be omitted and replaced by namespace`::` `using namespace ;` ### Main Function @@ -72,7 +72,7 @@ Type | Value Range | Byte `short` | -32768 to 32765 | 1 `unsigned short` | 0 to 65535 | 1 `int` | -2147483648 to 2147483647 | 4 -`unisgned int` | 0 to 4294967295 | 4 +`unsigned int` | 0 to 4294967295 | 4 `long` | -2147483648 to 2147483647 | 4 `unsigned long` | 0 to 4294967295 | 4 `long long` | | 8 @@ -105,7 +105,7 @@ Example | Type Example | Type ------------|------------- `3.14159L` | long double -`60.22e23f` | flaot +`60.22e23f` | float Code | Value ----------|--------------- @@ -123,7 +123,7 @@ Code | Value Escape Character | Character -------------------|----------------------------- -`\n` | neweline +`\n` | newline `\r` | carriage return `\t` | tab `\v` | vertical tab @@ -140,7 +140,7 @@ Escape Character | Character ```cpp cout << expression; // print line on screen (no automatic newline) -cout << expressin_1 << expreeeion_2; // concatenation of outputs +cout << expression_1 << expression_2; // concatenation of outputs cout << expression << "\n"; // print line on screen cout << expression << endl; // print line on screen @@ -153,19 +153,19 @@ printf_s("text %", variable); ### Input ```cpp -#iclude +#include cin >> var; //space terminates value cin >> var_1 >> var_2; //if used after cin >> MUST clear buffer with cin.ignore(), cin.sync() or std::ws -getline(stream, string, delimiter) //read input from stream (usially CIN) and store in in string, a different delimiter character can be set. +getline(stream, string, delimiter) //read input from stream (usually CIN) and store in in string, a different delimiter character can be set. #include scanf("%", &variable); // has problems, use SCANF_S -scanf_s("%", &variable); //return number of succescully accepted inputs +scanf_s("%", &variable); //return number of successfully accepted inputs ``` -### Fromat Specifiers %[width].[lenght][specifier] +### Format Specifiers %[width].[length][specifier] Specifier | Specified Format ------------|----------------------------------------- @@ -210,9 +210,9 @@ if (!(cin >> var)) // if cin fails to get an input #include cout << stew(print_size) << setprecision(num_digits) << var; //usage -setbase(base) //set numberica base [dec, hex, oct] +setbase(base) //set numeric base [dec, hex, oct] setw(print_size) //set the total number of characters to display -setprecision(num_digits) //sets the number of decimal digits to siaplay +setprecision(num_digits) //sets the number of decimal digits to display setfill(character) //use character to fill space between words ``` @@ -263,7 +263,7 @@ a `^` b, a `xor` b, | bitwise **XOR** a `<<` b | bitwise left shift a `>>` b | bitwise right shift -### Compound Assignement O +### Compound Assignment O Operator | Operation ------------|------------ @@ -297,7 +297,7 @@ abs(x); // absolute value labs(x); //absolute value if x is long, result is long fabs(x); //absolute value if x i float, result is float sqrt(x); // square root -ceil(x); // ceil function (next initeger) +ceil(x); // ceil function (next integer) floor(x); // floor function (integer part of x) log(x); // natural log of x log10(x); // log base 10 of x @@ -337,7 +337,7 @@ isxdigit(c); //true if c is HEX DIGIT ```cpp #include -tolower(c); //transfromas charatcer in lowercase +tolower(c); //transforms character in lowercase toupper(c); //transform character in uppercase ``` @@ -346,7 +346,7 @@ toupper(c); //transform character in uppercase ```cpp #include