Skip to content

Instantly share code, notes, and snippets.

@bansalankit92
bansalankit92 / Clean code.md
Created September 10, 2019 15:06
Lessons learnt from “The Clean Code” — Robert C. Martin

Even bad code can function. But if code isn't clean, it can bring a development organization to its knees.

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.
@miguelmota
miguelmota / util.php
Last active January 7, 2024 16:07
PHP byte array to hex, hex to byte array, string to hex, hex to string utility functions
<?php
function string2ByteArray($string) {
return unpack('C*', $string);
}
function byteArray2String($byteArray) {
$chars = array_map("chr", $byteArray);
return join($chars);
}
@yougg
yougg / proxy.md
Last active March 21, 2024 13:34
complete ways to set http/socks/ssh proxy environment variables

set http or socks proxy environment variables

# set http proxy
export http_proxy=http://PROXYHOST:PROXYPORT

# set http proxy with user and password
export http_proxy=http://USERNAME:PASSWORD@PROXYHOST:PROXYPORT

# set http proxy with user and password (with special characters)
@clue
clue / 2018-07-12 non-blocking-io-for-the-masses-webengdus.md
Last active February 10, 2022 11:17
Non-blocking I/O for the masses (WebEngDUS)

I/O is everywhere. I/O is slow. There's no denying it. Using traditional blocking I/O calls can thus be seen as a huge contributor to slow applications. This talk discusses how non-blocking I/O can help in building high performance, event-driven, reactive, concurrent, single-threaded applications (bingo). Don't worry, no need to install Node.js and npm install half the internet. Let's build high-performance applications from scratch with whatever language you're most comfortable with!

20 minutes talk at @WebEngDUS (2018-07-12)

Slides

The slides are available on https://speakerdeck.com/clue/non-blocking-io-for-the-masses-webengdus.

These slides were used as part of a presentation at @WebEngDUS. The full presentation took around 20 minutes including live demonstration and a short Q/A followed by some very nice discussions.

@mityukov
mityukov / git-rsync.sh
Last active November 4, 2023 18:48
Sync only files, added or modified since last commit
#!/bin/bash
## Installation:
# - make a file, called `git-rsync` in a directory, covered by your $PATH variable;
# - `chmod a+x` this file.
# - do the same for `listfiles` script
#
## Usage:
# 1. Syncing "dirties" (all the files you can see in the `git status` output)
# - before commiting, issue `git-rsync login@host:/destination/path/` command to sync all local changes to your stage server
@kana
kana / tomodachi.php
Created August 17, 2017 12:28
Don't confuse PHP & reference with other languages' reference.
<?php
function test_copy_on_write()
{
print "test_copy_on_write\n";
$a = 100;
xdebug_debug_zval('a');
//==> a: (refcount=1, is_ref=0)=100
@jhwheeler
jhwheeler / bigONotation.js
Last active February 21, 2024 18:36
Big O Notation Exercises
// 1. Even or odd
function isEven(value){
if (value % 2 == 0){
return true;
}
else
return false;
}
@Mikulas
Mikulas / Dockerfile
Last active March 11, 2022 12:34
Docker image PHP 7.1 alpine with extensions
FROM php:7.1-fpm-alpine
RUN apk add --update \
autoconf \
g++ \
libtool \
make \
&& docker-php-ext-install mbstring \
&& docker-php-ext-install mysqli \
@waldemarnt
waldemarnt / classes.js
Last active October 13, 2020 19:01
Fake,Spy,Stub, Mock
const Database = {
findAll() {}
}
class UsersController {
constructor(Database) {
this.Database = Database;
}
getAll() {
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active March 24, 2024 01:59
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096