Skip to content

Instantly share code, notes, and snippets.

View legndery's full-sized avatar

Aritra Chakraborty legndery

View GitHub Profile
@legndery
legndery / Workaround for Tuya: "No permissions. Your subscription to cloud development plan has expired.".js
Last active May 17, 2024 15:52
Workaround for Tuya: "No permissions. Your subscription to cloud development plan has expired."
const schedule = require('node-schedule');
const { TuyaContext } = require('@tuya/tuya-connector-nodejs');
const { exec } = require('child_process');
const answers = {
apiKey: 'xxxx', // from tuya
apiSecret: 'xxxx'
}
const deviceId = 'xx'; // from tuya
@legndery
legndery / altwin
Created February 18, 2022 15:58
Remap ALT->CTRL, CTRL->CTRL, WIN->ALT. The most common mac XKBOPTIONS
///////////////////////////////////////////
// /usr/share/X11/xkb/symbols/altwin //
///////////////////////////////////////////
// Ctrl is mapped to the Alt, Alt to the Super, and Win to the Ctrl keys.
// partial modifier_keys
// xkb_symbols "ctrl_alt_win" {
// key <LALT> { [ Control_L, Control_L ] };
// key <RALT> { type[Group1] = "TWO_LEVEL",
// symbols[Group1] = [ Control_R, Control_R ] };
server {
listen $PORT default_server;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
FROM nginx:1.21.0
COPY default.conf.template /etc/nginx/conf.d/default.conf.template
COPY nginx.conf /etc/nginx/nginx.conf
COPY static-html /usr/share/nginx/html
CMD /bin/bash -c "envsubst '\$PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf" && nginx -g 'daemon off;'
@legndery
legndery / 139 GIT ALIASES FROM ZSH FOR CMDER OR CONEMU
Last active September 22, 2021 05:44
139 GIT ALIASES FROM ZSH FOR CMDER/CONEMU
;= @REM 139 GIT ALIASES FROM ZSH
g=git $*
ga=git add $*
gaa=git add --all $*
gapa=git add --patch $*
gau=git add --update $*
gav=git add --verbose $*
gap=git apply $*cl
gapt=git apply --3way $*
gb=git branch $*
package controller
import (
"crypto-service/util"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
"net/url"
@legndery
legndery / serial-parallel-async.js
Created June 22, 2019 20:26
Using async-await
const axios = require('axios');
const empIds = ['72632', '72633', '72634'];
const dummyRESTurl = 'http://dummy.restapiexample.com/api/v1/employee/';
const result = [];
//Serial
(async () => {
for (let i = 0; i < empIds.length; i++) {
const body = await axios.get(`${dummyRESTurl}${empIds[i]}`);
@legndery
legndery / promise.all.js
Created June 22, 2019 20:17
Promise using Promise.all
const axios = require('axios');
const empIds = ['72632', '72633', '72634'];
const dummyRESTurl = 'http://dummy.restapiexample.com/api/v1/employee/';
let promises = [];
empIds.forEach((empID, i)=>{
promises.push(axios.get(`${dummyRESTurl}${empID}`));
})
@legndery
legndery / callback-req-serial.js
Created June 22, 2019 20:10
Callback Using request module
const request = require('request');
const empIds = ['72632', '72633', '72634'];
const dummyRESTurl = 'http://dummy.restapiexample.com/api/v1/employee/';
const result = [];
let count = 0;
empIds.forEach((empID, i)=>{
request(`${dummyRESTurl}${empID}`, (err, resp, body)=>{
result.push(JSON.parse(body));
var http = require('http');
var request = require('request');
var env = process.env.NODE_ENV;
var bunyan = require('bunyan');
const uuidV1 = require('uuid/v1');
var logenv = process.env.LOG_ENV;
var fileName = 'Utils';
var externalApiParams;
if(env){
fileName += '_'+env;