Skip to content

Instantly share code, notes, and snippets.

@tklee1975
tklee1975 / ShareHelper.cpp
Created September 22, 2015 01:57
Source code for Cocos-2dx Score Sharing (Android Platform)
//
// ShareHelper.cpp
// TapToJump
//
// Created by Ken Lee on 10/9/15.
//
//
#include "ShareHelper.h"
@tklee1975
tklee1975 / send_by_gmail.py
Created September 23, 2015 02:22
Python: Send email by SMTP
#!/usr/bin/python
import smtplib
gmail_user = "sender@gmail.com"
gmail_pwd = "sender_password"
def send_email(msg, gmail_user, gmail_pwd, to_list):
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
@tklee1975
tklee1975 / send_image_mail.py
Created September 28, 2015 15:48
Sending email with embed images using python
#!/usr/bin/python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
gmail_user = "test.address@gmail.com"
@tklee1975
tklee1975 / test.java
Created January 26, 2016 02:01
Cannot do "Animation" after using Object Animator!
final TextView view = new TextView(getContext());
view.setBackground(Color.RED);
addSubview(view, 100, 100, 100, 100); // my method: param: view, x, y, width, height
// Playing objectAnimator
Animator anime = (Animator) AnimatorInflater.loadAnimator(this.getContext(), R.anim.pulse);
anime.setTarget(view);
// Try to listen to the end of the animation
anime.addListener(new AnimatorListener() {
@tklee1975
tklee1975 / math_a_to_h_eq_ppp.py
Created March 30, 2016 03:40
Solution to Math Quiz (A + B ... + H = PPP)
#!/usr/bin/python
# Reference:
# http://stackoverflow.com/questions/104420/how-to-generate-all-permutations-of-a-list-in-python
import itertools;
def test_permutations():
print "test permutation";
@tklee1975
tklee1975 / gist:d8c4d1ea671f238efd0a5c6902d07d8b
Last active April 7, 2017 05:25
Unity Editor Script to generate new Component and Add it to the selected object
using UnityEditor;
using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.Text;
// Reference
// http://answers.unity3d.com/questions/12599/editor-script-need-to-create-class-script-automati.html
// http://answers.unity3d.com/questions/1007004/generate-script-in-editor-script-and-gettype-retur.html
@tklee1975
tklee1975 / TimeMeter.cpp
Created July 9, 2017 19:16
TimeMeter - A simple C++ code to measure the running time of the block of codes
//
// TimeMeter.cpp
// GhostLeg
//
// Created by Ken Lee on 7/7/2017.
//
//
#include "TimeMeter.h"
@tklee1975
tklee1975 / CreateObjectTest.cs
Last active July 28, 2017 03:53
Instantiate() vs Awake() vs Start()
public void testCreateObject() // Testing Instantiate
{
float x = Random.Range(-3, 3);
float y = Random.Range(-3, 3);
Vector3 position = new Vector3(x, y, 0);
Debug.Log("Before Instantiate");
GameObject obj = GameObject.Instantiate(sourceObject, position, Quaternion.identity);
Debug.Log("After Instantiate");
@tklee1975
tklee1975 / SimpleTextureShader.shader
Created August 4, 2017 08:07
Unity Basic Shader Crash Course
Shader "Custom/ShaderCrashCourse/Emptyshader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
// reference: http://danjohnmoran.com/Shaders/101/
Shader "Custom/ShaderCrashCourse/SimpleColorshader"
{
SubShader
{
Tags
{
"PreviewType" = "Plane"
}