Skip to content

Instantly share code, notes, and snippets.

View aasumitro's full-sized avatar
🌏

A. A. Sumitro aasumitro

🌏
View GitHub Profile
@aasumitro
aasumitro / App.kt
Created January 25, 2018 01:50
App With Dagger2
companion object {
lateinit var mAppComponent: AppComponent
}
override fun onCreate() {
super.onCreate()
mAppComponent = DaggerAppComponent
.builder()
.appModule(AppModule(this))
.build()
@aasumitro
aasumitro / PrefsUtil.kt
Created January 25, 2018 01:51
Kotlin Preferences Test
class PrefsUtil @Inject constructor(private val sharedPreferences: SharedPreferences) {
fun putBoolean(key: String, value: Boolean): Boolean {
val editor: SharedPreferences.Editor = sharedPreferences.edit()
editor.putBoolean(key, value)
return editor.commit()
}
fun getBoolean(key: String, defaultValue: Boolean): Boolean =
sharedPreferences.getBoolean(key, defaultValue)
@aasumitro
aasumitro / .htaccess
Created February 5, 2018 06:49
htaccess slim
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
@aasumitro
aasumitro / index.php
Last active February 5, 2018 07:17
slim index.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
//dengan adanya bagian ini qt dapat menggunakan library2 yang tersedia pada folder vendor
require __DIR__ . ('../vendor/autoload.php');
//pada bagian ini kita membuat pengaturan dimana ketika
//ada kesalahan akan ditampilkan secara menyeluruh pada browser
@aasumitro
aasumitro / index.php
Created February 5, 2018 08:56
new index.php slim 3
<?php
/*
|-----------------------------------------------------
| Register file app.php
|-----------------------------------------------------
*/
require_once __DIR__ . '/bootstrap/app.php';
@aasumitro
aasumitro / app.php
Created February 5, 2018 08:58
bootsrap app.php slim 3
<?php
/*
|----------------------------------------------------
| Register The Auto Loader
|----------------------------------------------------
*/
require __DIR__ . ('/../vendor/autoload.php');
@aasumitro
aasumitro / settings.php
Created February 5, 2018 08:59
config settings.php slim 3
<?php
return [
'settings' => [
'displayErrorDetails' => true,
],
@aasumitro
aasumitro / dependencies.php
Created February 5, 2018 08:59
config dependencies.php slim 3
<?php
/*
|----------------------------------------------------
| Container |
|----------------------------------------------------
*/
$container = $app->getContainer();
@aasumitro
aasumitro / Controller.php
Created February 5, 2018 09:00
app controllers Controller.php slim 3
<?php
namespace App\Controllers;
class Controller {
protected $container;
public function __construct($container) {
$this->container = $container;
@aasumitro
aasumitro / TestController.php
Created February 5, 2018 09:00
app controllers TestController.php slim 3
<?php
namespace App\Controllers;
class TestController extends Controller {
public function index($request, $response) {
$response->getBody()->write("Hello Slim With Controller");
return $response;