Skip to content

Instantly share code, notes, and snippets.

@yesnik
yesnik / software_modification.md
Last active January 25, 2021 18:11
How to modify logic of software

How to modify logic of software

You have a client with a website. Client wants to add new feature or fix some bug.

Initial analysis

  • Listen carefully what client needs

  • Describe current logic that we need to modify. If logic is complex draw scheme on the sheet of paper. Don't describe details yet, forget about table names, class' names on this step.

@jakub-g
jakub-g / async-defer-module.md
Last active March 26, 2026 03:08
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@yesnik
yesnik / docker-compose.md
Last active September 3, 2025 13:04
Docker Guides

Docker Compose

Docker compose is a tool that is used for defining and running multi-container Docker apps in an easy way. It provides docker-compose.yml configuration file that can be used to bring up an app and the suite of services it depends on with just one command.

  • docker compose up - start all services from docker-compose.yml
  • docker compose up db - start only service db
  • docker compose up --build - rebuild all images and run containers
  • docker compose restart db - restart db service
@anvaka
anvaka / panzoom.md
Created August 25, 2018 19:47
Pan and zoom

Pan and zoom some websites.

In the browser address bar type javascript: and then paste this line

s=document.createElement("script");s.src="https://cdn.rawgit.com/anvaka/panzoom/v6.1.3/dist/panzoom.js";s.setAttribute('query','body');document.head.appendChild(s)

Note: This doesn't work on some websites with strict content security policy (like Twitter or Facebook)

@yesnik
yesnik / active_record.md
Last active November 1, 2024 14:49
Yii 1 Framework Cookbook

CActiveRecord methods

findAll()

Sort records

// Ascending order
Partner::model()->findAll(array('order' => 'company'));
@javan
javan / direct-uploads.md
Last active January 9, 2025 01:00
Active Storage direct uploads

direct-uploads

rails/activestorage#81

// direct_uploads.js

addEventListener("direct-upload:initialize", event => {
  const { target, detail } = event
  const { id, file } = detail
@sybrew
sybrew / search-canonical-push-for-ga.php
Last active April 25, 2019 17:53
Search Canonical Push for Google Analytics
<?php
/**
* Plugin Name: Search Canonical Push for Google Analytics
* Plugin URI: https://theseoframework.com/
* Description: This plugin adds a small script to Search archives that optimizes the Google Analytics script when using pretty Search links.
* Version: 1.0.1
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
*/

Using Swift Package Manager with iOS

Step 1:

File > New > Project...

Step 2:

Create a Package.swift file in your root project directory, add dependencies, then run swift package fetch on the command line in the same directory. We’re not going to run swift build because it will just complain.

@craigvantonder
craigvantonder / install-configure-letsencrypt.md
Last active April 26, 2022 08:58
Install and configure LetsEncrypt on Ubuntu Server 14.04 & 16.04 (Apache)
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04
# Download the Let’s Encrypt Client
cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto
# Set Up the SSL Certificate
@PimDeWitte
PimDeWitte / Efficient Bad Word Filter
Last active June 30, 2025 17:53
Simple profanity filter written in Java for efficient comparison. Runtime grows based on string input, not list size.
static Map<String, String[]> words = new HashMap<>();
static int largestWordLength = 0;
public static void loadConfigs() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new URL("https://docs.google.com/spreadsheets/d/1hIEi2YG3ydav1E06Bzf2mQbGZ12kh2fe4ISgLg_UBuM/export?format=csv").openConnection().getInputStream()));
String line = "";
int counter = 0;
while((line = reader.readLine()) != null) {