Skip to content

Instantly share code, notes, and snippets.

View rangerz's full-sized avatar
🏠
Working from home

Ranger Chan rangerz

🏠
Working from home
View GitHub Profile
@rangerz
rangerz / dom3d.js
Created April 1, 2024 17:51 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any */
import { ChatReconnectIconBase64, CloseChatButtonIconBase64, ModernChatIconBase64, ProactiveChatBannerBase64 } from "@microsoft/omnichannel-chat-components";
import { ILiveChatWidgetProps } from "../../interfaces/ILiveChatWidgetProps";
import { ITelemetryConfig } from "../../../../common/telemetry/interfaces/ITelemetryConfig";
import MockAdapter from "../../../webchatcontainerstateful/common/mockadapter";
import { NewMessageNotificationSoundBase64 } from "../../../../assets/Audios";
import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
import { WebChatStoreLoader } from "../../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
@rangerz
rangerz / exssh
Created March 10, 2020 00:16
SSH with Password Parameter
#!/usr/bin/expect
# Install for MacOSX
# brew install expect
# touch /usr/local/bin/exssh
# chmod +x /usr/local/bin/exssh
set timeout 30
set userhost [lindex $argv 0]
set password [lindex $argv 1]
@rangerz
rangerz / install_ioncube.sh
Last active November 17, 2022 07:51
Install PHP ionCube Loader Script
#!/bin/bash
! hash php 2>/dev/null && echo "PHP Required" && exit
# Download Official Loader Wizard for
curl -O https://www.ioncube.com/loader-wizard/loader-wizard.tgz
tar zxvf loader-wizard.tgz
cat ./ioncube/loader-wizard.php | sed 's/run();/#run();/g' | sed "s/'mac'/'dar'/g" > ./loader-wizard.php
# PHP Setting
@rangerz
rangerz / Dockerfile
Last active February 24, 2020 18:52
Fixed ionCube issue for docker-magento
FROM markoshust/magento-php:7.2-fpm
USER root
# Remove Wrong PHP extension ini
RUN rm -f /usr/local/etc/php/conf.d/00_docker-php-ext-ioncube_loader_lin_7.2.ini
RUN cd /tmp \
&& curl -O https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \
&& tar zxvf ioncube_loaders_lin_x86-64.tar.gz \
@rangerz
rangerz / sizeof.cpp
Last active March 14, 2016 02:54
[C++] build-in type size and range
#include<iostream>
#include<iomanip>
#include<string>
#include<limits>
using namespace std;
#define SIZEOF(x) cout << \
setw(24) << #x << \
setw(9) << sizeof(x) << \
setw(21) << (numeric_limits<x>::max)() << \
@rangerz
rangerz / stringprintf.cpp
Last active May 3, 2016 04:51
[C++] StringPrintf
#include "stringprintf.h"
static void StringAppendV(string* dst, const char* format, va_list ap) {
// First try with a small fixed size buffer
char space[1024];
// It's possible for methods that use a va_list to invalidate
// the data in it upon use. The fix is to make a copy
// of the structure before using it and use that copy instead.
va_list backup_ap;
@rangerz
rangerz / foreach.h
Last active November 15, 2017 09:53
[C++] foreach for pure macro, Qt, and boost
/***** macro foreach *****/
#define EASY_FOREACH(it, container) \
for(typeof((container).begin()) it = (container).begin();it != (container).end(); ++it)
/***** qt foreach *****/
template <typename T>
class ForeachContainer {
public:
inline ForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
@rangerz
rangerz / ssh-copy-id.sh
Created August 28, 2014 17:43
Shell implementation of ssh-copy-id (OSX)
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then
@rangerz
rangerz / ssh-copy-id.sh
Created August 28, 2014 17:41
Shell implementation of ssh-copy-id (MinGW)
#!/bin/sh
usage () {
echo "Usage: $0 [-i [identity_file]] [user@]machine"
exit 1
}
# Parse options
while getopts ":i:" o
do case "$o" in