Skip to content

Instantly share code, notes, and snippets.

View Ephygtz's full-sized avatar

Ephraim Githinji Ephygtz

View GitHub Profile
@Ephygtz
Ephygtz / promisesJs.js
Created February 16, 2024 15:13
Working with JS Promises
Here are the key points for working with Promises:
A Promise can be pending, fulfilled, or rejected
A Promise is settled if it is either fulfilled or rejected
Use then to get the fulfilled value of a Promise
Use catch to handle errors
Use finally to perform cleanup logic that you need in either the success or error case
Chain Promises together to perform asynchronous tasks in sequence
Use Promise.all to get a Promise that is fulfilled when all given Promises are fulfilled, or rejects when one of those Promises rejects
Use Promise.allSettled to get a Promise that is fulfilled when all given Promises are either fulfilled or rejected
@Ephygtz
Ephygtz / jsPractise.js
Last active February 16, 2024 13:26
JS practise algos
// Reserve first available seat in a two dimensional array
let seats = [
[1, 1, 0, 1, 0],
[0, 1, 1, 1, 0],
[1, 0, 1, 0, 0],
];
//traverse the array
function reserveFirstAvailableSeat(seats) {
for (let i = 0; i < seats.length; i++) {
@Ephygtz
Ephygtz / media-queries.css
Created July 26, 2019 09:03
CSS media queries
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
}

Writing good commit messages

Good commit messages serve at least three important purposes:

  • To speed up the reviewing process.

  • To help us write a good release note.

  • To help the future maintainers, say five years into the future, to find out why a particular change was made to the code or why a specific feature was added.

public class RemoveSelectedListViewItem extends Activity {
// Declare view variables
ListView mListview;
// define array with data to display on listview
String[] mCoffeeCocktails = {
"Espresso",
"Short Latte",
"Cappuccino",
double mLatitude = 0.0;
double mLongitude = 0.0;
private FusedLocationProviderClient mFusedLocationClient;
// mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
// ^ to be instatiated inside onCreate method
public void fetchGPS() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
@Ephygtz
Ephygtz / README-Template.md
Created June 25, 2018 06:36 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

HTML/CSS/JS Resources

###Video

  • 30 Days to Learn HTML & CSS
    • Plenty of short tuts on html/css. (Kind of boring but definitely thorough)
  • Functional HTML5 & CSS3
    • Practical applications of html5 and css3, works its way into a site build with good info along the way
  • CSS Cross-Country
  • Very, very in depth look at css. Definitely the best video css resource I've come across.