Skip to content

Instantly share code, notes, and snippets.

@akash4gb
akash4gb / CodeGenerator.sql
Last active August 29, 2022 09:54
Generate Code SQL
-- exec [dbo].[generateCodeForModule] 'DOCTOR_SERVICE'
IF(@ModuleName = 'DOCTOR_SERVICE')
BEGIN
SELECT @Counter = ISNULL(MAX(SUBSTRING(ServiceRequisitionCode,9,4)),0)
FROM DoctorService_Requisition
WHERE FORMAT(CreatedOn, 'yyyy-MM') = FORMAT(GETDATE()-20, 'yyyy-MM');
SET @Counter =@Counter + 1;
@akash4gb
akash4gb / dynamicSQL.sql
Created June 26, 2022 12:38
Dynamic SQL
DECLARE @ExcludedList VARCHAR(MAX)
SET @ExcludedList = '3,4,22,6014'
declare @sql nvarchar(Max)
Set @sql='SELECT * FROM [A] WHERE Id NOT IN ('+@ExcludedList+')'
exec sp_executesql @sql
@akash4gb
akash4gb / blinker.css
Last active May 15, 2022 09:58
Blink effect css
.blink_me {
animation: blinker 1.5s linear infinite;
}
@keyframes blinker {
50% { opacity: 0.5; }
}
@akash4gb
akash4gb / datetime.js
Created February 23, 2020 07:38
[C# datetime to Js datetime] #dateTime
var cSharpDate = "/Date(1425408717000)/"
var jsDate = new Date(parseInt(cSharpDate.replace(/[^0-9 +]/g, '')));
@akash4gb
akash4gb / fridayCount.sql
Created February 9, 2020 02:52
[Get Friday count between two dates] This snippet of code returns friday count between two dates. #sql
--Friday count between today from 10 days ago.
declare @fridays int
SELECT @fridays = ((datediff(d, '20060210', GETDATE()) + 1)/7 - datediff(d, '20060210', GETDATE()-10)/7)
@akash4gb
akash4gb / webcam.html
Created February 5, 2020 03:21
[Webcam access and capture image] this snippet shows how to gain access of webcam and take a picture to canvas. #webcam #media
<!-- https://developers.google.com/web/fundamentals -->
<video id="player" controls autoplay></video>
<button id="capture">Capture</button>
<canvas id="canvas" width=320 height=240></canvas>
<script>
const player = document.getElementById('player');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture');
@akash4gb
akash4gb / emptyDataSource.js
Created January 23, 2020 05:19
[Empty KendoGrid dataSource] To make empty data source or kendo grid, use this line of jquery code. #kendoUI
$("#grid").data('kendoGrid').dataSource.data([]);
@akash4gb
akash4gb / today.js
Created January 11, 2020 06:52
[Today's day name, month name javascript] This snippet works for weekday, monthname, year of today in javascript. #dayName #monthName
var d = new Date();
var month = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear();
var weekDay = d.getDay();
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
const days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
@akash4gb
akash4gb / Backup.bat
Created December 22, 2019 06:24
[OneClickBackup] This executable batch file helps to make backup copy of a source with automatic dated folder #backup #batch
for /f "skip=1" %%i in ('wmic os get localdatetime') do if not defined fulldate set fulldate=%%i
set year=%fulldate:~0,4%
set month=%fulldate:~4,2%
set day=%fulldate:~6,2%
set foldername=%year%.%month%.%day%-v.0
set /a sum = 1
:chk
if exist %foldername% set foldername=%foldername:~0,14%%sum%&set /a sum += 1&goto chk
md %foldername%
@akash4gb
akash4gb / KendoNumericInputOnly.js
Created October 21, 2019 09:08
[Kendo grid cell only numeric input] To make Kendo gris's cell input box only takes numeric and spinner is disabled. #kendo #input #numeric
{ field: "UnitsInStock", title: "Units In Stock", editor: editNumberWithoutSpinners }
function editNumberWithoutSpinners(container, options) {
$('<input data-text-field="' + options.field + '" ' +
'data-value-field="' + options.field + '" ' +
'data-bind="value:' + options.field + '" ' +
'data-format="' + options.format + '"/>')
.appendTo(container)
.kendoNumericTextBox({
spinners : false