Skip to content

Instantly share code, notes, and snippets.

View egin10's full-sized avatar
:octocat:
Working from home

Ginanjar S.B egin10

:octocat:
Working from home
View GitHub Profile
{
"posts": [
{
"userId": 1,
"id": 1,
"title": "Echo Foxtrot Golf Hotel Lima Delta Bravo November Alfa Tango Zulu Juliett Papa Romeo Kilo Mike Uniform Quebec",
"body": "morbi non lectus aliquam sit amet diam in magna bibendum imperdiet nullam orci pede venenatis",
"likes": 0,
"dislikes": 0
},
@egin10
egin10 / Component.js
Last active October 3, 2019 04:10
Create Redux for ReactJs
// Use connect to use Store and Dispatch
import { connect } from'react-redux'
// Use todoAction from todoAction.js
import { addTodo } from './todoAction'
/*
use this syntax to access the store => this.state.todos
component(this.state.todos)
@egin10
egin10 / ImageRepositories.php
Last active January 19, 2020 04:48
Storing Image Laravel API
<?php
namespace App\Repositories;
use Illuminate\Support\Str;
class Image {
public function actionImage($nameOldImage = null, $method = null)
{
if($method = "DELETE_IMAGE"){
@egin10
egin10 / .htaccess
Last active November 4, 2019 01:56
Mengilangkan index.php pada CodeIgniter
//put this in root directory of project
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
class Core{
//This method use for getting some string from long string.
private function getStringBetween(String $teks, String $sebelum, String $sesudah): String
{
$teks = ' '.$teks;
$ini = strpos($teks, $sebelum);
if($ini == 0) return '';
$ini += strlen($sebelum);
$panjang = strpos($teks, $sesudah, $ini) - $ini;
return substr($teks, $ini, $panjang);
@egin10
egin10 / function_days_ago.php
Created November 12, 2019 00:18
Check days ago in php
public static function days_ago($date){
$date1 = new DateTime($date);
$date2 = new DateTime();
$interval = $date1->diff($date2);
if($interval->i <= 0) return "Just Now";
else if($interval->h <= 0) return $interval->i . " min";
else if($interval->d <= 0) return $interval->h . " hour";
else if($interval->m <= 0) return $interval->d . " day";
else if($interval->y <= 0) return $interval->m . " month";
@egin10
egin10 / .htaccess
Last active January 25, 2020 09:55
Deployment Laravel 5.8 to Shared Hosting
# put this htaccess on root directory
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
@egin10
egin10 / uuid.js
Created November 30, 2019 02:48
UUID Sample Generator in JS
function uuid(){
var dt = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (dt + Math.random()*16)%16 | 0;
dt = Math.floor(dt/16);
return (c=='x' ? r :(r&0x3|0x8)).toString(16);
});
return uuid;
}
@egin10
egin10 / interfaces
Created January 7, 2020 08:37
automatically connect a raspberry pi to a wifi network
# /etc/network/interfaces
auto wlan0
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet dhcp
#iface wlan0 inet static
@egin10
egin10 / random_code.php
Created January 10, 2020 12:44
Random Example Transaction Code
$arr = [];
for($i = 0; $i < 10; $i++) {
$num_rand = num_rand();
if(!in_array($num_rand, $arr)) {
$arr[] = $num_rand;
}else{
$num_rand = num_rand();
$arr[] = $num_rand;
}