Skip to content

Instantly share code, notes, and snippets.

View kresnasatya's full-sized avatar
🤫
Shh!

Kresna Satya kresnasatya

🤫
Shh!
View GitHub Profile
@kresnasatya
kresnasatya / defer.html
Created March 15, 2018 23:36
Menunda (defer) script
<script src="./js/sw-controller.js" defer></script>
<script src="./js/main.js" defer></script>
<script src="./js/lazysizes.min.js" defer></script>
@kresnasatya
kresnasatya / fetch-remote-image.js
Created March 16, 2018 02:46
Menarik gambar dari api dan mengkonversinya menggunakan cloudinary
// Pastikan anda telah mendaftarkan di cloudinary
// Dokumentasi tentang fetch remote images: https://cloudinary.com/documentation/fetch_remote_images
function cloudinaryJpg(thumbnail) {
return `https://res.cloudinary.com/{youraccountname}/image/fetch/c_scale,fl_force_strip.progressive,w_478/f_jpg/${thumbnail}`
}
@kresnasatya
kresnasatya / web-perf.html
Created March 16, 2018 07:44
Preconnect, dns prefetch, preload
<!-- Preconnect -->
<link rel="preconnect" href="https://api.rss2json.com" crossorigin>
<!-- DNS Prefetch -->
<link rel="dns-prefetch" href="https://cdn-images-1.medium.com">
<!-- Preload -->
<link rel="preload" href="./dist/css/mini-default.min.css" as="style" media="(min-width: 20em)">
@kresnasatya
kresnasatya / combine_arrays_without_key.php
Last active May 3, 2018 03:37
Combine arrays without key
<?php
function combine_arrays($arrays) {
$results = array();
foreach ($arrays as $subKey => $arr) {
foreach ($arr as $index => $key) {
$results[$index][$subKey] = $arr[$index];
}
}
@kresnasatya
kresnasatya / combine_arrays_with_key.php
Created May 3, 2018 03:36
Combine key with arrays
<?php
function combine_keys_with_arrays($keys, $arrays) {
$results = array();
foreach ($arrays as $subKey => $arr)
{
foreach ($keys as $index => $key)
{
$results[$key][$subKey] = $arr[$index];
@servers(['web' => '[email protected]'])
@setup
$repository = '[email protected]:satyakresna/test-laravel.git';
$releases_dir = '/var/www/test-laravel/releases';
$app_dir = '/var/www/test-laravel';
$release = 'release_' . date('YmdHis');
$new_release_dir = $releases_dir .'/'. $release;
@endsetup
@kresnasatya
kresnasatya / laravel-nginx.conf
Last active February 21, 2021 05:01
Laravel nginx conf
server {
listen 80;
server_name phpbali.com www.phpbali.com;
root /var/www/site.com/current/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
@kresnasatya
kresnasatya / Dockerfile
Created May 10, 2018 04:11
Docker file for laravel
# Set the base image for subsequent instructions
FROM php:latest
# Update packages
RUN apt-get update
# Install PHP and composer dependencies
RUN apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev
# Clear out the local repository of retrieved package files
@kresnasatya
kresnasatya / multiplefile.php
Created July 10, 2018 06:24
Script upload multiple file in CodeIgniter
<?php
if ($_FILES AND $_FILES['surat_file']['name']) {
$count_file = count($_FILES['surat_files']['name']);
for ($i = 0; $i < $count_file; $i++) {
$_FILES['surat_file']['name'] = $_FILES['surat_files']['name'][$i];
$_FILES['surat_file']['type'] = $_FILES['surat_files']['type'][$i];
$_FILES['surat_file']['tmp_name'] = $_FILES['surat_files']['tmp_name'][$i];
$_FILES['surat_file']['error'] = $_FILES['surat_files']['error'][$i];
$_FILES['surat_file']['size'] = $_FILES['surat_files']['size'][$i];
@kresnasatya
kresnasatya / deploy.php
Last active October 26, 2018 05:25
Setup CI/CD Laravel Deployer in Gitlab
<?php
return [
/*
|--------------------------------------------------------------------------
| Default deployment strategy
|--------------------------------------------------------------------------
|
| This option defines which deployment strategy to use by default on all