Skip to content

Instantly share code, notes, and snippets.

View NaserKhoshfetrat's full-sized avatar

Naser Khoshfetrat NaserKhoshfetrat

View GitHub Profile
-- list indexes
-- http://stackoverflow.com/a/428235/10245
-- https://gist.github.com/timabell/6da05a2b2542c907f179
select
o.name as TableName,
i.name as IndexName,
i.type,
i.is_unique,
ic.key_ordinal as ColumnOrder,
ic.is_included_column as IsIncluded,
// method to add to dbcontext
/// <summary>
/// Set EF's OriginalValue of RowVersion for 'entity' to the supplied value.
/// This allows you to make use of EF's built-in concurrent-editing
/// when you don't have the entity as it was presented to the user to
/// edit (because of the stateless nature of the web).
/// Call this before SaveChanges to ensure concurrent edits don't go
/// unnoticed by users.
/// More info: http://stackoverflow.com/a/9190378/10245
@NaserKhoshfetrat
NaserKhoshfetrat / extended_attributes.sql
Created September 13, 2021 08:55 — forked from timabell/extended_attributes.sql
source-controllable self-enforcing extended attribute list for sql server
-- Permanent copy of schema extended properties
-- In a format suitable for easy source control and hand-editing.
-- All the properties are prefixed and only those will be added/updated/deleted by this script
-- At the bottom you'll find a commented-out `select` for generating the
-- insert block from an existing schema's extended properties.
@NaserKhoshfetrat
NaserKhoshfetrat / ms_descriptions.sql
Created September 13, 2021 08:55 — forked from timabell/ms_descriptions.sql
sql server description property management
/*
# About
Source: https://gist.github.com/timabell/6fbd85431925b5724d2f
Permanent copy of schema documentation in a format suitable for
easy source control and hand-editing.
This script template was created by Tim Abell, (c) 2015-2018
@NaserKhoshfetrat
NaserKhoshfetrat / DirectoryAndFileUtils.cs
Created August 22, 2021 12:02
c# file and folder method
public class DirectoryAndFileUtils
{
public byte[] ReadFile(string path)
{
try
{
byte[] readBuffer = File.ReadAllBytes(path);
return readBuffer;
}
catch (IOException e)
System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
HttpContext.Current.Server.MapPath("~/UploadedFiles);
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
@NaserKhoshfetrat
NaserKhoshfetrat / CreatePivotTableModule.bas
Last active June 25, 2021 20:43
vba Create Pivot Table Module
Attribute VB_Name = "Module5"
Sub InsertPivotTableMain()
'create pivot table [test]
Call InsertPivotTable("testx", "tableTest", "newPivotTable", "data1", "data2", "data3")
End Sub
Private Sub InsertPivotTable(sourceWorksheetName As String, TableName As String, newWorksheetName As String, RowField As String, DataField1 As String, DataField2 As String)
'Declare Variables
Dim PSheet As Worksheet
@NaserKhoshfetrat
NaserKhoshfetrat / APIHelper.java
Created November 9, 2020 16:48 — forked from pallavahooja/APIHelper.java
Retrofit Retry
package app.goplus.in.v2.network;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by pallavahooja on 16/05/16.
*/
public class APIHelper {
@NaserKhoshfetrat
NaserKhoshfetrat / BackoffCallback.java
Created November 9, 2020 16:43 — forked from milechainsaw/BackoffCallback.java
Exponential backoff support for Retrofit2.
/**
* Created by milechainsaw on 7/19/16.
*
* Exponential backoff callback for Retrofit2
*
*/
public abstract class BackoffCallback<T> implements Callback<T> {
private static final int RETRY_COUNT = 3;
/**
* Base retry delay for exponential backoff, in Milliseconds