Skip to content

Instantly share code, notes, and snippets.

@tuanpmt
tuanpmt / app_pid.c
Created January 9, 2014 02:50
PID library
/*app examle */
#include "pid.h"
PID pid;
double vInput, vSetpoint, pwmOutput;
double kp = 3, ki = 7, kd = 0.1, sampleTime = 100;
/* initilize pid in initilization function */
void APP_Init()
{
@tuanpmt
tuanpmt / Form1.cs
Created January 9, 2014 04:55
HOW TO UPDATE UI FROM THREAD
public Form1()
{
InitializeComponent();
serialPort1.PortName = "COM2";
serialPort1.BaudRate = 9600;
serialPort1.Open();
Thread oThread = new Thread(new ThreadStart(recvThread));
oThread.Start();
}
exports.attendanceToday = function(day, _callback) {
var beginDay = moment(day).tz("Asia/Ho_Chi_Minh").startOf('day');
var endDay = moment(day).tz("Asia/Ho_Chi_Minh").endOf('day');
async.waterfall([
/*Get all employers*/
function(cb){
Employer
@tuanpmt
tuanpmt / esp_mqtt-usage
Created January 15, 2015 07:03
esp_mqtt-usage
#include "ets_sys.h"
#include "driver/uart.h"
#include "osapi.h"
#include "mqtt.h"
#include "wifi.h"
#include "config.h"
#include "debug.h"
#include "gpio.h"
#include "user_interface.h"
@tuanpmt
tuanpmt / php7_build_ubuntu15.04.sh
Created December 4, 2015 07:32 — forked from m1st0/php_build_ubuntu.sh
Compiling PHP 7 on Ubuntu 15.04 with LDAP Support
#! /bin/bash
## PHP 7 Initial Compile ##
## Some help from the various places like these. ##
# http://www.zimuel.it/install-php-7/
# http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
## Setup Ubuntu 15.04 ##
# I like the speed of Apt-Fast. Will check for installs some other day.
sudo apt-get install apt-fast
#!/bin/bash
# @Author: Tuan PM
# @Date: 2016-10-07 15:43:09
# @Last Modified by: Tuan PM
# @Last Modified time: 2016-10-07 17:34:59
declare -a ext=("mp3" "aac" "ogg" "flac")
declare -a rate=("8000" "11025" "22050" "44100" "48000")
declare -a bitw=("16", "24")
declare -a channel=("2")
#include "rtc.h"
#include "hw_config.h"
#define UPDATE_INTERVAL (24*60*60)
DATE_TIME sysTime, localTime;
static enum {
INITIAL,
WAIT_GPS,
STANDBY

Keybase proof

I hereby claim:

  • I am tuanpmt on github.
  • I am tuanpm (https://keybase.io/tuanpm) on keybase.
  • I have a public key ASA3NA8bWIVtGx6DAT3kW6-cdAxoHl26JniPbjUqr-69EAo

To claim this, I am signing this object:

@tuanpmt
tuanpmt / format.java
Last active May 2, 2022 08:17
formating code
//DON'T
public void DoSomething()
{
for (var i = 0; i < 1000; i++)
{
var productCode = $"PRC000{i}";
//...implementation
}
}
@tuanpmt
tuanpmt / kss.c
Created May 2, 2022 08:42
Keep it simple, stupid
//for understanding weekday2 there are more details to think about
const char *weekday2(int dayOfWeek)
{
if ((dayOfWeek < 1) || (dayOfWeek > 7)) {
ESP_LOGE(TAG, "dayOfWeek must be in range 1..7");
return NULL;
}
const char *weekdays = {
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"