Skip to content

Instantly share code, notes, and snippets.

View karlitxo's full-sized avatar

karlitxo karlitxo

View GitHub Profile
@karlitxo
karlitxo / pony-example.rb
Created June 8, 2017 12:23 — forked from pedrodelgallego/pony-example.rb
A working example of pony and sinatra.
# You need to install these gems.
# - smtp_tls
# - pony
post "/contact-us" do
Pony.mail :to => 'pedro.delgallego@gmail.com',
:from => "#{params[:email]}",
:subject => "Contact SFT : #{params[:name]}",
:body=> "#{params[:body]}, --- Contact Address #{params[:email]}",
:via => :smtp,
@karlitxo
karlitxo / grafana custom.ini
Created February 5, 2017 17:07 — forked from mvadu/grafana custom.ini
nginx config for using grafana, Influxdb via reverse proxy with authentication
# The full public facing url
#root_url = %(protocol)s://%(domain)s:%(http_port)s/
root_url = http://localhost:80/grafana/
@karlitxo
karlitxo / README.md
Created January 16, 2017 17:34 — forked from warmfusion/README.md
Cloud Init script for building a coreos cluster at home on XenServer using Cloud-Init and ETCD2

This Cloud-init script can be used to bootstrap a Xen based CoreOS server through Xen orchestra.

Features;

  1. Workaround for the lack of /etc/environment on 'unsupported' hypervisors
  2. Static IP allocation to deal with dhcp causing problems (On my network at least)
  3. etcd2 bootstrap discovery using public service and discovery tokens
    1. Manual reconfiguration to allow for membership changes after cluster is operational

Usage

@karlitxo
karlitxo / ruby_ftp_example.rb
Created December 3, 2016 14:44 — forked from 3dd13/ruby_ftp_example.rb
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@karlitxo
karlitxo / Gemfile
Created November 15, 2016 16:12
Sinatra + Mongoid CRUD Sample
source 'http://rubygems.org'
gem 'rack'
gem 'rack-flash'
gem 'thin'
gem 'sinatra', :require => 'sinatra/base'
gem 'mongoid'
gem 'bson_ext'
gem 'slim'
@karlitxo
karlitxo / CoreOS on XenServer
Created October 17, 2016 11:37 — forked from zebby76/CoreOS on XenServer
Install CoreOS to Disk in a VM on XenServer
Le support de Docker nativement par XenServer est actuellement disponible :
- http://xenserver.org/blog/entry/preview-of-xenserver-support-for-docker-and-container-management.html
- http://xenserver.org/partners/docker.html?id=159
Retour d'experience :
Création d'une VM avec Template CoreOS et utiliser le disque coreos_install_stable.iso pour booter.
- 2 disques supplémentaires sont nécessaires (pour l'utilisation du cloud-config) :
- Docker Space (xvdb)
@karlitxo
karlitxo / auto_zoom_markers.js
Created September 20, 2016 10:10 — forked from chensoren/auto_zoom_markers.js
Auto Zoom To Fit All Markers on Google Maps API v3
var LatLngList = new Array (new google.maps.LatLng (52.537,-2.061), new google.maps.LatLng (52.564,-2.017));
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds ();
// Go through each...
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) {
// And increase the bounds to take this point
bounds.extend (LatLngList[i]);
}
// Fit these bounds to the map
map.fitBounds (bounds);
@karlitxo
karlitxo / bongo.sh
Created August 13, 2016 00:22 — forked from smashew/bongo.sh
This one works... Tested
LOADING=false
usage()
{
cat << EOF
usage: $0 [options] dbname
OPTIONS:
-h Show this help.
-l Load instead of export
@karlitxo
karlitxo / custom_logger.rb
Created May 27, 2016 15:05 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@karlitxo
karlitxo / gist:f6dd97a1b98d78db8c790d51f309093c
Created May 12, 2016 23:15 — forked from philips/gist:7310435
Setting up swap on coreos

Setup a swap file in the stateful partition

Run these commands as root to create a 512 megabyte swap.

fallocate -l 512m /media/state/512MiB.swap
chmod 600 /media/state/512MiB.swap
mkswap /media/state/512MiB.swap