Skip to content

Instantly share code, notes, and snippets.

View kmmbvnr's full-sized avatar
💭
#StopPutin #StopWar

Mikhail Podgurskiy kmmbvnr

💭
#StopPutin #StopWar
View GitHub Profile
@sj26
sj26 / sidekiq.service
Last active May 3, 2024 07:07 — forked from dsadaka/\lib\systemd\system\sidekiq-static.service
systemd unit files for multiple sidekiq workers
[Unit]
Description=Sidekiq workers
# start as many workers as you want here
[email protected]
[email protected]
# ...
[Service]
Type=oneshot
ExecStart=/bin/true
@JPvRiel
JPvRiel / journalctl_enable_persistent_storage.md
Last active November 17, 2024 20:29
Enable persistent storage for the systemd journal log

Enable persistent storage for the systemd journal log

Overview

The assumed default setting in /etc/systemd/journald.conf is Storage=auto which implies that systemd journaling will only persist the journal if the expected storage location is available. Otherwise, the journal data is stored in memory and lost between reboots. On Ubuntu 16.04, /var/log/journal does not exist by default. Create it to keep and query events from previous boots.

Considerations:

  • Syslog still provides the persistant log records for Ubuntu 16.04, so enabling persistant systemd journal logging does cause a level of duplicaiton.
  • There are sane defaults:
@mattiaslundberg
mattiaslundberg / Ansible Let's Encrypt Nginx setup
Last active January 30, 2025 19:01
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@webjunkie
webjunkie / forms.py
Last active February 4, 2023 22:12
JSONFieldFormMixin for Django ModelForm with JSON field
# the mixin
class JSONFieldFormMixin(object):
"""
Given that a model has some kind of TextField ``json_storage_field`` with
a string of JSON formatted data inside, this mixin adds handling of this
field to a ModelForm.
It will read the text field, convert to Python dict, fill the form fields
that are given via ``json_fields`` and on saving will write this back to
@kmmbvnr
kmmbvnr / bigquery.sql
Created July 21, 2016 02:59
Query pypi package download stats
SELECT details.installer.name, COUNT(*)
FROM
TABLE_DATE_RANGE(
[the-psf:pypi.downloads],
TIMESTAMP("20160601"),
TIMESTAMP("20160630")
)
WHERE file.project='django-material'
group by details.installer.name
/*
* Динамическая сетка
* Внедряется подмешиванием DOM-узлу поведенческих классов: grid_col_3, grid_cell...
*/
.grid
box-sizing border-box
/*
* Генерирует стили для сетки
@tmaybe
tmaybe / ignore.md
Last active February 7, 2024 03:18
ignoring merge conflicts for specific files in a git repository

How to Ignore Merge Conflicts for Specific Files in a Git Repository

Create a directory and git init it

$ mkdir merge-test
$ cd merge-test/
$ git init
@paulirish
paulirish / bling.js
Last active February 18, 2025 14:08
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
class SomeView(View):
def dispatch(self, request, *args, **kwargs):
# imports and start profiling
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
# all logic runs here
@doochik
doochik / gist:575b94b20765b028dc70
Created November 26, 2014 16:25
IE10/11 can't execute blob-js with 114688 bytes size
var text = "var a = '";
for (var i = text.length; i < 114686; i++) {
text += '1';
}
text += "';";
console.log('text size:', text.length);
var blob = new Blob([text], {type: 'text/javascript'});
var url = URL.createObjectURL(blob);
var script = document.createElement('script');