Skip to content

Instantly share code, notes, and snippets.

View channainfo's full-sized avatar
🎯
Focusing

Channa Ly channainfo

🎯
Focusing
  • InSTEDD, SureSwift Capital, BookMeBus, VTENH, Onthegosystems
  • Phnom Penh
  • X @channaly
  • LinkedIn in/channaly
View GitHub Profile
@channainfo
channainfo / full-items-recommendation.sql
Last active December 10, 2021 08:12
Export items to panda data wrangling for items dataset in recommendation
WITH
ancesstor_taxons AS (
SELECT
taxon.id as taxon_id,
taxon.taxon_type as taxon_type,
taxon.parent_id,
ancesstor.id AS ancesstor_id,
ancesstor.parent_id AS ancesstor_parent_id,
trans.name AS ancesstor_name,
@channainfo
channainfo / recommendation-item.sql
Last active August 11, 2023 14:43
Export item pandas data for recommendations system
WITH
-- product with taxons
-- product_id, taxon_ids
-- 12611, 19|20
product_with_taxon_ids AS (
SELECT
pt.product_id,
st.taxon_type,
STRING_AGG( pt.taxon_id::varchar, '|' ORDER BY pt.taxon_id ASC ) AS taxon_ids,
@channainfo
channainfo / taxon-nested-set-ancesstor.sql
Last active December 10, 2021 08:01
Nested set with full ancestors path for pandas data wragling
WITH
ancesstor_taxons AS (
SELECT
taxon.id as taxon_id,
taxon.taxon_type as taxon_type,
taxon.parent_id,
ancesstor.id AS ancesstor_id,
ancesstor.parent_id AS ancesstor_parent_id,
trans.name AS ancesstor_name,
curl -XPUT localhost:9200/test
curl -XPUT http://localhost:9200/test/data/_mapping -d '{
"data" : {
"dynamic_templates" : [
{
"string_template" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
@channainfo
channainfo / ecs_task.js
Created October 11, 2021 10:13
ecs task sample aws sdk
import AWS from 'aws-sdk'
import dotenv from 'dotenv'
import ConfigWriter from '../config_writer'
import ConfigReader from '../config_reader'
dotenv.config()
// https://docs.aws.amazon.com/cli/latest/reference/ecs/register-task-definition.html
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ECS.html
class EcsTask {
@channainfo
channainfo / config.conf
Created September 23, 2021 11:14 — forked from gcsfred/config.conf
Sample integration between Elasticsearch and Amazon Personalize - entire file
[DEFAULT]
product_ranking_start = 10
product_ranking_steps_down = 0.2
cat_ranking_start = 10
cat_ranking_steps_down = 0.2
product_recommendations_campaignArn=arn:aws:personalize:us-east-2:11123456:campaign/es-test03-hrnn
product_rankings_campaignArn=arn:aws:personalize:us-east-2:222789:campaign/es-test03-rank
property1_recommendations_campaignArn=arn:aws:personalize:us-east-2:3333456:campaign/es-test03-cat-hrnn
property1_rankings_campaignArn=arn:aws:personalize:us-east-2:444789:campaign/es-test03-cat-rank
@channainfo
channainfo / 0-click-trial_shop.sql
Created August 26, 2021 00:29
CTE in practise: Writing a building block SQL expression with Postgresql
WITH
shops_on_trial AS (
SELECT shopify_domain
FROM shops
INNER JOIN charges on shops.id = charges.shop_id
WHERE charges.processor = 'trial' AND (commenced_at <= now())
AND (cancelled_at IS NULL OR cancelled_at >= now())
),
stats AS (
@channainfo
channainfo / account_api.dart
Last active August 26, 2021 00:17
Flutter API connection to Oauth2 REST API
import 'package:vtenh/models/account_model.dart';
import 'package:vtenh/models/base_model.dart';
import 'package:vtenh/services/apis/base_resource_owner_api.dart';
class AccountApi extends BaseResourceOwnerApi {
@override
bool get useJapxDecode => true;
AccountModel objectTransformer(Map<String, dynamic> json) {
return AccountModel.fromJson(json);
@channainfo
channainfo / .dockerignore
Created May 29, 2021 08:50 — forked from davidderus/.dockerignore
Docker + Rails + Puma + Postgres + Nginx
.git
.gitignore
/doc
.yardoc
coverage
jsdoc
/tmp
/log
Dockerfile
Dockerfile.prod
@channainfo
channainfo / feed_vendor_product.rb
Created February 23, 2021 07:14
Feed top products per vendor spree
module Feed
class VendorProduct
attr_accessor :vendor
LIMIT = 4
def initialize(vendor:, products:)
@vendor = vendor
@products = products
end