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 / itr.js
Created January 6, 2023 03:40 — forked from constantm/itr.js
NodeJS implementation in Pipedream of "Intent to Receive" for Xero webhooks
async (event, steps) => {
// NodeJS implementation in Pipedream of "Intent to Receive" for Xero webhooks
const { createHmac } = await import('crypto');
const xero_webhook_key = 'OSd0eLlVIY9ZhViEqlDUh4+6n6M+Lo+eDaEJheJ6OCCgWwIz2D3JIAU6jPMipHRbgKTLz2uJ+xiACXGDBLrgdA==' // Get this from the Xero app
const body_string = Buffer.from(steps.trigger.raw_event.body_b64, 'base64').toString() // Use RAW body data so that Pipedream doesn't break our data
const xero_hash = steps.trigger.event.headers["x-xero-signature"] // Could probably shorten, but keeping it long for consistency
let our_hash = createHmac('sha256', xero_webhook_key).update(body_string).digest("base64") // Generate the hash Xero wants
let statusCode = xero_hash == our_hash ? 200 : 401 // If the hashes match, send a 200, else send a 401
@wzul
wzul / wp-user-registration-query.php
Created September 2, 2021 04:30 — forked from stephenharris/ wp-user-registration-query.php
Get all users registered between two dates
<?php
/*
* Get all users registered after $start and before $end (dates in yyyy-mm-dd format)
*
* Based on my answer to this question: http://wordpress.stackexchange.com/questions/51485/how-can-i-query-all-users-who-registered-today/51492#51492
*
* @param (string) $start - start date in yyyy-mm-dd format
* @param (string) $end - end date in yyyy-mm-dd format
*/
@wzul
wzul / github_gpg_key.md
Created December 5, 2020 07:51 — forked from ankurk91/github_gpg_key.md
Github : Signing commits using GPG (Ubuntu/Mac)

Github : Signing commits using GPG (Ubuntu/Mac) 🔐

  • Do you have an Github account ? If not create one.
  • Install required tools
  • Latest Git Client
  • gpg tools
# Ubuntu
sudo apt-get install gpa seahorse
# MacOS with https://brew.sh/
@wzul
wzul / gist:f20aa6bd520dddf6761d92f264b7c255
Created August 27, 2020 07:46 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@wzul
wzul / 01.1.lifecycle.rb
Created July 1, 2020 10:07 — forked from Aupajo/01.1.lifecycle.rb
Sockets in Ruby
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
@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

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 / 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 / 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 / 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 ) {