Skip to content

Instantly share code, notes, and snippets.

View NaserKhoshfetrat's full-sized avatar

Naser Khoshfetrat NaserKhoshfetrat

View GitHub Profile
@NaserKhoshfetrat
NaserKhoshfetrat / number.js
Last active June 28, 2018 06:17
javascript check if string is a positive integer
function func_is_positiveInt(checkValue){
var status = false;
var number = Number(checkValue.replace(/[^0-9.]/g, ""));
if (Number.isInteger(number)){
if (number > 0){
status = true;
}
}
return status;
}
<div class="break15px"> &nbsp </div>
<div id="content" class="bg_form div_row">
<asp:Button CssClass="button_highlighted" ID="btn_create_event" runat="server" Text="ایجاد پیامک مناسبت" />
<div class="searchWrap div_two_column">
<div class="search">
<input type="text" class="searchTerm" placeholder="جستجو ؟ " />
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</div>
@NaserKhoshfetrat
NaserKhoshfetrat / ExecUDF_scalar.cs
Created June 13, 2018 08:15
c# Execute UDF scalar in sql server
public T ExecUDF_scalar<T>(string UDFName, string[] ParamNames, object[] ParamValues)
{
try
{
SqlCommand Comm = new SqlCommand();
Comm.Connection = MyConnection;
Comm.CommandText = string.Format("SELECT [dbo].[{0}] ({1}) ", UDFName, string.Join(",",ParamNames));
Comm.Parameters.Clear();
for (int i = 0; i < ParamNames.Length; i++)
@NaserKhoshfetrat
NaserKhoshfetrat / stingify.cs
Created June 13, 2018 06:20
c# convert list to string
private string Stringify(string[] list,string seprator) {
string result = string.Empty;
/*
var result = list
.Skip(1)
.Aggregate(
list.FirstOrDefault() ?? string.Empty,
(total, current) => total + "," + current);
*/
@NaserKhoshfetrat
NaserKhoshfetrat / button_highlighted.css
Last active June 9, 2018 13:46
css button highlighted
/*#region button_highlighted */
.button_highlighted {
background-color: white;
color: black;
border: 2px solid #008CBA;
border-radius: 4px;
font-size: 18px;
padding-top: 3px;
padding-bottom: 3px;
.module_path{
background-attachment: scroll;
background-color: #f0f0f0;
background-image: url("images/txtbg.png");
background-repeat: repeat-x;
border: 1px solid #acacac;
border-radius: 6px;
color: #6c6c6c;
font-family: Tahoma;
font-size: 11px;
@NaserKhoshfetrat
NaserKhoshfetrat / delayed iterate.js
Created June 7, 2018 12:38
javascript delayed iterate
//#region delayed iterate
function Func_Delayed_iterate_timer(ms){
return new Promise(r=>setTimeout(r,ms));
}
async function Func_Delayed_iterate(iterate,delay) {
for (var i = 0; i < iterate; i++) {
process.stdout.write(`index ${i} \n`);
await Func_Delayed_iterate_timer(delay);
}
}
@NaserKhoshfetrat
NaserKhoshfetrat / GET_FIRST_OR_DEFAULT.cs
Created June 3, 2018 12:13
c# get first or default value in generic method
public T GET_FIRST_OR_DEFAULT<T>(DataSet dataset)
{
return GET_FIRST_OR_DEFAULT<T>(dataset, default(T));
}
public T GET_FIRST_OR_DEFAULT<T>(DataSet dataset, T defaultValue)
{
bool status = true;
if (dataset.Tables.Count == 0)
{
status = false;
declare @endDateTime datetime = cast(getdate() + 1 as date);
declare @startDateTime datetime = DATEADD(dd, 1, DATEDIFF(dd, 0, GETDATE())) ;
set @endDateTime= dateadd(second, 86399, @endDateTime)
@NaserKhoshfetrat
NaserKhoshfetrat / sqlQuerry.sql
Created May 20, 2018 06:43
sqlserver get table info
SELECT concat(', [',COLUMN_NAME,'] = ' ,' @', COLUMN_NAME, ' ')
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tblEvent'