Skip to content

Instantly share code, notes, and snippets.

@philiplambok
philiplambok / improve-spec.md
Last active August 20, 2019 04:29
Improve system spec with rack_session_access

Before

$> time rspec
Finished in 6 minutes 54 seconds (files took 13.31 seconds to load)
823 examples, 0 failures

Coverage report generated for RSpec to /home/harukaedu/Codes/ruby/cms-corp-u/coverage. 2908 / 3003 LOC (96.84%) covered.
bundle exec rspec  151,89s user 21,29s system 39% cpu 7:14,58 total
@philiplambok
philiplambok / index.php
Created August 14, 2019 13:35
problem value not send to controller.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Add Remove Dynamic HTML Fields using JQuery Plugin in PHP</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
@philiplambok
philiplambok / query.md
Created July 25, 2019 02:46
history of improvement query.
 courses = Moodle::Course.taken_by(current_user)
 // Completed 200 OK in 161ms (Views: 0.2ms | ActiveRecord: 37.6ms
 // Completed 200 OK in 102ms (Views: 0.2ms | ActiveRecord: 31.1ms)
``

``rb
courses = Moodle::Course.includes(user_enrollments: [{ enrollments: [:courses] }]).taken_by(current_user)
// Completed 200 OK in 148ms (Views: 0.2ms | ActiveRecord: 37.4ms)
// Completed 200 OK in 109ms (Views: 0.1ms | ActiveRecord: 34.8ms)
@philiplambok
philiplambok / rails-object-style-guide.md
Created July 12, 2019 00:35
Rails object style guide

reserved

@philiplambok
philiplambok / spec_run.md
Last active May 31, 2019 05:58
CMS Test profiler.

Saat ini

$> time rspec
bundle exec rspec  488,63s user 20,80s system 39% cpu 21:22,95 total

Setelah di improve.

(start --branch develop)

// Before
{
  "status": true,
  "length": 1,
  "data": {
      "id": "16",
      "type": "Moodle::Competency",
      "attributes": {
          "shortname": "Comp 3",
@philiplambok
philiplambok / events.md
Last active March 26, 2019 09:56
Events API

All Events.

# /api/v1/events 
{
  "status": true,
  "length": 5,
  "data": [
    {
      "id": "1543",
      "type": "Moodle::Event",

Otentikasi di moodle.

  • Jalankan request ke enpoint POST /api/v1/authdengan parameter body:
    {
     "auth": {
       "email": "email_input_of@employee.com",
       "password": "password_input"
     }
    }
@philiplambok
philiplambok / array-sessions.md
Last active November 25, 2018 03:16
Cara menyimpan nilai array dalam sebuah sessions.

Cara menyimpan nilai array dalam sebuah sessions.

Tulisan ini mencoba untuk membahas cara pembuatan fitur keranjang belanja pada sebuah aplikasi E-commerce.

Keranjang belanja dikenal sifatnya yang dinamis dan mungkin tidak cocok untuk disimpan di database. Walapun jika anda memiliki orang data science, mungkin saja lebih baik anda menyimpannya di database.

Namun tulisan ini hanya akan memperlihatkan pengimplementasian pada sessions saja.

Session sebenarnya adalah cookies yang dienkripsi. Cookies dikenal dengan sturktur data key-dan-values : key = value. Jika anda ingin menyimpan nilai array anda mungkin akan menemukan masalah.

Ayano with TDD

Overview

Ayano is sharing links api-only project. Ayano was build on testing driven development. Ayano project's just for learning purpose.

Enpoints

The Enpoints will be written based on features.

Authentication

Request