Skip to content

Instantly share code, notes, and snippets.

@kixorz
kixorz / nginx.sh
Created April 14, 2013 05:10
Installation of rvm, rails, passenger, nginx
#rvm
\curl -#L https://get.rvm.io | sudo bash -s stable --autolibs=3 --ruby
#passenger
gem install passenger --pre
#nginx
#http://nginx.org/en/download.html
#set paths
@kixorz
kixorz / aws_cycle_elastic_ip.rb
Last active December 18, 2015 11:49
Script for cycling of Elastic IP attached to Amazon EC2 instance. Script also updates selected Route53 A record.
#!/usr/bin/env ruby
require 'syslog'
require 'net/http'
require 'aws-sdk'
Syslog.open
AWS.config({
:access_key_id => '<iam user key>',
:secret_access_key => '<iam user secret>'
@kixorz
kixorz / age.rb
Created June 20, 2013 04:19
Getting age in years from Time or Date object.
def age(time)
if time.kind_of?(Date)
timestamp = time.to_time.to_i
elsif time.kind_of?(Time)
timestamp = time.to_i
else
return 0
end
(Time.now.to_i - timestamp) / 31536000
@kixorz
kixorz / gist:6084158
Last active December 20, 2015 06:09
Useful gdb commands
Unlimited gdb print command:
set print elements 0
Print void* string content:
p (char *)variable+16
@kixorz
kixorz / payment.html
Created August 26, 2013 21:30
It's terrible to use meta tag order sematics to define multiple items: https://developers.facebook.com/docs/howtos/payments/definingproducts/#ogproduct_item
<meta property="product:price:amount" content="0.99"/>
<meta property="product:price:currency" content="USD"/>
<meta property="product:price:amount" content="0.79"/>
<meta property="product:price:currency" content="EUR"/>
@kixorz
kixorz / chef.txt
Created September 17, 2013 20:38
Chef Notes
# bootstrapping new node:
knife bootstrap <hostname> -x <username> -P <password> --sudo
@kixorz
kixorz / module1.js
Last active December 25, 2015 03:49
Example of design pattern for Node.js modules.
var module1 = function(param1, param2) {
var m_param1 = param1;
var m_param2 = param2;
var private_method = function(param3) {
return param3 + m_param1 + m_param2;
};
return {
public_method1: function(param1) {
@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"
@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 / 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>