Skip to content

Instantly share code, notes, and snippets.

View rslhdyt's full-sized avatar
🎯
Focusing

Risal Hidayat rslhdyt

🎯
Focusing
View GitHub Profile
@wojteklu
wojteklu / clean_code.md
Last active June 2, 2024 11:08
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

// Codility Bbinary Gap Test
function solution($N) {
// write your code in PHP5.5
$binaryNumber = decbin($N); // binary conversion of number
$trimmed = trim($binaryNumber, 0); // trim to remove trailing zeros
$binaryGap = explode("1",$trimmed); // explode
$binaryCount = array_map('strlen', $binaryGap);
return max($binaryCount); // returns the longest binary gap
@benlinton
benlinton / multiple_mysql_versions_for_development.md
Last active September 23, 2023 09:38
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions for Development

Options included below:

  • Using Docker docker-compose
  • Using Homebrew brew

Using Docker (recommended)

This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer. Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.

@JeffBelback
JeffBelback / docker-destroy-all.sh
Last active May 25, 2024 20:19
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
@ebouchut
ebouchut / disable_postgres_autostart_on_macos
Created April 16, 2014 08:42
Disable Postgres (installed with Homebrew) autostart on MacOS
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@pcreux
pcreux / 0-gourmet-service-objects.md
Last active August 21, 2022 15:32
Gourmet Service Objects - Lightning Talk - http://vanruby.org - Feb 27, 2014

Gourmet Service objects

 @pcreux

 Feb 27, 2014
 http://vanruby.org
@darul75
darul75 / helper_jpeglib.txt
Last active August 23, 2017 08:08
Max OS fatal error: 'jpeglib.h' file not found
Use Brew
> brew install libjpeg
find /usr | grep "libjpeg"
find /opt | grep "libjpeg"
Here what I have done
@denji
denji / nginx-tuning.md
Last active June 1, 2024 17:44
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@laracasts
laracasts / test.php
Last active July 10, 2018 16:33
Transactions for functional/integration tests.
<?php
class ExampleTest extends TestCase {
public function setUp()
{
parent::setUp();
DB::beginTransaction();
}
@richnicholls404
richnicholls404 / gist:7449378
Last active October 27, 2020 06:09
Register Service Provider and assign a Facade alias programatically in Laravel (such as inside a package)
<?php namespace Cavedwellerrich\MyPackage;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
class MyPackageServiceProvider extends ServiceProvider {
//...
public function register()