Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Peteng Dedet (Ikhwan Maftuh) PetengDedet

🏠
Working from home
View GitHub Profile
@PetengDedet
PetengDedet / log.md
Created Nov 19, 2021
log.Fatal vs log.Panic
View log.md
log.Fatal() log.Panic()
When to Use When something unexpected happened When something really unexpected happened
Use Case - Not enough arguments - can not access file - etc. - Not having enough disk space - Not being find file that previously accessed - etc.
Terminate Behavior Stops the program at the point where log.Fatal() called Immediately stops the Go program
Similar function Similar to call log.Print() followed by os.Exit(1) Similar to call log.Print() followed by panic()
@PetengDedet
PetengDedet / wordpress sed
Created Feb 19, 2021
Change wordpress config via sed in docker
View wordpress sed
RUN cp wp-config-sample.php wp-config.php
# Replace configuration file with desired env
RUN sed -i 's/database_name_here/'"${DB_NAME}"'/g' wp-config.php;
RUN sed -i 's/username_here/'"${DB_USER}"'/g' wp-config.php;
RUN sed -i 's/password_here/'"${DB_PASSWORD}"'/g' wp-config.php;
RUN sed -i 's/localhost/db/g' wp-config.php;
RUN sed -i 's/'"'AUTH_KEY',".*"'put your unique phrase here'"'/'"'AUTH_KEY', '""$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)""'"'/g' wp-config.php;
RUN sed -i 's/'"'SECURE_AUTH_KEY',".*"'put your unique phrase here'"'/'"'SECURE_AUTH_KEY', '""$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)""'"'/g' wp-config.php;
RUN sed -i 's/'"'LOGGED_IN_KEY',".*"'put your unique phrase here'"'/'"'LOGGED_IN_KEY', '""$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)""'"'/g' wp-config.php;
@PetengDedet
PetengDedet / ping_say.sh
Last active Sep 19, 2020
Script to tell you that ping is reply or not on macos
View ping_say.sh
#!/bin/bash
CONNECT_STATE=0
PREVIOUS_STATE=0
while true; do
if ping -c 1 google.com | grep "64 bytes from"; then
CONNECT_STATE=1
else
CONNECT_STATE=0
View [ASK] ELK Security.md
+--------------------------------------------------------------------------+
|                                                                          |
|                           Phisical Server                                |
|                           Host: 192.168.100.1                            |
|                                                                          |
|                                                                          |
|                                                                          |
|                                                                          |
|                                                                          |
View api
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
View gist:738f8b0b970eb974c7c7c41ce84cc355
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
View checkquestion
public function quizCheckAnswer($quiz_id, Request $request) {
$userdata = Cektoken::cek($request->token);
$data = [];
//Cek Quiz
$quiz = \App\Models\Quiz::find($quiz_id);
//Quiz tidak ditemukan
if (! $quiz) {
return response()->json(['status' => false, 'data' => $data, 'message' => 'Ups, Quiz tidak valid',404]);
}
View snip
public function surveyPlayStore($id, Request $request)
{
$userdata = Cektoken::cek($request->token);
$data = [];
$survey = \App\Models\Survey::find($id);
if (!$survey OR $survey->is_active == 'n') {
return response()->json(['status' => false, 'data' => $data, 'message' => 'Survey tidak valid'], 404);
}
View gist:51b75aa844b3e28149e5d21c289804e3
This file has been truncated, but you can view the full file.
.
├── 1.env
├── LICENSE.md
├── README.md
├── _ide_helper.php
├── anu.md
├── app
│   ├── ApiToken.php
│   ├── Console
View Multilevel Menu Codeigniter
//----MY Table--
MariaDB [sik]> select * from sik_institution;
+----+-------------------------------+-----------+--------+
| id | name | alias | parent |
+----+-------------------------------+-----------+--------+
| 1 | Kantor Bendahara Pesantren | bendahara | NULL |
| 2 | Bidang Pendidikan Tinggi | dikti | 1 |
| 3 | Institut Agama Islam Ibrahimy | iaii | 2 |
| 4 | Fakultas Syari'ah | fs | 3 |
+----+-------------------------------+-----------+--------+