Skip to content

Instantly share code, notes, and snippets.

@kixorz
kixorz / example.cpp
Created October 6, 2015 22:38
C++ function pointer example
//function type declaration
typedef <function return type> * (* <function type name>)( <arg type>, ... ); //don't include variable names
//instance
<function type name> func;
//usage
func = &<function instance name>;
@kixorz
kixorz / aws_lambda_public_ip.js
Last active February 14, 2024 07:39
Function retrieving AWS Lambda public IP address. Copy and paste this to your Lambda console, use standard permissions, execute and observe the log to see the public IP address of your Lambda function.
var http = require('http');
exports.handler = function(event, context) {
http.get('http://httpbin.org/get', function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
{
"Parameters" : {
"KeyName" : {
"Type" : "String",
"Description" : "EC2 KeyPair"
},
"ClusterName" : {
"Type": "String",
"Description" : "ECS Cluster name"
},
@kixorz
kixorz / ec2hostname.rb
Last active June 3, 2022 11:26
EC2 DNS load-balancing init.d script. Instances automatically register themselves in Route53 RecordSets and properly update their records when starting/shutting down. Instances need to use attached IAM role allowing them to modify the Route53 zone.
#!/usr/bin/ruby
# chkconfig: 35 99 01
# description: EC2 DNS loadbalancing
# processname: ec2hostname
require 'aws-sdk'
require 'net/http'
`touch /var/lock/subsys/ec2hostname`
@kixorz
kixorz / ec2hostname.rb
Last active June 3, 2022 11:27
EC2 Instance Route53 Hostname registration init.d script. Instance needs to have the attached IAM instance role policy applied.
#!/usr/bin/ruby
# chkconfig: 35 99 01
# description: EC2 DNS registration
# processname: ec2hostname
require 'aws-sdk'
require 'net/http'
`touch /var/lock/subsys/ec2hostname`
@kixorz
kixorz / INSTALL
Last active August 29, 2015 13:59
Stackdriver agent setup on Ubuntu Saucy
taken from:
http://support.stackdriver.com/customer/portal/articles/1491764-installing-the-stackdriver-agent-on-ubuntu-and-debian
switch to root and:
curl -o /etc/apt/sources.list.d/stackdriver.list http://repo.stackdriver.com/wheezy.list
curl --silent https://app.stackdriver.com/RPM-GPG-KEY-stackdriver | apt-key add -
apt-get update
apt-get install libhiredis0.10
apt-get install stackdriver-agent
"UserData": {
"Fn::Base64": { "Fn::Join":["", [
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-setuptools\n",
"mkdir aws-cfn-bootstrap-latest\n",
"curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1\n",
"easy_install aws-cfn-bootstrap-latest\n",
"/usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackName" }, " --resource WebServer", " --region ", { "Ref": "AWS::Region" }, "\n",
"\n",
@kixorz
kixorz / test.html
Created April 4, 2014 16:45
YouTube API experiment
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>
@kixorz
kixorz / node.conf
Created March 17, 2014 22:29
Node.js Upstart script template
#!upstart
description "<project>"
author "<author>"
env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
respawn
start on runlevel [23]
script
@kixorz
kixorz / auto_logon.reg
Created March 5, 2014 21:37
Automatic Windows login for selected username.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="<username>"
"DefaultPassword"="<password>"
"AutoAdminLogon"="1"