Skip to content

Instantly share code, notes, and snippets.

View komly's full-sized avatar

Dmitry Petrov komly

  • aliexpress.ru
  • Moscow
View GitHub Profile
@komly
komly / gist:5fb77488c58ffec880f67e48d16f3608
Last active October 3, 2020 18:13
self signed sertificate valid for chrome
openssl req -x509 -newkey rsa:2048 -nodes -keyout=test_key.pem -out test.pem -days=365 -subj='/CN=test.ru' -reqexts SAN -extensions SAN -config <(cat /usr/lib/ssl/openssl.cnf \
<(printf '[SAN]\nsubjectAltName=@alt_names\n[alt_names]\nDNS.1 = test.ru\nDNS.2 = *.test.ru')) -sha256
protected void setScrollingEnabled(boolean isEnabled) {
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
params.setScrollFlags(isEnabled ? (AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS) : 0);
}
def get_char(c, i):
return c if i == 1 else '%s%d' % (c, i)
def encode(s):
if s == '':
return ''
res = []
last_char = s[0]
i = 1
@komly
komly / Pause.lhs
Created March 30, 2018 14:24 — forked from ppetr/Pause.lhs
An implementation of a Pause monad from http://stackoverflow.com/q/10236953/1333025
http://stackoverflow.com/q/10236953/1333025
I quite enjoyed this exercise. I tried to do it without looking at the answers,
and it was worth it. It took me considerable time, but the result is
surprisingly close to two of the other answers, as well as to
[monad-coroutine](http://hackage.haskell.org/package/monad-coroutine) library.
So I guess this is somewhat natural solution to this problem. Without this
exercise, I wouldn't understand how _monad-coroutine_ really works.
To add some additional value, I'll explain the steps that eventually led me to
@komly
komly / Jenkins
Last active April 27, 2017 19:04
https://medium.com/@mondaini/assembling-a-continuous-integration-service-for-a-django-project-on-jenkins-5f979d4c4184
http://www.deploypython.com/source/theme/static/pdf/table-of-contents.pdf
https://medium.com/@mondaini/assembling-a-continuous-integration-service-for-a-django-project-on-jenkins-5f979d4c4184
#sudo sysctl -w net.inet.ip.portrange.first=32768
sudo sysctl -w net.inet.ip.portrange.first=12000
sudo sysctl -w net.inet.tcp.msl=1000
sudo sysctl -w kern.maxfiles=1000000 kern.maxfilesperproc=1000000
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
#include <iostream>
using namespace std;
int main() {
# Меняет первое вхождение a на b в arr
def replace_first(a, b, arr):
arr = arr[:]
for i, x in enumerate(arr):
if x == a:
arr[i] = b
return arr
return arr
#!/usr/bin/env python3
import os
import sys
import binascii
def find_duplicates(path):
checksums = {}