Skip to content

Instantly share code, notes, and snippets.

View theanam's full-sized avatar
One coffee every five minute.

Anam Ahmed theanam

One coffee every five minute.
View GitHub Profile
@theanam
theanam / resize_image_in_frontend.js
Last active September 21, 2021 05:03
A small JavaScipt function to resize image in frontend and return a new JPEG file
/****
Creatd by Anam Ahmed (https://anam.co)
Sample Use:
document.querySelector("input[type=file]").addEventListener("change",function(e){
if(e.target.files.length){
_resample(e.target.files[0],1000,function(response){
console.log(response); // returns an object: {stats:<compression stats>,file:output file}
});
}
});
@theanam
theanam / crux1_start_gcode_kp3s.gcode
Created November 24, 2022 21:07
Crux 1 start Gcode if you are using kp3s profile
; start heating up the bed and nozzle together
M140 S{material_bed_temperature_layer_0} ; Set bed temperature
M104 S{material_print_temperature_layer_0} T0 ; Set nozzle temp
G28 ; home all axes
M190 S{material_bed_temperature_layer_0} ; Set bed temperature and wait
M109 S{material_print_temperature_layer_0} T0 ; Set nozzle temp and wait
M117 Purge extruder
G92 E0 ; reset extruder
G1 Z5.0 F3000 ; move z up little to prevent scratching of surface
G1 X5 Y20 Z0.3 F5000.0 ; move to start-line position
@theanam
theanam / number.js
Created September 29, 2018 20:14
LWHH JavaScript Course Number Project
let x = parseInt(process.argv[2]);
let y = parseInt(process.argv[3]);
console.log(x+y);
@theanam
theanam / crux1_start.gcode
Last active September 16, 2023 06:10
Tronxy Crux 1 Start G-Code for cura
; Tronxy Crux1 Start Code
; Forked from the Tronxy XY 2 Pro Start code on cura
; Improvement: Start nozzle and bed heating together
; Imorovement: Fixed purge line (XY2 version was for a bigger bed and would draw out of build area)
; Bugfix: On glass bed Crux 1, the nozzle would bump on the retainer trying to draw the purge line. Fixed in this version.
; Cleanup: Removed all ABL related code since Crux 1 does not have ABL.
G21 ; Set units to millimeters
G90 ; Set all axis to Absolute
M82 ; Set extrusion to Absolute
M107 ; Disable all fans
@theanam
theanam / regex.txt
Created September 4, 2019 10:08
Regular Expression to match Bangladeshi Phone number
/^(?:\+88|88)?(01[3-9]\d{8})$/
@theanam
theanam / sendhash.js
Last active January 18, 2024 15:52
create SMS OTP hash
const otpGenerator = require("otp-generator");
const crypto = require("crypto");
const key = "verysecretkey"; // Key for cryptograpy. Keep it secret
function createNewOTP(phone){
// Generate a 6 digit numeric OTP
const otp = otpGenerator.generate(6, {alphabets: false, upperCase: false, specialChars: false});
const ttl = 5 * 60 * 1000; //5 Minutes in miliseconds
const expires = Date.now() + ttl; //timestamp to 5 minutes in the future
const data = `${phone}.${otp}.${expires}`; // phone.otp.expiry_timestamp
@theanam
theanam / otpverify.js
Last active March 31, 2024 17:05
OTP verification without database, full sample source code
const otpGenerator = require("otp-generator");
const crypto = require("crypto");
const key = "verysecretkey"; // Key for cryptograpy. Keep it secret
function createNewOTP(phone){
// Generate a 6 digit numeric OTP
const otp = otpGenerator.generate(6, {alphabets: false, upperCase: false, specialChars: false});
const ttl = 5 * 60 * 1000; //5 Minutes in miliseconds
const expires = Date.now() + ttl; //timestamp to 5 minutes in the future
const data = `${phone}.${otp}.${expires}`; // phone.otp.expiry_timestamp