Skip to content

Instantly share code, notes, and snippets.

View dimayakovlev's full-sized avatar

Dmitry Yakovlev dimayakovlev

View GitHub Profile
@Downes
Downes / vhost.sh
Last active April 22, 2025 11:23 — forked from mattmezza/vhost.sh
bash script to create virtual host vhost with apache2 and Ubuntu
#!/bin/bash
# This script was originally used for create virtual hosts on CentOs.
# Created by alexnogard from http://alexnogard.com
# Improved by mattmezza from http://you.canmakethat.com
# Adapted for Apache2 on Ubuntu by Stephen Downes at https://www.downes.ca
# Feel free to modify it
# PARAMETERS
#
# $usr - User
# $dir - directory of web files
@Goadstir
Goadstir / New-TimerStopWatch.ps1
Last active April 17, 2024 08:18
PowerShell: Using Timer to track time elapsed
$timeout = New-TimeSpan -Seconds 30
$timer = [Diagnostics.Stopwatch]::new() # Create a timer
$timerAndStart = [Diagnostics.Stopwatch]::StartNew() # Create a timer and start it
$timer.Start() # Start the timer
$timer.Stop() # Stop the timer
$timer.Elapsed # Get time elapsed
$timer.IsRunning # Is timer running?
$timer.Restart() # restarts the time, doesn't stop
$timer.Reset() # stops timer and sets to 0
$timer.Equals($timeout) # check if timer value equals a value such as timeout, returns boolean
@lucasmezencio
lucasmezencio / SLUG.md
Last active March 7, 2025 16:32
Creating URL slugs properly in PHP (including transliteration for UTF-8)

Creating URL slugs properly in PHP (including transliteration for UTF-8)

The point to use a slug (semantic URL) besides of improve the SEO of your articles is to prevent that the user, at the creation of for example an article, it uses special characters that aren't allowed in a URL, appropiate the usage etc. What target usage means, is context dependent.

In this article, you'll learn how to slugify a string in PHP properly, including (or not) support (conversion) for cyrilic and special latin characters.

Slugify in PHP

The following function exposes a simple way to convert text into a valid slug:

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active February 6, 2026 18:57
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@luismts
luismts / GitCommitBestPractices.md
Last active February 13, 2026 08:20
Git Tips and Git Commit Best Practices

Git Commit Best Practices

Basic Rules

Commit Related Changes

A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. Small commits make it easier for other developers to understand the changes and roll them back if something went wrong. With tools like the staging area and the ability to stage only parts of a file, Git makes it easy to create very granular commits.

Commit Often

Committing often keeps your commits small and, again, helps you commit only related changes. Moreover, it allows you to share your code more frequently with others. That way it‘s easier for everyone to integrate changes regularly and avoid having merge conflicts. Having large commits and sharing them infrequently, in contrast, makes it hard to solve conflicts.

@nathansmith
nathansmith / _closest.js
Created October 22, 2016 16:31
Helper method for finding an ancestor element.
/*
This method works similarly
to jQuery's `closest` method.
```
$('.foo').closest('.bar')
```
Except, instead of returning an
element, it executes a function.
@luruke
luruke / smashingmagazine.js
Last active June 19, 2025 11:33
Source code of the demo "Improving User Flow Through Page Transitions" on Smashing Magazine.
/*
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/
You can copy paste this code in your console on smashingmagazine.com
in order to have cross-fade transition when change page.
*/
var cache = {};
function loadPage(url) {
if (cache[url]) {
@OleVik
OleVik / gulpfile.js
Last active May 15, 2024 09:36
Build responsive images with Gulp
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var debug = require('gulp-debug');
var $ = require('gulp-load-plugins')();
gulp.task('clean:pages', function() {
gutil.log('Deleting /pages/**/*', gutil.colors.magenta('123'));
return del([
@lokothodida
lokothodida / README.md
Last active March 25, 2016 19:46
GetSimple Theme Developer Language Helper Functions

GetSimple Theme Developer Language Helper Functions

Allows GetSimple theme designers to have theme-dependent language strings in a lang folder of their theme.

Usage

  1. Add language_functions.php (from this gist) to your current theme's folder.
  2. Create a lang folder in your current theme
  3. Create language files for your theme with file names corresponding to language codes:
@jdhitsolutions
jdhitsolutions / ChristmasWishes.ps1
Created December 24, 2015 15:49
Display a colorful and randomly selected Christmas message.
<#
Display a randomly selected holiday quote in a festive color scheme
you can find more Christmas quotes at
http://www.brainyquote.com/quotes/topics/topic_christmas.html
Learn more about PowerShell:
http://jdhitsolutions.com/blog/essential-powershell-resources/
#>