Skip to content

Instantly share code, notes, and snippets.

@waspar
waspar / vite.config.js
Created December 3, 2023 20:56 — forked from FbN/vite.config.js
vite.config.js node built-in polyfills
// yarn add --dev @esbuild-plugins/node-globals-polyfill
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
// yarn add --dev @esbuild-plugins/node-modules-polyfill
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
export default {
resolve: {
alias: {
@waspar
waspar / nginxproxy.md
Created December 3, 2023 20:53 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@waspar
waspar / php_array_walk_use
Created August 16, 2021 14:35
php_array_walk_use
array_walk(current($arResultTasksUsers), function ($value, $key) use (&$arData) {
$arData['TASKS_USERS_IDS'][$value['USER_ID']] = $value['USER_ID'];
});
@waspar
waspar / _media_queries.sass
Created April 4, 2020 10:04 — forked from poteto/_media_queries.sass
Sass media queries
// Standard device screen widths
$iphone-portrait: 320px
$iphone-landscape: 480px
$ipad-portrait: 767px
$ipad-landscape: 980px
$desktop: 1224px
$desktop-large: 1824px
// General device targeting
// Use: Only use if you want the style to apply to many devices
@waspar
waspar / linebreak.md
Created December 16, 2019 15:12
Line breaks in markdown
Hello  (<-- two spaces)
World

Hello
World


@waspar
waspar / objects_arrays.md
Created November 22, 2019 08:21 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@waspar
waspar / aes_enc_dec.php
Created October 21, 2019 13:47 — forked from turret-io/aes_enc_dec.php
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well
@waspar
waspar / vue.md
Created September 25, 2019 11:08 — forked from DawidMyslak/vue.md
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modyfing state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@waspar
waspar / xdebug_installation.md
Created August 21, 2019 15:45 — forked from joseluisq/xdebug_installation.md
Install PHP Xdebug on Fedora / CentOS x64

PHP Xdebug installation on Fedora/CentOS x64

First, install xdebug package on system:

$ sudo yum install php-pecl-xdebug.x86_64

Or with DNF:

  • List all modified file names

    • git whatchanged --since '12/01/2016' --oneline --name-only --pretty=format: | sort | uniq
    • git log --since="4 day ago" --name-only --pretty=format: | sort -u
    • git whatchanged --since '12/01/2016' --until '12/06/2016' --oneline --name-only --pretty=format: | sort | uniq
  • Stash

    • git stash
    • git stash list (Get all stash(s))
    • git stash pop (Reapply stash and remove)
  • git stash apply (Reapply stash and keep copy)