Skip to content

Instantly share code, notes, and snippets.

View wzul's full-sized avatar
😋
Yummy

Wan Zulkarnain wzul

😋
Yummy
View GitHub Profile
@wzul
wzul / wp-config.php
Created January 23, 2018 06:27
Set WordPress site URL in the config file instead of the database
<?php
// WordPress stores the site URL in the database by default (which I have never
// understood), and it's a pain to have to type out the UPDATE SQL or search in
// phpMyAdmin to change it. This is a simple way to put the URL into
// wp-config.php instead.
// Note that you will still need to update any URLs that appear in the content,
// especially when you copy a database from a development site to production:
// https://gist.github.com/davejamesmiller/a8733a3fbb17e0ff0fb5
@wzul
wzul / update-post-urls.sql
Created January 23, 2018 06:28
SQL to replace URLs in the WordPress database when moving between servers
-- Run this to replace URLs in the database when moving a WordPress blog from one URL to another.
--
-- Replace "wp_" with the table prefix if you have changed it.
--
-- You may need to update other tables/columns as well - I normally use phpMyAdmin's database search tool to search for the old URL.
--
-- Note: Don't replace the guid field if you're changing the URL of a live site, only if you're making a development site live.)
--
-- Alternatively, use WP-CLI (http://wp-cli.org/) or WP Migrate DB (https://en-gb.wordpress.org/plugins/wp-migrate-db/)
@wzul
wzul / billplz-mobile.php
Created August 23, 2018 08:09
PHP Example: Parse and generate valid mobile number for Billplz Create a BIll API
<?php
// https://github.com/giggsey/libphonenumber-for-php
// composer require giggsey/libphonenumber-for-php
require 'vendor/autoload.php';
use libphonenumber\PhoneNumberUtil;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberFormat;
$phoneNumber = "0107989480";
$phoneNumberUtil = PhoneNumberUtil::getInstance();
@wzul
wzul / round.js
Created November 8, 2018 07:59 — forked from nawawi/round.js
function round(value, precision, mode) {
var m, f, isHalf, sgn;
precision |= 0;
m = Math.pow(10, precision);
value *= m;
sgn = (value > 0) | -(value < 0);
isHalf = value % 1 === 0.5 * sgn;
f = Math.floor(value);
if ( isHalf ) {
@wzul
wzul / JavaApplication1.java
Created November 28, 2018 13:38
Determine minimum expenses
package javaapplication1;
/**
*
* @author wanzu
*/
public class JavaApplication1 extends Thread {
static int minimum_expenses = 0;
@wzul
wzul / mobile_hotspot.py
Created December 27, 2018 09:43 — forked from bizkut/mobile_hotspot.py
Use your mobile phone's data on your pc without tethering. Doesn't need jailbreak or root.
#!/usr/bin/env python
import socket
import select
import threading
HOST = ''
PORT = 50007
# use https or socks5 and use the same protocol on pc
PROXYHOST = 'your proxy server'
PROXYPORT = 8080
@wzul
wzul / aws-write-to-s3-acl.rb
Created June 10, 2019 03:04 — forked from dannguyen/aws-write-to-s3-acl.rb
Using Ruby AWS-SDK to write an object to S3 and set its ACL
#!/usr/bin/ruby
require 'rubygems'
require 'aws-sdk'
#creates an interface object to AWS S3
AWS.config( :access_key_id => '' , :secret_access_key => '' )
#creates an interface to the S3
s3interface = AWS::S3.new
@wzul
wzul / MSFEX.php
Created August 16, 2019 17:58
[PHP] BNM API Get Latest Exchange Rate
<?php
$host = 'https://api.bnm.gov.my/public/exchange-rate';
$header = 'Accept: application/vnd.BNM.API.v1+json';
$from_currency = 'USD';
$data = array(
'session' => "0900",
);

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@wzul
wzul / cert_convert.sh
Created June 24, 2020 08:32 — forked from jmervine/cert_convert.sh
openssl: convert cert from p7b to crt (or cer)
openssl pkcs7 -print_certs -in old.p7b -out new.crt
# openssl pkcs7 -print_certs -in old.p7b -out new.cer