Skip to content

Instantly share code, notes, and snippets.

View devacto's full-sized avatar

Victor Wibisono devacto

View GitHub Profile
@devacto
devacto / app.js
Created May 4, 2013 01:00
Node.js Express Module Dependency
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
@devacto
devacto / split_delmited_string.sql
Last active December 27, 2015 12:59
Various useful MySQL string functions. (Original source: http://goo.gl/udse6R)
CREATE FUNCTION strSplit(x varchar(255), delim varchar(12), pos int) returns varchar(255)
return replace(substring(substring_index(x, delim, pos), length(substring_index(x, delim, pos - 1)) + 1), delim, '');
@devacto
devacto / sub_string_count.sql
Created November 6, 2013 03:41
Count the number of sub-strings separated by a specified delimiter.
CREATE FUNCTION substrCount(x varchar(255), delim varchar(12)) returns int
return (length(x)-length(REPLACE(x, delim, '')))/length(delim);
@devacto
devacto / uppercase_first_letter.sql
Created November 6, 2013 03:45
MySQL function to change the first letter into upper case.
CREATE FUNCTION ucfirst(x varchar(255)) returns varchar(255)
return concat( upper(substring(x,1,1)),lower(substring(x,2)) );
@devacto
devacto / add_padded_identifier.sql
Created November 6, 2013 03:49
Add padded identifier from store codes.
CONCAT('DS', LPAD(store_code, 4, 0));
@devacto
devacto / regex.js
Created November 13, 2013 05:07
Example of using regex with Javascript.
// Validate IMEI numbers.
$('#RequestProofOfPurchaseFloorStockForm').find('.imei').each(function() {
var pattern = /^(?!\b(.)\1+\b)\d{15}$/gi;
if(pattern.test($(this).val()) == false) {
validate = false;
$(this).addClass('err');
$(this).parent().find('label').addClass('err');
}
});
@devacto
devacto / eclipse_solarized_theme.epf
Created November 15, 2013 00:13
The Eclipse Solarized theme from Eclipse Themes have a defect in that find occurrence are not properly highlighted. This version fixed it.
file_export_version=3.0
/instance/org.codehaus.groovy.eclipse.ui/groovy.editor.groovyDoc.keyword.enabled=true
/instance/org.codehaus.groovy.eclipse.ui/groovy.editor.groovyDoc.link.enabled=true
/instance/org.codehaus.groovy.eclipse.ui/groovy.editor.groovyDoc.tag.enabled=true
/instance/org.eclipse.ui.editors/AbstractTextEditor.Color.SelectionForeground.SystemDefault=false
/instance/org.eclipse.ui.editors/AbstractTextEditor.Color.SelectionBackground.SystemDefault=false
/instance/org.eclipse.ui.editors/AbstractTextEditor.Color.Background.SystemDefault=false
/instance/org.eclipse.ui.editors/AbstractTextEditor.Color.Foreground.SystemDefault=false
/instance/org.epic.perleditor/AbstractTextEditor.Color.Background.SystemDefault=false
/instance/org.epic.perleditor/AbstractTextEditor.Color.Foreground.SystemDefault=false
@devacto
devacto / build.gradle
Created July 1, 2014 07:35
Example Gradle build file for use with Dropwizard.
apply plugin: 'java'
apply plugin: 'gradle-one-jar'
apply plugin: 'application'
// Use Java 8 by default
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
@devacto
devacto / cli.py
Last active October 30, 2020 10:02
import logging
import click
import os
import posixpath
from mlflow.models import Model
from mlflow.models.flavor_backend_registry import get_flavor_backend
from mlflow.tracking.artifact_utils import _download_artifact_from_uri
from mlflow.utils.file_utils import TempDir
from mlflow.utils import cli_args
## Bank Mandiri KSQL POT
### Download the MySQL Driver
`curl -k -SL "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.17.tar.gz" | tar -xzf - -C /Users/victor/desktop/mandiri-ksql-pot/mysql-driver --strip-components=1 mysql-connector-java-8.0.17/mysql-connector-java-8.0.17-bin.jar`
### Deploy Confluent Platform using Docker
`docker-compose up --build`
### Deploy Customer Source Kafka Connector
`curl --silent --request POST http://localhost:8083/connectors/ --header 'Content-Type: application/json' --data @source-connector-configs/mysql_customer_source_connector_config.json`