Skip to content

Instantly share code, notes, and snippets.

View ghostvar's full-sized avatar
🎹
Sedang bermain dengan perangkat keras

Didin Fakhrudin ghostvar

🎹
Sedang bermain dengan perangkat keras
  • indonesia
View GitHub Profile
@jzazove
jzazove / gist:1479763
Created December 15, 2011 03:54
URL Friendly Javascript Regex
/* function to urlify a string */
var urlify = function(a){return a.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '')};
/* usage example */
var str_a = "* The Best Wallpaper Magazine in the . ? & world! : Rjer9238131 & ";
urlify(str_a)
/* returns */
"the-best-wallpaper-magazine-in-the-world-rjer9238131"
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@danharper
danharper / CatchAllOptionsRequestsProvider.php
Last active April 20, 2024 01:53
Lumen with CORS and OPTIONS requests
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
@ben-albon
ben-albon / php5.6-pgsql.Dockerfile
Last active April 21, 2024 17:10
Docker PHP Image with PostgreSQL Driver
FROM php:5.6-apache
RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql
COPY src/ /var/www/html
@vielhuber
vielhuber / script.sh
Last active July 13, 2024 02:21
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@MichelDiz
MichelDiz / Enable-DockerRemoteAPI.md
Created September 15, 2019 19:01 — forked from CollinChaffin/Enable-DockerRemoteAPI.md
Enable Docker Remote API on Photon OS v3(+)

Enable Local/Remote Docker API on PhotonOS

Prerequisites

You must have already performed the following in one form or another as well as properly set a STATIC IP. Bear in mind many instructions do not properly show how to commit iptables changes on Photon which then survive reboots.

iptables -A INPUT -p tcp --dport 2375 -j ACCEPT
iptables -A INPUT -p tcp --dport 2376 -j ACCEPT
iptables-save > /etc/systemd/scripts/ip4save
@jacky9813
jacky9813 / lxc-wsl2.md
Last active March 31, 2024 09:19
Running LXC VM in WSL2

Running LXC/LXD VM in WSL2 (Windows 11 Only)

If you just running LXC/LXD containers, the default settings for WSL2 (both Windows 10 and Windows 11) should be adequate.

However, if trying something like lxc launch images:alpine/3.18 --vm, LXC will complain that vhost_vsock module is not loaded.

Here's how I configure WSL2 so I can run VM with LXC/LXD.