Skip to content

Instantly share code, notes, and snippets.

@anoochit
anoochit / thai-id-card.go
Created May 11, 2021 — forked from bouroo/thai-id-card.go
Thai National ID Card reader in GO
View thai-id-card.go
package main
// Require pcscd, libpcsclite
import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"os"
"strconv"
@anoochit
anoochit / BankSmartContract.sol
Last active May 10, 2021
Basic Bank SmartContract
View BankSmartContract.sol
pragma solidity 0.6.6;
contract OPPBank {
int balance;
constructor() public {
balance=0;
}
function getBalance() view public returns(int) {
@anoochit
anoochit / wifimanager-esp32.ino
Last active May 9, 2021
ESP32 wifi manager and custom parameter SPIFFS
View wifimanager-esp32.ino
#include <FS.h> // this needs to be first, or it all crashes and burns...
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <ArduinoJson.h> // https://github.com/bblanchon/ArduinoJson
#ifdef ESP32
#include <SPIFFS.h>
#endif
//define your default values here, if there are different values in config.json, they are overwritten.
char mqtt_server[40];
View item-id-8u5h2m.json
{
"name": "Thor's hammer",
"description": "Mjölnir, the legendary hammer of the Norse god of thunder.",
"image": "https://game.example/item-id-8u5h2m.png",
"strength": 20
}
View OPPCoinERC20.sol
pragma solidity 0.6.6;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
@anoochit
anoochit / Dockerfile
Created Jun 16, 2020
Dockerfile to build dart container in small image **ONLY** x86_64 arch
View Dockerfile
FROM google/dart AS dart-runtime
WORKDIR /app
ADD pubspec.* /app/
RUN pub get
ADD bin /app/bin/
RUN pub get --offline
RUN dart2native /app/bin/server.dart -o /app/server
View leanback_android_tv_flutter.md
  • Add software leanback feature in AndroidManifest
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  • Add banner icon xhdpi 320x180 px for banner
@anoochit
anoochit / home.dart
Created Mar 11, 2021
adaptive layout with LayoutBuilder
View home.dart
import 'dart:developer';
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
View ble_advertrise.ino
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include <iostream>
#include <string>
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
@anoochit
anoochit / search.dart
Created Jan 26, 2021
simple search NOT recommended
View search.dart
Future<List<String>> searchTrip(String keyword) async {
List<String> docId = [];
var value = await FirebaseFirestore.instance.collection('trips').get();
value.docs.forEach((element) {
var title = element['name'].toString().toLowerCase();
var body = element['body'].toString().toLowerCase();
if (body.contains(keyword)) docId.add(element.id);
if (title.contains(keyword)) docId.add(element.id);
});
return docId;