Skip to content

Instantly share code, notes, and snippets.

View dexterous's full-sized avatar

Saager Mhatre dexterous

View GitHub Profile
@dexterous
dexterous / nginx-certs
Created July 19, 2016 17:42
Get list of certificates configured for nginx sites-enabled
#!/bin/bash -e
#set -o xtrace
sed -nre '/ssl_certificate\s/ { F; s,^.*/(.*);$,\1\n,; p}' /etc/nginx/sites-enabled/*
@dexterous
dexterous / JVM Options (java -help; java -X)
Created June 29, 2016 14:50
JVM (HotSpot) settings & options
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
@dexterous
dexterous / turkpipe.py
Created April 20, 2016 21:03
TurkPipe, a CLI to batch MTurk jobs; copied from https://code.google.com/archive/p/turkpipe/
#!/usr/bin/python
"""
Copyright (c) 2009-2010 Voxilate, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@dexterous
dexterous / Vagrantfile
Last active July 20, 2016 19:01
Steps to install and configure OpenVPN client on Fedora 23
Vagrant.configure(2) do |config|
config.vm.box = "fedora/23-cloud-base"
config.vm.provider "virtualbox" do |vbox|
# Modify netmask of default NAT interface to avoid conflict with VPN
vbox.customize ["modifyvm", :id, "--natnet1", "192.168.20.0/24"]
end
config.vm.network "public_network", bridge: "wlan0"
#!/usr/bin/env python
def slicing(lang_idx, lang_cnt, lines):
'''Using islice; short, but requires knowledge of total line count'''
from itertools import islice
return islice(lines, lang_idx, 12, lang_cnt)
def counting(lang_idx, lang_cnt, lines):
'''Using count in conjunction with dropwhile; on and on and on and on...'''
@dexterous
dexterous / Vagrantfile
Last active November 2, 2021 08:07
Steps to install FreeIPA 4.3 on Fedora 23 and 389-DS on Ubuntu Trusty 64
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "ipa-master" do |ipa|
ipa.vm.box = "fedora/34-cloud-base"
ipa.vm.network "private_network", ip: "10.12.0.10"
ipa.vm.hostname = "my-ipa01.medicaid-genius.com"
ipa.vm.provider "virtualbox" do |vm|
@dexterous
dexterous / git-core-bins
Last active February 18, 2016 17:03
A quick analysis of git-core binaries
user@hostname:~$ uname -a
Linux dockerhome 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
user@hostname:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
user@hostname:~$ apt-cache policy git git-core
git:
@dexterous
dexterous / procs.rb
Last active January 13, 2024 09:20
Ruby Procs, return & yield semantics
require 'rubygems'
require 'expectations'
Expectations do
expect(1){ proc { |a| a }.call(1) }
expect([1, 2]){ proc { |a| a }.call(1, 2) } #fails
expect(1){ proc { |a, b| a }.call(1, 2) }
expect(1){ Proc.new { |a| a }.call(1) }
@dexterous
dexterous / output.txt
Created February 4, 2016 21:17
Quick and dirty quantity pattern implementation in Groovy
1E+2 centimeters
1 kilometers = 1 kilometers
1 kilometers = 1E+3 meters
1 kilometers = 1E+5 centimeters
1 kilometers = 1E+6 millimeters
1 meters = 0.001 kilometers
1 meters = 1 meters
1 meters = 1E+2 centimeters
1 meters = 1E+3 millimeters
1 centimeters = 0.00001 kilometers
@dexterous
dexterous / format-column
Last active April 25, 2016 18:08
A bunch of bash scripts to pull (and sed scripts to format) a users-groups crosstab from LDAP
#!/bin/sed -rnf
/^uniqueMember: / {
s_^\w*: uid\=([^,]*),.*$_"\1",✔_
p
}