Skip to content

Instantly share code, notes, and snippets.

View lazzyms's full-sized avatar
👨‍💻

Maulik Sompura lazzyms

👨‍💻
View GitHub Profile
@lazzyms
lazzyms / drop_table.sql
Last active March 1, 2018 06:49
Getting all the table name of the database and generating a Drop table query.
SET FOREIGN_KEY_CHECKS = 0;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'DBNAME' and table_type = 'Base Table';
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;
@lazzyms
lazzyms / main.js
Created July 24, 2018 12:51
electron main.js
const setupEvents = require('./installers/setupEvents')
if (setupEvents.handleSquirrelEvent()) {
// squirrel event handled and app will exit in 1000ms, so don't do anything else
return;
}
const {
app,
BrowserWindow,
ipcMain
} = require('electron')
@lazzyms
lazzyms / mysql.js
Created July 24, 2018 13:05
Node.js code to connect to mysql
var http = require("http");
var mysql = require("mysql");
var fs = require("fs");
var jsonContent = null;
const prompt = require('electron-prompt');
var userdata = {
"host": '',
"port": '',
"username": '',
"password": '',
@lazzyms
lazzyms / copy.js
Created July 24, 2018 13:19
copy the built project to another folder.
const fs = require('fs-extra')
var del = require("delete");
//delete js
console.log("Deleting Old JS");
del.sync('../electron/main.*.js', {
force: true
});
console.log("Deleted");
<UserControl x:Class="TestApp.mainUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SaiData.TestApp"
mc:Ignorable="d"
>
<Grid>
<Grid.ColumnDefinitions>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
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;
@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) {
@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 / 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);