Skip to content

Instantly share code, notes, and snippets.

View kaloprominat's full-sized avatar

Pavel Kondratev kaloprominat

View GitHub Profile
@kaloprominat
kaloprominat / openssl: request server certificate cnf
Created April 11, 2013 12:00
openssl: request server certificate cnf
[req]
default_bits=1024
default_keyfile=private.key
encrypt_key=no
prompt=no
distinguished_name=req_distinguished_name
x509_extensions = v3_req
req_extensions=v3_req
@kaloprominat
kaloprominat / openssl: change private key privkey password
Created April 11, 2013 12:00
openssl: change private key privkey password
openssl rsa -des3 -in privkey.pem -out privkey.pem.new
@kaloprominat
kaloprominat / vim: search replace
Created April 11, 2013 12:01
vim: search replace
:%s/foo/bar/g
Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
:%s/foo/bar/g
Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.
:%s/foo/bar/gc
Change each 'foo' to 'bar', but ask for confirmation first.
:%s/\<foo\>/bar/gc
@kaloprominat
kaloprominat / sed: replace inplace syntax
Last active December 16, 2015 02:29
sed: replace inplace syntax
sed -i 's/search/replace/g' file
@kaloprominat
kaloprominat / ldapsearch: ldap basic query syntax
Last active December 16, 2015 02:29
ldapsearch: ldap basic query syntax
ldapsearch -x -D login@domain -W -H ldap://server:389 -LLL -b "base" '(filter)'
@kaloprominat
kaloprominat / python: load module from filesystem .py
Created April 11, 2013 12:02
python: load module from filesystem
import imp
<module> = imp.load_source('<module>', '<module_path.py>')
@kaloprominat
kaloprominat / PHP: file lines iterate .php
Created April 11, 2013 12:02
PHP: file lines iterate
$in = fopen('file.txt', 'rb');
while($line = fgets($in)) {
// $line is a line of file
}
@kaloprominat
kaloprominat / python: python script heading
Last active May 4, 2019 01:35
python: python script heading
#!/usr/bin/env python
# -*- coding: utf-8 -*-
@kaloprominat
kaloprominat / bash: lxc lxctl create container syntax
Last active December 16, 2015 05:49
bash: lxc lxctl create container syntax
lxctl create fqdn --ostemplate=ubuntu-12.04-amd64 --rootsz=10G --ipaddr ip --netmask netmask --defgw gw --hostname fqdn --userpasswd user:passwd --mtu 1500/8950 --autostart=1
@kaloprominat
kaloprominat / mysql: analyse sql table analyse
Created April 15, 2013 19:12
mysql: analyse sql table analyse
SELECT col1, col2 FROM table1 PROCEDURE ANALYSE()\G;