Skip to content

Instantly share code, notes, and snippets.

View lazzyms's full-sized avatar
👨‍💻

Maulik Sompura lazzyms

👨‍💻
View GitHub Profile
@lazzyms
lazzyms / transform-css.js
Last active February 23, 2024 09:18
add prefix to tailwind class name in particular files within directory
const fs = require('fs');
const path = require('path');
const { tw } = require('./tw.cjs');
function addPrefixToClasses(filePath) {
console.log('processing... ', filePath);
const fileContent = fs.readFileSync(filePath, 'utf8');
let modifiedContent = fileContent;
tw.forEach((item) => {
console.log(item);
@lazzyms
lazzyms / SelectionArea.jsx
Created January 29, 2024 06:28
SelectionArea component in react to drag and select the area of canvas.
import { useEffect, useState } from "react";
import { RhButton } from "@rhythm-ui/react";
const SelectionArea = ({ onCancel, onCapture }) => {
const [startPosition, setStartPosition] = useState({ x: 0, y: 0 });
const [endPosition, setEndPosition] = useState({ x: 0, y: 0 });
const [selectState, setSelectState] = useState("init");
const handleMouseDown = (e) => {
if (selectState == "init") {
const { clientX, clientY } = e;
@lazzyms
lazzyms / react.gitlab-ci.yml
Last active September 10, 2020 04:54
Deploy React build with gitlab-ci
image: node:10
cache:
paths:
- node_modules/
before_script:
- apt-get update -qq && apt install -y openssh-client openssh-server
- mkdir -p ~/.ssh
- echo -e "$SSH_PRIVATE_KEY" > ~/deploy.pem
@lazzyms
lazzyms / README.md
Last active July 28, 2020 15:44
Interview Question - the perfect curry

We want to prepare the perfect curry with ingredients P, Q, and R. "A" is a zero-indexed array of N integers. Elements of A are integers within the range [−99,999,999 to 99,999,999] The curry is a string consisting of N characters such that each character is either P, Q, or R and the corresponding index of the array is the weight of each ingredient. The curry is perfect if the sum of the total weights of P, Q, and R is equal. Write a function function makeCurry(Array); such that, given a zero-indexed array Array consisting of N integers, returns the perfect curry of this array. The function should return the string "noLuck" if no perfect curry exists for that Array.

@lazzyms
lazzyms / getallmail.js
Last active May 23, 2020 15:04
To get all the email from links with 'mailto' action with javascript.
var links = document.getElementsByTagName('a'), hrefs = [], sendIt = '';
for (var i = 0; i<links.length; i++)
{
if(links[i].href.includes('mailto')) {
var email = links[i].href.replace('mailto:','');
//If you want to use this as array
hrefs.push(email);
//If you want to copy all email ids in one string (usually to send mail to multiple ids at once)
sendIt += email + ', ';
@lazzyms
lazzyms / index.html
Created March 26, 2019 09:04
THREE Text Animation #6
<div id="three-container"></div>
<div id="instructions">
click and drag to control the animation
</div>
@lazzyms
lazzyms / firebase.js
Created February 22, 2019 08:38
firebase configuration gist
var config = {
apiKey: "yOurAppAPIkey11",
authDomain: "your-app.firebaseapp.com",
databaseURL: "https://your-app.firebaseio.com",
projectId: "your-app",
storageBucket: "your-app.appspot.com",
messagingSenderId: "3034404405537"
};
firebase.initializeApp(config);
@lazzyms
lazzyms / FizzBuzz.js
Created January 24, 2019 12:36
A well-known interview question, FizzBuzz Problem's solution.
for (var i = 0; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
console.log('FizzBuzz')
} else if (i % 3 == 0) {
console.log('Fizz')
} else if (i % 5 == 0) {
console.log('Buzz')
} else {
console.log(i)
}
@lazzyms
lazzyms / htmlToPdfConvert.php
Created September 20, 2018 10:05
Convert Html to pdf using Chrome Headless - php script
<?php
$chrome_path = 'C:\"Program Files (x86)"\Google\Chrome\Application\chrome.exe'; // for windows user
$chrome_path = 'chromium-browser'; // for linux user, first install chromium-browser to linux
$output_file = 'path/to/store/sample.pdf';
$url = 'http://www.google.com';
$command = $chrome_path . " --headless --disable-gpu --enable-logging --print-to-pdf="
. $output_file . " " . $url . " --virtual-time-budget=1000 "; // virtual-time-budget is used for delay loading js
try {
exec($command);
} catch (Exception $ex) {
DataGrid dg = new DataGrid();
dg.HorizontalAlignment = HorizontalAlignment.Left;
dg.VerticalAlignment = VerticalAlignment.Top;
dg.AutoGenerateColumns = true;
//the function getData used to get the data from data-source, you can manipulate it.
getData gd = new getData(); // getData holds getUserRecord() to get the data
UserData[] data = gd.getUserRecord();
dg.ItemsSource = data;