Skip to content

Instantly share code, notes, and snippets.

View sergeycherepanov's full-sized avatar
:bowtie:
Focusing

S.Cherepanov sergeycherepanov

:bowtie:
Focusing
View GitHub Profile
brew install dnsmasq
cd $(brew --prefix)
mkdir etc
echo 'address=/.dev/127.0.0.1' >> etc/dnsmasq.conf
echo 'address=/.loc/127.0.0.1' >> etc/dnsmasq.conf
sudo chown root $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist
sudo ln -s $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons/
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
@sergeycherepanov
sergeycherepanov / fingerprint.php
Created February 3, 2016 20:22 — forked from xeoncross/fingerprint.php
Generate a fingerprint from and RSA SSH public key
<?php
print "\n";
$rsa = file_get_contents('rsa.pub');
$ssh = file_get_contents('ssh.pub');
// For reference
print $rsa . "\n\n";
print $ssh . "\n\n";
@sergeycherepanov
sergeycherepanov / dev-tld.md
Created March 4, 2016 00:39 — forked from marek-saji/dev-tld.md
Configure local DNS server to serve #dev #TLD #ubuntu #linux

Configure local wildcard DNS server

  1. Install Dnsmasq: sudo apt-get install dnsmasq
  2. Since Ubuntu's NetworkManager uses dnsmasq, and since that messes things up a little for us, open up /etc/NetworkManager/NetworkManager.conf and comment out (#) the line that reads dns=dnsmasq. Restart NetworkManager afterwards: sudo restart network-manager.
  3. Make sure Dnsmasq listens to local DNS queries by editing /etc/dnsmasq.conf, and adding the line listen-address=127.0.0.1.
  4. Create a new file in /etc/dnsmasq.d (eg. /etc/dnsmasq.d/dev), and add the line address=/dev/127.0.0.1 to have dnsmasq resolve requests for *.dev domains. Restart Dnsmasq: sudo /etc/init.d/dnsmasq restart.

source: http://brunodbo.be/blog/2013/04/setting-up-wildcard-apache-virtual-host-wildcard-dns

<pre>
<?php
$username = 'admin';
$key = 'd525e743ee692632b52a05570444aa537e06a8cc';
$created = date('c');
$nonce = substr(md5(time()), 0, 16);
$sha1 = sha1($nonce . $created . $key, true);
$digest = base64_encode($sha1);
echo "user: {$username}" . PHP_EOL;
@sergeycherepanov
sergeycherepanov / vagrant-kvm.md
Created September 21, 2016 15:30 — forked from yuanying/vagrant-kvm.md
How to use vagrant-kvm

Install Vagrant

sudo su
apt-get update && apt-get install -y libvirt-dev ruby-all-dev apparmor-utils
curl -O -L https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.5_x86_64.deb
dpkg -i vagrant_1.6.5_x86_64.deb 
aa-complain /usr/lib/libvirt/virt-aa-helper # workaround
exit

Install vagrant-kvm as user

@sergeycherepanov
sergeycherepanov / get_ssl_bundle.php
Last active September 30, 2016 17:01
Make ssl bundle from domain certificate
#!/usr/bin/env php
<?php
/**
* Usage: php ./get_ssl_bundle.php example.com.crt
*
* @param string $crtFile
* @return string
*/
function get_ssl_bundle($crtFile)
{
qemu-system-x86_64 \
\
-rtc clock=vm,base=2016-01-01T16:01:21 \
\
-m 4096 \
-enable-kvm \
-name osxcapitan \
-cpu core2duo,vendor=GenuineIntel \
-rtc base=localtime \
-smbios type=2 \
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<!--
DONT FORGET TO ADD: /vm/osx-ovmf-bios-src-build/bios.bin IN APPARMOR PROFILE!
Host machine may need the following tweak for this to work, (it's will be reset after reboot)
echo 1 > /sys/module/kvm/parameters/ignore_msrs
Usb stick image with installer http://bit.ly/2dIhdy8
Archive with bioses: http://bit.ly/2djSmxR
@sergeycherepanov
sergeycherepanov / elastic-stress-test.sh
Last active October 18, 2016 15:17
Elastic stress test script
#!/bin/bash
#
# Usage: bash <(curl https://gist.githubusercontent.com/SergeyCherepanov/a36b0f11c069070690505bc847950808/raw/57d4b6f1b30936be81f13f0200a9c015825da794/elastic-stress-test.sh)
#
python --version 2>&1 | grep '2.7' || {
apt-get update
apt-get install python2.7
}
pip --version || {
/usr/bin/python <(curl https://bootstrap.pypa.io/get-pip.py)
@sergeycherepanov
sergeycherepanov / percona-server-5.7-armv7.md
Last active November 25, 2016 14:43
Percona Server 5.7 on ARM under Ubuntu 14.04 from source code

Percona Server 5.7 on ARM under Ubuntu 14.04 from source

Install dependencies

sudo apt-get -y install git wget cmake make dh-make gcc g++ \
libaio-dev libncurses5-dev libreadline-dev bison libboost-all-dev \
build-essential devscripts checkinstall

Install 1.59 libboost froum source