Skip to content

Instantly share code, notes, and snippets.

@hendrasyp
hendrasyp / dump.php
Last active November 11, 2015 09:23
How to Dump and Restore MySQL Database via Console
<?php
// BACKUP / DUMP
// mysqldump -u<username> --password='<password>' <database> <table1,table2,..> > <filename>.<sql/extension>
// RESTORE
// mysqldump -u<username> --password='<password>'; <enter>
// use <databasename>;
// source <filename>.<sql/extension>
@hendrasyp
hendrasyp / autonumber.php
Last active November 11, 2015 09:35
Function to generate Format autonumber using CodeIgniter and YII Frameworks
<?php
function _autonumber($field, $table, $Parse, $Digit_Count) {
$NOL = "0";
$query = "Select " . $field . " from " . $table . " where " . $field . " like '" . $Parse . "%' order by " . $field . " DESC LIMIT 0,1";
// CODEIGNITER
$identifier = &get_instance();
$data = $identifier->db->query($query)->result_array();
// YII Way
@hendrasyp
hendrasyp / master-detail.php
Created November 9, 2016 09:03
Short Code PHP - jQuery untuk operasi master detail (Kasus POS / Transaksi)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<?php
if (isset($_POST["tombol"])) {
$head = $_POST["head"];
$detail = $_POST["item"];
echo "Head Looping Foreach <br/>";
foreach ($head as $k => $v) {
echo $k . " = " . $v . "<br/>";
}
@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
@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 / .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 / 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 / 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)
// Copyright by Bo Norgaard, All rights reserved.
using System;
using System.Text;
using System.Collections;
namespace Misc.Helpers.IPNumbers
{
/// <summary>
@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" />