Skip to content

Instantly share code, notes, and snippets.

@kixorz
kixorz / example.cpp
Created Oct 6, 2015
C++ function pointer example
View example.cpp
//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 Mar 28, 2021
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.
View aws_lambda_public_ip.js
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() {
View cfn_coreos_ecs.json
{
"Parameters" : {
"KeyName" : {
"Type" : "String",
"Description" : "EC2 KeyPair"
},
"ClusterName" : {
"Type": "String",
"Description" : "ECS Cluster name"
},
@kixorz
kixorz / ec2hostname.rb
Last active Dec 5, 2017
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.
View ec2hostname.rb
#!/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 Apr 11, 2022
EC2 Instance Route53 Hostname registration init.d script. Instance needs to have the attached IAM instance role policy applied.
View ec2hostname.rb
#!/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 Aug 29, 2015
Stackdriver agent setup on Ubuntu Saucy
View INSTALL
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
View ubuntu-cloudformation.json
"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 Apr 4, 2014
YouTube API experiment
View test.html
<!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 Mar 17, 2014
Node.js Upstart script template
View node.conf
#!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 Mar 5, 2014
Automatic Windows login for selected username.
View auto_logon.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="<username>"
"DefaultPassword"="<password>"
"AutoAdminLogon"="1"