Skip to content

Instantly share code, notes, and snippets.

@imvenj
imvenj / install-rabbitmq-centos-7.md
Last active October 19, 2022 03:13 — forked from fernandoaleman/install-rabbitmq-centos-7.md
Install RabbitMQ on CentOS 7

Install RabbitMQ on CentOS 7

sudo yum -y install epel-release
sudo yum -y update

Install Erlang

Download repository

#!/usr/bin/env ruby
# Simple script that update namecheap ddns.
require 'open-uri'
require 'nokogiri'
require 'json'
HOST=''
DOMAIN=''
PASSWORD=''
#!/usr/bin/env ruby
# Generate json for iGolf 2 location simulation.
require 'nokogiri'
require 'json'
doc = Nokogiri::XML(open(ARGV[0]))
coordinates = doc.css('coordinates').text.strip.split(/\s+/).map { |s| s.split(',') }
arr = []
#!/bin/bash
# Set up your username stuff here:
DDNS_USER=YOUR_USERNAME
DDNS_PASS=YOUR_PASS
DDNS_PREFIX=YOUR_DDNS_PREFIX
IP_TMP=/tmp/current_ip
CURL_PATH=/usr/bin/curl
current_ip=$(${CURL_PATH} -s whatismyip.akamai.com)
#!/usr/bin/env ruby
# Generate gpx for Xcode from Google Earth kml.
require 'time'
require 'nokogiri'
seconds_per_point = 2
timestamp = Time.now.to_i
doc = Nokogiri::XML(open(ARGV[0]))
#!/usr/bin/env ruby
require 'rubyXL'
workbook = RubyXL::Parser.parse("test.xlsx")
workbook.worksheets.each do |worksheet|
out_sql = open("#{worksheet.sheet_name}.sql", 'w+')
current_row = 1 # 跳过第一行表头
blank_rows = 0 # 空行计数器
@imvenj
imvenj / sma.js
Created April 17, 2019 08:27
SMA implementation in simple function form, or in class form.
// Simple move average
function sma(data, dataLength, sampleRate=250, frequency=50) {
if (data.length === 0) return data;
const filterTL = Math.round(sampleRate / frequency)
const filteredData = []
if (filterTL > dataLength) {
throw new Error('Data length is not enough.')
}
else {
for (let i = 0; i < dataLength; ++i) {
@imvenj
imvenj / birthday_cal.swift
Last active April 11, 2018 10:21
Code snippet that calculates in which year (and age), your Chinese calendar birthday will be the same day as in Gregorian calendar.
import Foundation
let cst = TimeZone(secondsFromGMT: 8 * 3600)!
func createDate(_ year: Int, _ month: Int, _ day: Int) -> Date {
var components = DateComponents()
components.year = year
components.month = month
components.day = day
components.calendar = Calendar(identifier: .gregorian)