Skip to content

Instantly share code, notes, and snippets.

pet the duck until exploded

Oleg Abrazhaev seyfer

pet the duck until exploded
View GitHub Profile
wojteklu /
Last active Aug 3, 2021
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

Kartones /
Last active Aug 3, 2021
PostgreSQL command line cheatsheet


Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
jeffochoa / Response.php
Last active Aug 3, 2021
Laravel HTTP status code
View Response.php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
nicklasos / download.php
Last active Aug 2, 2021
Curl PHP multiple files downloading
View download.php
function multiple_download(array $urls, $save_path = '/tmp')
$multi_handle = curl_multi_init();
$file_pointers = [];
$curl_handles = [];
// Add curl multi handles, one per file we don't already have
foreach ($urls as $key => $url) {
fgilio / axios-catch-error.js
Last active Aug 1, 2021
Catch request errors with Axios
View axios-catch-error.js
* Handling Errors using async/await
* Has to be used inside an async function
try {
const response = await axios.get('');
// Success 🎉
} catch (error) {
// Error 😨
justintv / .bashrc
Created Aug 17, 2009
Display git branch in bash prompt
View .bashrc
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
thensg / luhn-checksum.js
Last active Jul 29, 2021
Calculate or verify a Luhn (Mod10) checksum
View luhn-checksum.js
* Calculate a Luhn (Mod10) checksum
* -or-
* Verify the Luhn checksum of a credit card or IMEI number
* This implementation was adapted from the following sources:
* -
* -
barryvdh / _ide_helper.php
Last active Jul 28, 2021
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using
View _ide_helper.php
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
* @author Barry vd. Heuvel <>
* @see
namespace {
exit("This file should not be included, only analyzed by your IDE");
endolith / Has weird right-to-left characters.txt
Last active Jul 28, 2021
Unicode kaomoji smileys emoticons emoji
View Has weird right-to-left characters.txt
ibreathebsb / upload.js
Last active Jul 23, 2021
file upload from dataUrl with axios
View upload.js
// Note: only for modern browser
import axios from 'axios'
// helper function: generate a new file from base64 String
const dataURLtoFile = (dataurl, filename) => {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)