Skip to content

Instantly share code, notes, and snippets.

@hidayat365
hidayat365 / REST-helper.php
Last active February 18, 2017 07:28
REST Helper Function using PHP
/*
* REST_Helper: Helper untuk mengakses layanan REST
* Bisa digunakan walaupun fungsi cURL diblokir
*
* @param string $url URL yang mau kita buka
* @param optional array $params data yang mau kita POST ke $url
* @param optional string method either POST or GET
* @param optional string format payload
*/
function rest_helper($url, $params = null, $verb = 'GET', $format = 'text')
@hidayat365
hidayat365 / sp_insert.sql
Last active July 19, 2016 07:12
Stored Procedure untuk encapsulate beberapa perintah SQL menjadi satu kesatuan.
-- -------------------------
-- ini stored procedure-nya
-- -------------------------
CREATE PROCEDURE InsertDataSMS
@KodeKel int,
@KodeTPS int,
@SuaraPartai int,
@KodeCaleg1 int = -1,
@SuaraCaleg1 int = -1,
@KodeCaleg2 int = -1,
@hidayat365
hidayat365 / explain-plan.sql
Created February 19, 2014 16:00
EXPLAIN PLAN menjelaskan Query langsung terhadap table dan view adalah sama saja di MySQL
mysql> -------------------------------------
mysql> ini execution plan
mysql> untuk query langsung ke base table
mysql> -------------------------------------
mysql> explain
-> select a.*, b.account_id, b.item_id, b.debet, b.credit
-> from journals a
-> join journal_details b on a.id=b.journal_id
-> where a.id=1 ;
+----+-------------+-------+-------+-----------------------------+---------+---------+-------+------+-------------+
@hidayat365
hidayat365 / table.html
Created February 18, 2014 07:43
Membuat HTML Table dengan Header bertingkat
<table>
<tr>
<th rowspan="3">No.</th>
<th rowspan="3">Nomor Induk</th>
<th rowspan="3">Nama Lengkap</th>
<th colspan="12">Aspek Penilaian</th>
<th rowspan="3">NR</th>
</tr>
<tr>
<th colspan="5">Tugas</th>
@hidayat365
hidayat365 / combobox-fill.vb
Created December 24, 2013 03:57
Cara paling simple bin mudah untuk menampilkan isi combobox secara dinamis berdasarkan table yang ada di database menggunakan VB.net
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
InitializeComboBox()
End Sub
Private Sub InitializeComboBox()
@hidayat365
hidayat365 / garansi.sql
Created December 17, 2013 14:30
MySQL, menggunakan query untuk menentukan apakah masa garansi sudah habis atau belum berdasarkan tanggal hari ini dan tanggal akhir masa garansi.
mysql> use test ;
Database changed
mysql> -- --------------------------------------
mysql> -- create table contoh
mysql> -- --------------------------------------
mysql> create table garansi (
-> id int auto_increment primary key,
-> awal_garansi date null,
-> akhir_garansi date null
@hidayat365
hidayat365 / timespan.cs
Created December 6, 2013 04:09
Contoh penggunaan TimeSpan di c#
private string HitungUsia(DateTime awal, DateTime akhir)
{
TimeSpan selisih = akhir.Subtract(awal);
int tahun = Convert.ToInt32(selisih.Days / 365);
int bulan = Convert.ToInt32(selisih.Days % 365 / 30);
int hari = selisih.Days - tahun * 365 - bulan * 30;
return String.Format("Usia {0} tahun {1} bulan {2} hari", tahun, bulan, hari);
}
@hidayat365
hidayat365 / caesar.cs
Created October 29, 2013 20:44
Implementasi Caesar Cipher/Encryption menggunakan c#
using System;
class Program
{
/// <summary>
/// Pengkodean Caesar dengan menggeser huruf.
/// </summary>
static string Caesar(string value, int shift)
{
char[] buffer = value.ToCharArray();
@hidayat365
hidayat365 / aggregate.sql
Created October 17, 2013 02:12
Contoh Penggunaan COUNT, MIN dan MAX dalam SQL, studi kasus database MySQL. untuk database lain sintaks sama saja.
D:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
@hidayat365
hidayat365 / drupal-form.php
Created October 3, 2013 07:39
Custom drupal form with table select and paging
<?php
function referrals_search_cardlist2() {
global $user;
$output = drupal_render(drupal_get_form('referrals_form_listpin'));
return $output;
}
function referrals_form_listpin()
{