Skip to content

Instantly share code, notes, and snippets.

@xu-li
xu-li / lightgbm_with_binary_focal_crossentropy.py
Created February 14, 2023 08:12
LightGBM with Binary Focal Crossentropy
'''
LightGBM with Binary Focal Crossentropy
There are a lot of articles talking about how to calculate the first and second order derivatives. They are complex and
I don't understand them in full. Here, I am using Tensorflow which provides both the BinaryFocalCrossentropy loss and
the auto-differentiation. Within a few lines of code, I am able to use BinaryFocalCrossentropy as the loss function.
Focal crossentropy: https://arxiv.org/abs/1708.02002
'''
import numpy as np
@xu-li
xu-li / oauth-using-jwt.xml
Created August 21, 2020 09:19
Mulesoft OAuth using JWT
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:crypto="http://www.mulesoft.org/schema/mule/crypto" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/crypto http://www.mulesoft.org/schema/mule/crypto/current/mule-crypto.xsd">
<crypto:jce-config name="OAuth_JWT_Crypto_Jce" doc:name="Crypto Jce" doc:id="b819382e-9ed7-4a23-b7e3-4886afa0b7ed" keystore="${jwt.keystore.path}" password="${jwt.keystore.password}" >
<crypto:jce-key-infos >
<crypto:jce-asymmetric-key-info keyId="${jwt.keystore.alias.id}" alias="${jwt.keystore.alias.name}" password="${jwt.keystore.alias.password}" />
@xu-li
xu-li / FillText.php
Last active April 4, 2018 06:11
FPDF::fillText, fillText in a rectangular area
<?php
/**
* Fill text in a rectangular area
*
* It will automatically decrease font size if it exceeds the boundary.
* It also takes cMargin into consideration.
*
* @see FPDF::Cell()
*
* @param string $text
@xu-li
xu-li / laravel_orm_standalone.php
Last active August 29, 2015 14:04
Using laravel ORM alone
<?php
// composer.json
/*
{
"require": {
"illuminate/database": "*"
}
}
*/
@xu-li
xu-li / batch-user-import.php
Created July 6, 2012 07:56
A drupal7 script for batch importing users
#!/usr/bin/php
<?php
$users = "
first_name last_name\temail\tpassword\n
first_name last_name\temail\tpassword\n
first_name last_name\temail\tpassword\n
first_name last_name\temail\tpassword\n
first_name last_name\temail\tpassword\n
";