Skip to content

Instantly share code, notes, and snippets.

View chinhvo's full-sized avatar

Chinh Vo Wili chinhvo

View GitHub Profile
@chinhvo
chinhvo / sp_generate_inserts.sql
Created October 21, 2019 10:13 — forked from GeorgeDellinger/sp_generate_inserts.sql
My copy of sp_generate_inserts scripts..... Only changes: Commented out the calls to sp_MS_upd_sysobj_category.Added sp_MS_marksystemobject to end of script.
SET NOCOUNT ON
GO
PRINT 'Using Master database'
USE master
GO
PRINT 'Checking for the existence of this procedure'
IF (SELECT OBJECT_ID('dbo.sp_generate_inserts','P')) IS NOT NULL --means, the procedure already exists
BEGIN
@chinhvo
chinhvo / media-query.css
Created June 27, 2019 09:21 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
internal static IQueryable<TEntity> Include<TEntity>(this IQueryable<TEntity> query, DbContext context, params string[] includes) where TEntity : class
{
// Do a safety check first
if (includes == null)
return query;
List<string> includeList = new List<string>();
if (includes.Any())
return includes
.Where(x => !string.IsNullOrEmpty(x) && !includeList.Contains(x))
@chinhvo
chinhvo / sqlpackage.md
Created February 23, 2019 12:49 — forked from anova/sqlpackage.md
Sqlpackage.exe samples

Export

Creates a .bacpac file from live database.

"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /a:Export /scs:"Data Source=SERVER;Initial Catalog=db_name;Integrated Security=False;Persist Security Info=False;User ID=db_user;Password=db_password" /tf:"D:\backup\database_backup.bacpac"

Import

Import from .bacpac file to database.

@chinhvo
chinhvo / CustomItemClickListener.java
Created December 4, 2018 13:08 — forked from riyazMuhammad/CustomItemClickListener.java
Easy Implementation of RecyclerView custom onItemClickListener
public interface CustomItemClickListener {
public void onItemClick(View v, int position);
}
@chinhvo
chinhvo / MySQLiteOpenHelper
Created December 2, 2018 04:38 — forked from nxax/MySQLiteOpenHelper
Check table if exists on SQLite
// Check table if exists on SQLite
// http://stackoverflow.com/questions/3058909/how-does-one-check-if-a-table-exists-in-an-android-sqlite-database
//
public boolean isTableExists(String tableName, boolean openDb) {
if(openDb) {
if(mDatabase == null || !mDatabase.isOpen()) {
mDatabase = getReadableDatabase();
}
if(!mDatabase.isReadOnly()) {
@chinhvo
chinhvo / DatabaseUtil.java
Created November 4, 2018 09:43 — forked from shashankitmaster/DatabaseUtil.java
Generic Class Useful for Database Operations in Android Applications. It's easy to ship your db to application with this code.
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import java.io.File;
@chinhvo
chinhvo / online_learning_resources.md
Created September 3, 2018 16:03 — forked from softwarespot/online_learning_resources.md
JavaScript/PHP/C/C#/Java online learning resources

Online Learning Resources

The following document was updated on 2017/04/28

Disclaimer: I'm very much aware documents like this already exist and no doubt I will end up linking to them as well. But I wanted to have corner of my own where I could document links and short snippets that are useful to me.


JavaScript

@chinhvo
chinhvo / SubdomainRoute.cs
Created May 18, 2018 14:07 — forked from bjcull/SubdomainRoute.cs
A class to detect the subdomain and pass it through as a route parameter
public class SubdomainRoute : RouteBase
{
public override RouteData GetRouteData(HttpContextBase httpContext)
{
if (httpContext.Request == null || httpContext.Request.Url == null)
{
return null;
}
var host = httpContext.Request.Url.Host;
@chinhvo
chinhvo / CustomRequireHttpsFilter.cs
Created May 18, 2018 14:07 — forked from bjcull/CustomRequireHttpsFilter.cs
An improved HTTPS redirection filter for ASP.NET MVC.
public class CustomRequireHttpsFilter : RequireHttpsAttribute
{
protected override void HandleNonHttpsRequest(AuthorizationContext filterContext)
{
// The base only redirects GET, but we added HEAD as well. This avoids exceptions for bots crawling using HEAD.
// The other requests will throw an exception to ensure the correct verbs are used.
// We fall back to the base method as the mvc exceptions are marked as internal.
if (!String.Equals(filterContext.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)
&& !String.Equals(filterContext.HttpContext.Request.HttpMethod, "HEAD", StringComparison.OrdinalIgnoreCase))