Skip to content

Instantly share code, notes, and snippets.

View iandexter's full-sized avatar

Ian Dexter D Marquez iandexter

View GitHub Profile
@iandexter
iandexter / slack_workspace_cleanup.py
Last active November 29, 2017 03:56
Clean up Slack workspace
#!/usr/bin/env python
"""Clean up Slack workspace"""
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name,redefined-outer-name,logging-format-interpolation
from __future__ import print_function
import logging
import os
import sys
import requests
@iandexter
iandexter / aws_ssh.py
Last active July 9, 2017 15:53
Allow or revoke SSH access to AWS security group
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import requests
import boto3
from botocore.exceptions import ClientError
sg = {
'aws-region-1': 'sg-group-id',
'aws-region-2': 'sg-group-id',

Keybase proof

I hereby claim:

  • I am iandexter on github.
  • I am iandexter (https://keybase.io/iandexter) on keybase.
  • I have a public key ASAN9UwcwBcOtvzbIy_8whMFnvfmziSY5QbQnikfH9mCXwo

To claim this, I am signing this object:

curl -s http://eleksyondata.gmanews.tv/national/VICE-PRESIDENT_PHILIPPINES.json.gz | jq -r '.result[0].candidates | sort_by(.name) | ["name","vote_count"] as $fields | $fields, (.[] | [.[$fields[]]]) | @csv'
@iandexter
iandexter / apache.conf
Last active January 19, 2016 02:54
Reverse proxy separate Wordpress instance
<VirtualHost>
...
### START - Blog redirection
RewriteRule ^/blog$ /blog/ [R=301]
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests off
ProxyPass /blog/ http://url.of.separate.blog/
@iandexter
iandexter / toepoch.pl
Created November 15, 2013 06:53
Convert timestamps to epoch time.
use Time::Local;
sub toepoch {
my $timestamp = shift;
my ($mon, $mday, $year, $hour, $min, $sec, $ampm) =
split(/[\/\s:]/, $timestamp);
$hour = ($ampm =~ /PM/ && $hour < 12) ? $hour+12 : $hour;
return timelocal($sec,$min,$hour,$mday,$mon-1,$year);
}
sub toepoch {
@iandexter
iandexter / getlatest.pl
Created November 15, 2013 06:52
Get newer or latest files in a directory.
use Time::Local;
use POSIX qw(strftime);
sub getlatest {
my $dir = shift;
my $pattern = shift;
my $dh;
$dir =~ s|/\z||;
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@iandexter
iandexter / toughnut_gen.py
Last active December 28, 2015 09:09
Generate ``tough nut'' passwords and passphrases by padding and using permutations of common words, then calculate the bit entropy for each generated password. Bonus: XKCD passphrase scheme. <http://blog.iandexter.net/2013/11/tough-nut-to-crack.html>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Generate ``tough nut'' passwords and passphrases by padding and using
permutations of common words, then calculate the bit entropy for each generated
password.
Usage: python toughnut_gen.py n file1 file2 ... filen
<?php
define("DIRECTORY",$_SERVER['OPENSHIFT_DATA_DIR'] );
define("DBNAME",$_SERVER['OPENSHIFT_APP_NAME'] );
define("DBUSER",$_SERVER['OPENSHIFT_MYSQL_DB_USERNAME'] );
define("DBPASS",$_SERVER['OPENSHIFT_MYSQL_DB_PASSWORD'] );
define("DBHOST",$_SERVER['OPENSHIFT_MYSQL_DB_HOST'] . ':' . $_SERVER['OPENSHIFT_MYSQL_DB_PORT'] );
$AUTOCONFIG = array(
'installed' => false,
'dbtype' => 'mysql',
'dbtableprefix' => 'oc_',