Skip to content

Instantly share code, notes, and snippets.

View alucard001's full-sized avatar

Ellery Leung alucard001

View GitHub Profile
@alucard001
alucard001 / csv_for_excel.php
Created January 18, 2017 03:32
PHP CSV for Excel file download
<?php
// Prepare file download
// Special Thanks: https://www.skoumal.net/en/making-utf-8-csv-excel/
$filename = 'some_file_name.csv';
//headers
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
@alucard001
alucard001 / clean_email.py
Last active January 18, 2017 03:54
Python Validate Email example script
# coding: utf-8
import pandas as pd
import numpy as np
from validate_email import validate_email
import sys
# Note: you may encounter error if you don't have pyDNS or pyDNS3 installed.
import DNS
DNS.defaults["server"] = ["8.8.8.8", "8.8.4.4"]
@alucard001
alucard001 / woocommerce-product-category.php
Created April 30, 2017 09:44
WooCommerce Product Category List
<?php
/**
* @package Woocommerce Product Category List
* @version 1.0
*/
/*
Plugin Name: Woocommerce Product Category List table
Plugin URI: https://www.linkedin.com/in/elleryleung
Description: This plugin is just add a new shortcode: <code>[bp_product_category]</code> to list all product categories in div format.
Author: Ellery Leung
@alucard001
alucard001 / check_email_server_alive.py
Last active May 17, 2017 10:06
Python 2 Linux send email through Gmail using SMTP
# Python 2 Script. It works as of 17 May 2017
import os
if "CONNECTED" not in os.popen("/usr/bin/openssl s_client -connect 192.168.1.15:25 | /bin/grep '^CONNECTED'").read():
# Note about sending email using Gmail SMTP
# https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server
# http://stackoverflow.com/questions/20337040/gmail-smtp-debug-error-please-log-in-via-your-web-browser
# How to send email using Linux Command: http://www.binarytides.com/linux-mailx-command/
@alucard001
alucard001 / numerai.py
Last active January 17, 2018 01:15
Using TPOT Classifier to analysis Numerai dataset
"""
Largely come from TPOT example. The only control you can do to prevent timeout
and successful running is the "generation" and "population_size" parameters.
Remember, scoring is "log_loss" as of 18 Jan 2017, not probability
The larger the generation and population_size, the longer time you take to get result.
"""
from tpot import TPOTClassifier
from sklearn.model_selection import train_test_split
@alucard001
alucard001 / googlesearch.py
Last active June 24, 2019 04:09
Google Search API Working Example - Python 3 + MSSQL
#!/usr/local/bin/python3
'''
This program is used to get all search terms in Google search console and save it in MSSQL DB.
Please note: Just using this .py is not enough. You need to create a Google service account in google API console and
connect that service account to Google search console property.
Points to note:
===============
@alucard001
alucard001 / GetNextBusinessDay.php
Created March 30, 2020 02:57
[PHP]Get Next Business Day, include/not include holiday
<?php
/**
* One of my task is to create a function that find the next business day.
*
* Reference: https://stackoverflow.com/a/5532070/1802483
*/
class GetNextBusinessDay{
// Get a list of holiday in https://holidayapi.com/. Then I copy, paste and edit it manually to make this list
private $holidayList = [
"2020-04-04",
@alucard001
alucard001 / docker-compose.yml
Last active February 19, 2023 14:58
Docker compose for Kafka + Zookeeper + Kafka UI - Just work!
# Just run `docker compose up --build` to build and run these containers
# To access the UI go to http://localhost
# While I haven't REALLY use program to access producer/consumer, you can use the Python wrapper
# provided by Confluent: https://developer.confluent.io/get-started/python/#introduction
# to get start
version: "3"
services:
zookeeper:
@alucard001
alucard001 / llama.ipynb
Created July 22, 2023 10:28
llama.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.