Skip to content

Instantly share code, notes, and snippets.

View Zloy's full-sized avatar

Zloy

  • Zelenograd, Moscow, Russia
View GitHub Profile
@Zloy
Zloy / wa.local.ps1
Last active June 3, 2016 12:48
Periodic windows task to check if VPN is up and to reconnect if VPN is down
$vpnName = "connection mane"
$vpnUsername = "user"
$vpnPassword = "password `$ with escaped dollar sign"
$ip = "10.10.10.51" # some site in vpn to test access to
$result = gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address = '$ip'"
if ($result.StatusCode -eq 0) {
Write-Host "$ip is up."
}
else{
@Zloy
Zloy / manage-etc-hosts.sh
Created May 26, 2016 12:05 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
@Zloy
Zloy / hosts.ps1
Created May 26, 2016 12:00 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
@Zloy
Zloy / libsodium-0.6.0.txt
Created July 7, 2015 12:14
libsodium-0.6.0 and zeromq-4.1.2 installation logs
~/sources/libsodium-0.6.0 > ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
@Zloy
Zloy / active_support_autoload.rb
Created July 7, 2015 08:33
Activesupport autoload feature outside Rails
require 'active_support'
require 'active_support/dependencies'
relative_load_paths = %w[app/controllers app/models]
ActiveSupport::Dependencies.autoload_paths += relative_load_paths
@Zloy
Zloy / uri.js
Last active August 29, 2015 14:22 — forked from jlong/uri.js
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"
@Zloy
Zloy / .screenrc
Created May 28, 2015 07:57
Launches gnu screen which attaches to named session if exists or starts vagrant up and creates a new session with 5 windows with: vim, rails c, rails s, guest os shell, host os shell
source /home/zloy/.screenrc
screen -t 'rails c' 0
screen -t 'shell' 1
screen -t 'vim' 2
screen -t 'guest' 3
screen -t 'rails s' 4
select 0
stuff "cd ../vbox && vagrant ssh -- -t 'source ~/.bash_profile && cd my_src/organization/app && bundle exec rails c && /bin/bash'^M"
@Zloy
Zloy / rspec_vagrant_overcommit
Last active August 29, 2015 14:21
Run rspec in vagrant from overcommit hook
Put to `bin/rspec_vagrant` file
#!/bin/bash
(cd ../vbox && vagrant ssh -c 'source ~/.bash_profile && cd my_src/latera/loms && bundle exec rspec')
Put to `.overcommit.yml`
PrePush:
RSpec:
command: bin/vagrant_rspec