Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View PetengDedet's full-sized avatar
🏠
Working from home

Peteng Dedet (Ikhwan Maftuh) PetengDedet

🏠
Working from home
View GitHub Profile
@PetengDedet
PetengDedet / wordpress sed
Created February 19, 2021 10:00
Change wordpress config via sed in docker
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 / log.md
Created November 19, 2021 08:24
log.Fatal vs log.Panic
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 / ping_say.sh
Last active September 19, 2020 00:40
Script to tell you that ping is reply or not on macos
#!/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
+--------------------------------------------------------------------------+
|                                                                          |
|                           Phisical Server                                |
|                           Host: 192.168.100.1                            |
|                                                                          |
|                                                                          |
|                                                                          |
|                                                                          |
|                                                                          |
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
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]);
}
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);
}
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
│   │   ├── Commands
//----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 |
+----+-------------------------------+-----------+--------+