Skip to content

Instantly share code, notes, and snippets.

<?php
$a = preg_replace("/[\/=+]/", "", base64_encode(openssl_random_pseudo_bytes(7)));
$b = uniqid($a);
echo $b;
@mgoku
mgoku / euclid.php
Created October 23, 2017 14:17
Simple Euclidean Distance Calculation using PHP
<?php
$handle = fopen ("php://stdin","r");
echo "\nAplikasi sederhana menghitung jarak antara titik A dan B pada bidang Euclid dimensi n menggunakan koordinat Cartisean\n";
echo "\nMasukkan dimensi: ";
$dimensi = fgets($handle);
echo "\nMasukkan koordinat titik A\n";
@mgoku
mgoku / Cek listen to port
Created August 9, 2016 03:45
List Semua proses yang Listen to port
netstat -anlp | grep -w LISTEN
@mgoku
mgoku / gist:29a48c1524c42e2028f1
Created December 3, 2015 00:44
Cari teks di file di Linux
https://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-on-linux#
Do the following:
grep -rnw '/path/to/somewhere/' -e "pattern"
-r or -R is recursive, -n is line number and -w stands match the whole word. -l (letter L) can be added to have just the file name.
Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:
#!/bin/sh
# Put this file in ~/.kde4/Autostart
export SSH_ASKPASS=/usr/lib/ssh/ksshaskpass
/usr/bin/ssh-add </dev/null
@mgoku
mgoku / .fonts.conf
Last active October 21, 2015 01:56
Font configuration
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
@mgoku
mgoku / .htaccess
Last active August 29, 2015 14:06
.htaccess for Angularjs app in html5 mode
# Apache .htaccess
# Thanks to Eric Duran http://ericduran.io/2013/05/31/angular-html5Mode-with-yeoman/
# angularjs pushstate (history) support:
# See http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url-routing/
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<html>
<head>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="strophe-102.js" type="text/javascript"></script>
<script src="facebook.js" type="text/javascript"></script>
<script>
var BOSH_SERVICE = 'http://island.csie.org:8273/xmpp-httpbind'
var connection = null;