Skip to content

Instantly share code, notes, and snippets.

View adipatiarya's full-sized avatar
💭
Javascript Lover

Adipatiarya adipatiarya

💭
Javascript Lover
View GitHub Profile
@adipatiarya
adipatiarya / nextjs-deploy.md
Created February 18, 2023 04:32 — forked from jjsquady/nextjs-deploy.md
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

@adipatiarya
adipatiarya / 0-go-os-arch.md
Created January 24, 2022 07:43 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
func downloadFile(URL string) ([]byte, error) {
response, err := http.Get(URL)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, errors.New(response.Status)
}
var data bytes.Buffer
func downloadMultipleFiles(urls []string) ([][]byte, error) {
done := make(chan []byte, len(urls))
errch := make(chan error, len(urls))
for _, URL := range urls {
go func(URL string) {
b, err := downloadFile(URL)
if err != nil {
errch <- err
done <- nil
return
[{"id":1,"msisdn":"083892652014","pkgid":"3212784","created_at":"2019-06-18 12:35:32","updated_at":"2019-06-18 12:35:32"},{"id":2,"msisdn":"083106406495","pkgid":"3212446","created_at":"2019-06-18 15:47:46","updated_at":"2019-06-18 15:47:46"},{"id":3,"msisdn":"083106406495","pkgid":"3212442","created_at":"2019-06-18 15:52:26","updated_at":"2019-06-18 15:52:26"},{"id":4,"msisdn":"083143561616","pkgid":"3212446","created_at":"2019-06-18 16:25:09","updated_at":"2019-06-18 16:25:09"},{"id":5,"msisdn":"083143561616","pkgid":"3212446","created_at":"2019-06-18 16:25:19","updated_at":"2019-06-18 16:25:19"},{"id":6,"msisdn":"083143561616","pkgid":"212442","created_at":"2019-06-18 16:26:20","updated_at":"2019-06-18 16:26:20"},{"id":7,"msisdn":"083143561616","pkgid":"3212784","created_at":"2019-06-18 16:28:15","updated_at":"2019-06-18 16:28:15"},{"id":8,"msisdn":"083143561616","pkgid":"3212784","created_at":"2019-06-18 16:28:33","updated_at":"2019-06-18 16:28:33"},{"id":9,"msisdn":"083812805815","pkgid":"3212446","creat
const-string v8, "log-tag"
invoke-static {v1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
move-result-object v9
invoke-static {v8, v9}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
@adipatiarya
adipatiarya / Response.php
Created February 24, 2019 20:46 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@adipatiarya
adipatiarya / README.md
Last active October 18, 2018 09:21 — forked from robynitp/README.md
Movie JSON example

Publish some JSON data of your own by forking this gist. Delete my example data and add your own. It can be anything: a list of your favorite songs, statistics on global warming, the number of steps you took in a day. It should be in valid JSON. Use JSON Editor Online to check if your JSON is valid.

For an additional JSON example see this gist with weather data as well as the example files in the JSON folder for week 2.

@adipatiarya
adipatiarya / SimpleJSON.java
Created October 3, 2018 18:49 — forked from sheharyarn/SimpleJSON.java
Simple Java Class to convert Lists/Maps to JSON and vice versa
public class SimpleJSON {
public static Object toJSON(Object object) throws JSONException {
if (object instanceof HashMap) {
JSONObject json = new JSONObject();
HashMap map = (HashMap) object;
for (Object key : map.keySet()) {
json.put(key.toString(), toJSON(map.get(key)));
}
return json;
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class HerbsService {
private _url= 'assets/herbs.json';
constructor(private _http: Http) {}
getHerbs () {
return this._http.get(this._url)
.map((response: Response) => response.json());