Skip to content

Instantly share code, notes, and snippets.

View chen1i's full-sized avatar

Li Chen chen1i

  • Nvidia
  • Shanghai
View GitHub Profile
git config --system core.longpaths true
@chen1i
chen1i / alidayu.rb
Created April 21, 2018 08:52
Simple wrapper for using Alidayu API. Works with Alidayu till 2017.6
# encoding: utf-8
module VendorSvc
class Alidayu
def initialize(options)
@app_key = AppConfig.alidayu_settings['app_key']
@app_secret = AppConfig.alidayu_settings['app_secret']
@svc_gateway = AppConfig.alidayu_settings['svc_gateway_https']
@sms_template = options[:sms_template]
@sms_sign = options[:sms_sign]
@app_product_name = options[:app_product_name] || AppConfig.alidayu_settings['app_product_name']
@chen1i
chen1i / extract_vm_info.sql
Created April 17, 2018 08:18
extract JSON field in mysql table
select ddn.properties->>'$.server.name' as os_hostname,
ddni.external_name,
ddni.host_instance_name,
ddni.name,
ddni.runtime_properties->>'$.ip' as main_ip
from deployment_details_node ddn,
deployment_details_node_instance ddni,
deployment dp
where dp.tenant_id = 'bocomm'
and dp.deleted =false
@chen1i
chen1i / OEM.sh
Created April 17, 2018 08:16
一键替换背景图片和logo
#!/bin/bash
if (( $# < 1 )); then
echo "Run as root: ./OEM.sh <customer_name>"
exit 2
fi
JS_DIR=/opt/cloudchef/tomcat/webapps/ROOT/WEB-INF/classes/static/javascripts/
OEM=$1
@chen1i
chen1i / join_all_projects.sql
Created April 17, 2018 08:11
add user to all projects under a business_group
DROP FUNCTION IF EXISTS `join_all_projects`;
DELIMITER $$
CREATE DEFINER = `cloudchef`@`%` FUNCTION `join_all_projects`(`tenant_id` varchar(64),`business_group_name` varchar(225),`user_name` varchar(225))
RETURNS int(4)
BEGIN
DECLARE projectCount int;
DECLARE done INT DEFAULT FALSE;
DECLARE user_id varchar(64);
DECLARE proj_id varchar(64);
@chen1i
chen1i / abstract_mysql2_adapter.rb
Created July 25, 2016 09:43
work around to resolve mysql5.7 and rails 3.22.1 issue
# this is due to break change in Mysql 5.7.x, and latest Rails4.2.x already have this patched.
# remove this file when upgrade to Rails 4.2.x
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end