Skip to content

Instantly share code, notes, and snippets.

View almokhtarbr's full-sized avatar
👋

almokhtar almokhtarbr

👋
  • 02:47 (UTC -04:00)
View GitHub Profile
filters : {
currency(value){
var formatter = Intl.NumberFormat('en-US',
{
style:'currency',
currency:'USD',
minimumFractionDigits : 0
});
return formatter.format(value);
@almokhtarbr
almokhtarbr / Podcasts2018.md
Created September 1, 2018 20:10 — forked from adamayd/Podcasts2018.md
Web Development Podcasts for Beginners in 2018

Web Development Podcasts for Beginners in 2018

Commuting to work from east of Baltimore to Washington DC leaves a lot of time in the car. While driving to work one day early in my web development career, I wondered if there is such a thing as a web development podcast. How would you pull off live coding on a “radio” podcast. Well, you don’t. Well, sometimes they do, but the moral of the story is that I was shocked to find that not only are there web development podcasts, there are a lot of them and really good ones to boot. These podcasts have become staples to my learning and I recommend them to everyone who is just starting out. While there are plenty to listen to, I recommend starting with these. You’ll have plenty of time later to load up deep dives into the V8 JavaScript engine later.

Technology Podcasts

These podcasts are focused more on the technologies used in web development and their use cases.

Syntax - The new kid on the block and by far my favorite right now. Syn

@almokhtarbr
almokhtarbr / gist:8daa66cb6720da9955506e2c3cbc509a
Created September 4, 2018 19:09
My alias for using phpunit via composer package manager
alias phpunit="if [ -f \"./vendor/bin/phpunit\" ]; then php vendor/bin/phpunit; else echo \"It seems you don't have phpunit installed via composer\"; fi"
1. Increments and Decrements
Instead of this:
$article = Article::find($article_id);
$article->read_count++;
$article->save();
You can do this:
$article = Article::find($article_id);
$article->increment('read_count');
Oftentimes you would have a public area, an admin (dashboard) area, and sometimes an API - all inside a single Laravel project. A really good idea would be to separate the files for each area so that your project structure is more clean and there are no unexpected mix-ups. Let's do just that.
The Routes
Having all the routes in the routes/web.php file can get messy and confusing. Let's start with organizing routes for different areas of your web app into separate files. This can be done in the app/Providers/RouteServiceProvider.php file - open it. By the way, I'm working in a fresh Laravel 5.6 project here.
Anyway, if you scroll down a bit you will see the map() method which gets called when a user refreshes a page. It simply calls 2 further methods, which in turn create 2 route groups - one for the API and one for the web (so the web and the API routes are actually separated by default).
/**
* Define the routes for the application.
*
@almokhtarbr
almokhtarbr / redis_cheatsheet.bash
Created September 9, 2018 22:38 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
/* *******************************************************************************************
* GLOBAL CONFIG
* Vue.config is an object containing Vue’s global configurations.
* You can modify its properties listed below before bootstrapping your application.
* https://vuejs.org/v2/api/#Global-Config
* ******************************************************************************************* */
// Configure whether to allow vue-devtools inspection
Vue.config.devtools = true
/* *******************************************************************************************
* GLOBAL OBJECTS > ARRAY
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
* ******************************************************************************************* */
// Global object: properties
Array.length // Reflects the number of elements in an array
// Global object: methods
@almokhtarbr
almokhtarbr / README.md
Created September 9, 2018 22:43 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet