Skip to content

Instantly share code, notes, and snippets.

@nmcclain
nmcclain / update_aws_route53_ddns
Last active January 3, 2016 19:39
Crude script to update an AWS Route53 entry from cron
#!/usr/bin/php
<?php
# crude script to update an AWS Route53 entry from cron
$hostname = "homer";
$domain = "simpsons.org";
$ip = chop(`curl -s http://www.telize.com/ip`);
$r53ip = chop(`cli53 rrlist $domain | grep $hostname | awk '{print $5}'`);
@tanakahisateru
tanakahisateru / perfect-mail.php
Created January 9, 2014 16:57
How Japanese control Yii2's SwiftMailer
<?php
// Charset
$domesticCharset = 'iso-2022-jp';
$universalCharset = 'utf-8';
// Encoders
$headerEncoderBase64 = new \Swift_Mime_HeaderEncoder_Base64HeaderEncoder();
$contentEncoder7bit = new \Swift_Mime_ContentEncoder_PlainContentEncoder('7bit');
$contentEncoderBase64 = new \Swift_Mime_ContentEncoder_Base64ContentEncoder();
@akitaonrails
akitaonrails / upgrading-vagrant-fusion.mdown
Created October 24, 2013 17:40
Upgrading Vagrant from the default Virtualbox provider to VMWare Fusion on the Mac

I had some headaches yesterday while trying to upgrade to VMWare Fusion with Vagrant.

The steps that work are:

  • export your boxes from Virtualbox to OVA files
  • run 'vagrant destroy' on all your boxes
  • uninstall Virtualbox using the uninstaller script in the installer DMG
  • download VMWare Fusion
  • run 'vagrant plugin install vagrant-vmware-fusion' to install the provider plugin
  • run 'vagrant plugin license vagrant-vmware-fusion license.lic' to install the license you just bought
@joemiller
joemiller / raid_ephemeral.sh
Last active October 23, 2023 21:53
detect all ephemeral disks on EC2 then stripe together in a raid-0 vol mounted at /mnt
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
@andreCatita
andreCatita / iso7064_mod11_2.php
Last active August 29, 2022 09:25
PHP Example of ISO 7064 Mod 11,2 or Modulus 11,2 of the norm ISO/IEC 7064. Is is not very used, that's why I am sharing.
<?php
class Iso7064mod112 {
public $code;
public function encode($code) {
$this->code = $code;
$c = $this->computeCheck($this->code);
if ($c == 10) {
@Turin86
Turin86 / WSSoapClient.php
Last active April 24, 2023 19:37 — forked from johnkary/WSSoapClient.php
WS-Security for PHP SoapClient
<?php
/**
* This class can add WSSecurity authentication support to SOAP clients
* implemented with the PHP 5 SOAP extension.
*
* It extends the PHP 5 SOAP client support to add the necessary XML tags to
* the SOAP client requests in order to authenticate on behalf of a given
* user with a given password.
*
@mrflip
mrflip / 20130416-todo.md
Last active April 22, 2025 14:33
Elasticsearch Tuning Plan

Next Steps

  • Measure time spend on index, flush, refresh, merge, query, etc. (TD - done)
  • Take hot threads snapshots under read+write, read-only, write-only (TD - done)
  • Adjust refresh time to 10s (from 1s) and see how load changes (TD)
  • Measure time of a rolling restart doing disable_flush and disable_recovery (TD)
  • Specify routing on query -- make it choose same node for each shard each time (MD)
  • GC new generation size (TD)
  • Warmers
  • measure before/after of client query time with and without warmers (MD)
@chrisjdavis
chrisjdavis / gist:4046787
Created November 9, 2012 16:48
Passbook server API
<?php
class PassAPI extends Plugin
{
# Registration
# register a device to receive push notifications for a pass
#
# POST /v1/devices/<deviceID>/registrations/<typeID>/<serial#>
# Header: Authorization: ApplePass <authenticationToken>
# JSON payload: { "pushToken" : <push token, which the server needs to send push notifications to this device> }
#
@sshtmc
sshtmc / ubuntu-configure-sendmail-with-gmail
Created October 25, 2012 12:24
Ubuntu sendmail using smtp.gmail.com
#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
@dmitrybitman
dmitrybitman / pre-commit
Created March 5, 2012 11:56
php code sniffer pre-commit
#!/bin/bash
# PHP CodeSniffer pre-commit hook for git
#
# @author Soenke Ruempler <[email protected]>
# @author Sebastian Kaspari <[email protected]>
#
# see the README
PHPCS_BIN=/usr/bin/phpcs
PHPCS_CODING_STANDARD="$(git rev-parse --show-toplevel)/doc/CodeStandard.xml"