Skip to content

Instantly share code, notes, and snippets.

View muhfaris's full-sized avatar
:octocat:
Focusing

Muhammad Faris 'Afif muhfaris

:octocat:
Focusing
View GitHub Profile
@muhfaris
muhfaris / golang-tls.md
Created July 13, 2019 07:28 — forked from 6174/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@muhfaris
muhfaris / responsive-semantic-ui.css
Created July 21, 2018 01:30 — forked from bl4ck5un/responsive-semantic-ui.css
Responsive helpers (mobile-only etc.) for semantic-ui
/* Semantic UI has these classes, however they're only applicable to*/
/* grids, containers, rows and columns.*/
/* plus, there isn't any `mobile hidden`, `X hidden` class.*/
/* this snippet is using the same class names and same approach*/
/* plus a bit more but to all elements.*/
/* see https://github.com/Semantic-Org/Semantic-UI/issues/1114*/
/* Mobile */
@media only screen and (max-width: 767px) {
[class*="mobile hidden"],
package main
import (
"fmt"
"net/http"
)
func main() {
fmt.Printf("Please input which directory\nwhat you want to share, start with \"/\":\n")
h := http.FileServer(http.Dir("/usr/share/nginx/html/app"))
@muhfaris
muhfaris / github.txt
Created April 15, 2018 23:35
remove history commit
# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH
# Add all the files:
git add -A
# Commit the changes:
git commit -am "Initial commit"
# Delete the old branch:
@muhfaris
muhfaris / convertMS.js
Created April 9, 2018 03:52
convert milliseconds to time
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
@muhfaris
muhfaris / curl.md
Created January 31, 2018 09:10 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@muhfaris
muhfaris / default
Created January 11, 2018 09:50
reserve proxy : from ip address to domain name
server {
listen 80;
server_name xxx.xxx.xxx.xxx;
# or
# server_name default_server
return 301 $scheme://domain.com$request_uri;
}
<?php
if(!function_exists("add_var_to_url")){
function add_var_to_url($variable_name,$variable_value,$url_string){
// first we will remove the var (if it exists)
// test if url has variables (contains "?")
if(strpos($url_string,"?")!==false){
$start_pos = strpos($url_string,"?");
$url_vars_strings = substr($url_string,$start_pos+1);
$names_and_values = explode("&",$url_vars_strings);
$url_string = substr($url_string,0,$start_pos);
@muhfaris
muhfaris / url_remove_parameter.php
Created December 22, 2017 03:16
query remove parameter in url
<?php
// can remove variables from: full url, from urls related to site root, form just a query string like "a=1&b=2"
if(!function_exists("remove_var_from_url")){
function remove_var_from_url($variable_name, $url_string){
// this is anything before the "?" sign
$base_url = '';
// the variable separator, can be "?" if is a full URL or can be empty, if we just have "&sort=sales&oprder=asc"
$separator = "";
$start_pos = 0;
@muhfaris
muhfaris / url.php
Created December 20, 2017 03:39
get link, order table
<?php
if(isset($_GET['sort'])) {
$query = $_GET;
if($_GET['sort']=='ASC') {
$query['sort'] = 'DESC';
} else {
$query['sort'] = 'ASC';
}
$query_result = http_build_query($query);