Skip to content

Instantly share code, notes, and snippets.

View miripiruni's full-sized avatar

Slava Oliyanchuk miripiruni

View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@shinypb
shinypb / gist:4485878
Created January 8, 2013 17:32
Bookmarklet to reload CSS without reloading the entire page
(function(){
$('link[rel="stylesheet"]').each(function(i, elem) {
// Make an anchor tag with the stylesheet's href -- this is a weird/handy way of
// working with URLs in the browser.
var anchorTag = $('a').attr('href', elem.getAttribute('href'))[0];
// Rewrite the URL to have a cache busting parameter. This assumes
// that any query params weren't significant.
anchorTag.search = "ts=" + (+new Date);
@pepelsbey
pepelsbey / 1. Legend.md
Last active December 11, 2015 21:48
Описание ручных тестов для навигации и таймера: отдельно и в сочетании

Условия

Термины, договорённости и описание тестовой презентации.

Состояния

  • Список (список слайдов)
  • Презентация (один слайд, ?full в адресе)
  • Текущий слайд (ID слайда в адресе, может быть и в Списке, и в Презентации)
@lazarofl
lazarofl / a_mongodb_to_s3_backup.sh
Last active April 19, 2022 05:06
MongoDB Automatic Backup to Amazon S3 with Crontab and s3cmd. Red Hat Linux on Amazon EC2
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"

Сравнение синтаксиса

Для сравнения была поставлена задача преобразовать входные данные вида:

var data = {
  caption: "Cap",
  people: [ 'John', 'Malkovich', 'Doe' ]
}

в строку Cap: John, Malkovich, Doe

@paulirish
paulirish / what-forces-layout.md
Last active July 3, 2024 16:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@anton-rudeshko
anton-rudeshko / gpg.conf
Last active September 5, 2018 22:23
Let's talk GnuPG Materials
# Based on:
# - https://www.gnupg.org/faq/gnupg-faq.html
# - https://raw.githubusercontent.com/ioerror/duraconf/master/configs/gnupg/gpg.conf
# If you have more than 1 secret key in your keyring, you may want to
# uncomment the following option and set your preferred keyid.
# default-key KEYID
# If you do not pass a recipient to gpg, it will ask for one. Using
@sindresorhus
sindresorhus / esm-package.md
Last active July 3, 2024 15:07
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@upgundecha
upgundecha / Brewfile
Last active October 7, 2022 06:40
Brewfile for tools listed in https://github.com/ibraheemdev/modern-unix
# tools from https://github.com/ibraheemdev/modern-unix
tap "cantino/mcfly"
tap "clementtsang/bottom"
brew "bat"
brew "exa"
brew "lsd"
brew "git-delta"
brew "dust"
brew "duf"
brew "broot"