Skip to content

Instantly share code, notes, and snippets.

@hendrasyp
hendrasyp / Foo.cs
Created November 28, 2019 01:23
How to Check Property on Dynamic Data type
/// <summary>
/// Check any property on dynamic data type whether id exists or not
/// </summary>
/// <param name="settings">your object</param>
/// <param name="name">key to search</param>
/// <returns>True or False</returns>
/// <example>
/// bool isExists = IsPropertyExists(Dictionary<string, dynamic>, string);
/// <example>
public bool IsPropertyExists(dynamic settings, string name)
@hendrasyp
hendrasyp / CommonHelper.cs
Last active November 21, 2019 07:32
Formatted Sequence Number
// db = Instance of Entities Object
public static void StoreLastSequence(int lastSequence, string prefix)
{
applicationoption applicationoption = db.applicationoption.Where(m => m.CODE == "NOMOR_INVOICE").Single();
applicationoption.VALUE = lastSequence.ToString();
db.Entry(applicationoption).State = System.Data.EntityState.Modified;
db.SaveChanges();
}
@hendrasyp
hendrasyp / BlobDataViewer.html
Last active November 14, 2019 13:07
Convert Large Base64 string to blob Data
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Document Viewer</title>
</head>
<body style="overflow: hidden;">
<div id="objviewer"> </div>
<script type="text/javascript">
const b64toBlob = (b64Data, contentType = '', sliceSize = 512) => {
const byteCharacters = atob(b64Data);
@hendrasyp
hendrasyp / Web.Config
Last active November 14, 2019 03:39
WordPress Web.Config On IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
// Copyright by Bo Norgaard, All rights reserved.
using System;
using System.Text;
using System.Collections;
namespace Misc.Helpers.IPNumbers
{
/// <summary>
@hendrasyp
hendrasyp / FilterIPAttribute.cs
Created November 8, 2019 03:19 — forked from rdingwall/FilterIPAttribute.cs
FilterIPAttribute for ASP.NET Web API (IIS only, port of MVC version from http://stackoverflow.com/a/4605086/91551)
using System;
using System.Configuration;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
namespace Miscellaneous.Attributes.Controller
{
/// <summary>
/// Filter by IP address (ASP.NET Web API version)
@hendrasyp
hendrasyp / FilterIPAttribute.cs
Created November 8, 2019 03:18
FilterIPAttribute for ASP.NET Web API (ported from https://gist.github.com/rdingwall/2028849), (IIS only, port of MVC version from http://stackoverflow.com/a/4605086/91551),
using Misc.Helpers.IPNumbers;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
namespace Misc.WebApi.Filters
{
@hendrasyp
hendrasyp / .htaccess
Last active March 19, 2019 01:52
Optimasi Website Menggunakan htaccess
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
@hendrasyp
hendrasyp / FindIndex.js
Created August 30, 2018 05:01
Find Index for IE Issue
// 1. Use object.some
var index = -1;
items.some(function(el, i) {
if (el.OBJECT_NAME == "search") {
index = i;
return true;
}
});
// 2. use underscore.js
@hendrasyp
hendrasyp / cache.htaccess
Created March 7, 2017 05:01 — forked from jcanfield/cache.htaccess
.htaccess caching rules
<IfModule mod_mime.c>
# Text
AddType text/css .css
AddType application/x-javascript .js
AddType text/html .html .htm
AddType text/richtext .rtf .rtx
AddType text/plain .txt
AddType text/xml .xml