Skip to content

Instantly share code, notes, and snippets.

@kiichi
kiichi / generate_excel.php
Last active November 21, 2020 19:25
Generate Excel using HTML format
function downloadExcel($table_html, $style_html){
$file="gmdi.xls";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
$excel = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<!--[if gte mso 9]>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
@kiichi
kiichi / test_email.php
Created October 10, 2020 15:53
PHP Email Test Script
<?php
$subject = 'hello world';
$mailto = '(my email)';
$mailfrom = 'do_not_reply@(email)';
$content = 'Test email !';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:".$mailfrom;
//$success = mail($mailto,$subject,$content,$headers);
$success = mail($mailto,$subject,$content);
@kiichi
kiichi / upsert.sql
Last active March 25, 2020 16:48
SQL Server Tips
MERGE Meetings target
USING (
VALUES ('2')
) AS source (uuid)
ON target.uuid = source.uuid
WHEN MATCHED THEN
UPDATE SET target.topic = 'updated'
WHEN NOT MATCHED THEN
INSERT (uuid, topic)
VALUES (source.uuid,'inserted')
@kiichi
kiichi / text-to-speech.js
Last active March 16, 2020 21:35
Text to Speech Using Chrome API (Speech Synthesis)
// This takes time... keep the voice reference somewhere before clicking on something
let voice_type = speechSynthesis.getVoices().find(function(voice) { return voice.name == 'Samantha'; });
// e.g. after click event
var msg = new SpeechSynthesisUtterance();
msg.voice = voice_type;
msg.text = "Awesome!";
msg.rate = 1.4;
msg.pitch = 3.0;
window.speechSynthesis.speak(msg);
@kiichi
kiichi / RSA.md
Last active August 5, 2020 02:02
Find private key from pair of 2 prime numbers
@kiichi
kiichi / Pokemon.js
Last active August 10, 2019 14:42
Use Pokemon to teach OOP for millennials rather than dull examples like "Car" or "Animal". They don't even drive car with combustion engine.
// --------------------------
// Base
class PokeDex {
constructor(name, hp, atk, gen, type){
this.name = name;
this.hp = hp;
this.atk = atk;
this.gen = gen;
this.type = type;
this.rare = false;
@kiichi
kiichi / index.html
Created August 7, 2019 03:01
APK Download One Page with Instructions
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mini.css/3.0.1/mini-default.min.css">
</head>
<body style="padding:5px;">
<div style="text-align:center">
<br/>
@kiichi
kiichi / version.json
Last active August 6, 2019 03:58
Version Bump Script which generates version.json based on Ionic config.xml
{"date": "2019-08-05T11:44:08.787879", "core": "1.1.3", "shell": "1.0.21", "mode": "DEBUG"}
@kiichi
kiichi / robbyrussell.zsh-theme
Created August 3, 2019 14:49
ZSH Theme Configuration ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})"
PROMPT='${ret_status}${PWD/$HOME/~}%{$reset_color%}$(git_prompt_info)>'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[blue]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%})%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"