Skip to content

Instantly share code, notes, and snippets.

View zmilan's full-sized avatar

Milan Zivkovic zmilan

View GitHub Profile
@zmilan
zmilan / linux-setup.sh
Created April 12, 2024 10:00 — forked from dhh/linux-setup.sh
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl docker.io \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@zmilan
zmilan / awesome-selfhosted-sorted-by-stars.md
Created October 31, 2023 15:50 — forked from kvnxiao/awesome-selfhosted-sorted-by-stars.md
awesome-selfhosted-sorted-by-stars.md

Awesome-Selfhosted

Awesome

Selfhosting is the process of locally hosting and managing applications instead of renting from SaaS providers.

This is a list of Free Software network services and web applications which can be hosted locally. Non-Free software is listed on the Non-Free page.

See Contributing.

@zmilan
zmilan / postgres-cheatsheet.md
Created April 1, 2020 14:11 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

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)
@zmilan
zmilan / nearest.php
Last active October 10, 2019 17:32
find the nearest key, value, and delta from provided array of data.
<?php
/**
* Example of usage and results
* $a = [ 7, -10, 13, 8, 4, -7.2, -12, -3.7, 3.5, -9.6, 6.5, -1.7, -6.2, 7 ];
* print_r(nearest(-3.1, $a)); // idx = 7, delta = 0.6, val = -3.7
* print_r(nearest(7, $a)); // idx = 0, delta = 0, val = 7
* print_r(nearest(0, $a)); // idx = 11, delta = 1.7, val = -1.7
*/
function nearest($needle, $haystack) {
// do some basic check of inputs
@zmilan
zmilan / home.tmpl
Created April 18, 2019 19:00 — forked from campoy/home.tmpl
Electron-like html+golang app
<html>
<head>
<title>Hello, from Go</title>
</head>
<body>
<h1>Hello</h1>
<p>
This is Go code running, {{.}}
</p>
</body>
@zmilan
zmilan / design.md
Created January 7, 2019 17:37 — forked from arpit/design.md
@zmilan
zmilan / Db.php
Created June 11, 2016 04:58 — forked from cherifGsoul/Db.php
Proof of concept and example how to implement facades for yii2 components
<?php
namespace app\components\facades;
/**
* Example how to use the facade class
* uses yii\web\Connection
*/
class Db extends Facade
{
@zmilan
zmilan / js-micro.js
Created May 31, 2016 06:20 — forked from yuval-a/js-micro.js
Javascript micro-optimizations
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
var obj = {};
// property === undefined is faster than hasOwnProperty(property)
// http://jsperf.com/hasownproperty-vs-in-vs-undefined/17