Skip to content

Instantly share code, notes, and snippets.

View novalagung's full-sized avatar
🏠

Noval Agung Prayogo novalagung

🏠
View GitHub Profile
@novalagung
novalagung / go-mod-private-repo-terminal-prompt.sh
Created January 21, 2020 11:05
go modules install allow private repo by enabling terminal prompt
GIT_TERMINAL_PROMPT=1 go mod tidy
@novalagung
novalagung / uitextview-dynamic-height-with-autolayout-enabled.md
Last active December 16, 2021 02:21
make UITextView height dynamically follow it's content even with Auto Layout enabled

The key to make text view height follow it's content is by NOT SET HEIGHT CONSTRAINT and DISABLE THE SCROLL.

theTextView.isScrollEnabled = false
theTextView.text = "some text"
theTextView.sizeToFit()

But, if you already set the height constraint, then make it inactive

@novalagung
novalagung / iptables-allow-ssh-http-https-from-certain-ip-but-block-all-others.sh
Last active July 10, 2019 01:51
iptables example to allow ssh, and block every incoming http and https requests except certain ips
# allow incoming ssh access from anywhere
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# allow incoming http & https requests from local
sudo iptables -A INPUT -p tcp --dport 80 -s 127.0.0.1 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -s 127.0.0.1 -j ACCEPT
# allow incoming http & https requests from specific ips
sudo iptables -A INPUT -p tcp --dport 80 -s 13.250.120.208 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -s 13.250.120.208 -j ACCEPT
@novalagung
novalagung / mongodb_ssl_with_letsencrypt.md
Created June 11, 2019 08:26 — forked from leommoore/mongodb_ssl_with_letsencrypt.md
MongoDB 3.2.x SSL with Letsencrypt

#MongoDB 3.2.x SSL with Letsencrypt Letsencrypt is an initative which aims to increase the use of encryption for websites. It basically allows people to apply for free certificates provided that they prove the they control the requested domain. We will look at the what is needed to secure your MongoDB installation. For more details on setting up a MongoDB server see MongoDB 3.2.x.

##Set the hostname We sould to set the hostname to match the name of the certificate we are going to optain.

sudo hostname mongo0.example.com

Then update the hostname file to set the server name permanently.

@novalagung
novalagung / gist:a0fddc1d0161599572ee9871146d2992
Created May 14, 2019 02:31 — forked from sanatgersappa/gist:4030649
Querying Sharepoint on Office365 with Go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"log"
"regexp"
"strings"
)
var vm = {}
vm.dataUser = []
vm.isDataUserReady = false
vm.doGetData = function() {
$.ajax({
url: "https://reqres.in/api/users?page=2"
}).then(function(res) {
setTimeout(() => {
vm.dataUser = res.data
package main
import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/PuerkitoBio/goquery"
)
@novalagung
novalagung / using-callback.js
Last active November 15, 2018 09:47
a simple comparison on handling asynchronous processes sequentially, using callback vs promise, in javascript
function doA(callback) {
$.ajax({
// ...
success: function (res) {
if (callback) callback(res, true)
},
error: function (res) {
if (callback) callback(res, false)
}
})
@novalagung
novalagung / go-soap-wsdl-using-http.go
Last active April 20, 2023 19:16
Example implementation of making SOAP call on WSDL web service using go with only net/http package. The full tutorial avaiable on https://medium.com/eaciit-engineering/soap-wsdl-request-in-go-language-3861cfb5949e
package main
import (
"bytes"
"crypto/tls"
"encoding/base64"
"encoding/xml"
"fmt"
"log"
"net/http"
// Get session
info := new(mgo.DialInfo)
info.Username = "username"
info.Password = "password"
info.Source = "admin"
info.Addrs = []string{"host"}
info.Database = "dbname"
session, err := mgo.DialWithInfo(info)