Skip to content

Instantly share code, notes, and snippets.

@huytd
huytd / JSONRequest.cs
Last active December 28, 2015 18:49
JSON Request class in C#
using System;
using System.Net;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Gamarist
{
public class JSON : Dictionary<string, string> { }
<script>
var fps = 30;
var time = 0;
var deltaTime = 1;
function Start() {
looper();
}
function looper() {
using UnityEngine;
using System.Collections;
public class Paint : MonoBehaviour {
Texture2D tex;
// Use this for initialization
void Start () {
tex = new Texture2D(128, 128);
GameObject.Find("Plane").renderer.sharedMaterial.mainTexture = tex;
}
@huytd
huytd / LinqJS
Created April 25, 2014 02:52
Linq for Javascript
/* LinQ for Javascript
* Author: Huy Tran - Email: kingbazoka@gmail.com
*/
/////////////////////////////////
Array.prototype.first = function(condition) {
return this[0];
}
Array.prototype.last = function(condition) {
int led = 13;
void setup() {
// đưa pin 13 về chế độ OUTPUT
pinMode(led, OUTPUT);
}
// hàm lặp chính - nơi xử lý tất cả mọi thứ cho một chương trình Arduino
void loop() {
digitalWrite(led, HIGH); // bật đèn
@huytd
huytd / android_game.java
Last active August 22, 2023 14:37
Simple game engine using Canvas for Android - using for quick prototype or simple games
package com.gamarist.momoney;
import android.os.Bundle;
import android.R.integer;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@huytd
huytd / fadeLed.c
Created June 1, 2014 04:58
Điều khiển đèn LED sáng mờ
int led = 9; // khai báo pin output là pin số 9
int doSang = 0; // biến lưu độ sáng của đèn
int tocDo = 5; // tốc độ mờ dần của đèn
void setup() {
// thiết đặt chế độ output cho pin 9
pinMode(led, OUTPUT);
}
// chương trình chính
// khai báo pin 13
const int ledPin = 13;
// Các giá trị sẽ thay đổi
int ledState = LOW; // ledState - trạng thái của đèn LED
long previousMillis = 0; // thời gian của lần vừa xử lý
long interval = 1000; // biên độ chênh lệch thời gian - đây sẽ là thời gian cần delay
void setup() {
@huytd
huytd / objcFoundation.m
Last active August 29, 2015 14:02
Objective-C class, inheritance, protocol, delegate demo
#import <Foundation/Foundation.h>
@interface DaGiac: NSObject {
int a;
int b;
}
@property int a;
@property int b;
-(float) getDienTich;
@end
@huytd
huytd / bootstrap.showDialog.js
Created July 16, 2014 07:51
Bootstrap Modal Dialog plugin for jQuery
jQuery.showDialog = function (options) {
var settings = $.extend({
confirm: true,
message: "Hurahhh!!!",
success: function () { },
cancel: function () { }
}, options);
var clickedOK = false;
var html = '<div class="modal fade" id="modalDialog" tabindex="-1" role="dialog"> ' +
' <div class="modal-dialog modal-sm"> ' +