Skip to content

Instantly share code, notes, and snippets.

View lgh06's full-sized avatar

Daniel Liu lgh06

View GitHub Profile
const useFetch = (service) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState();
const [data, setData] = useState();
const fetchAPI = useCallback(async () => {
try {
const res = await fetch(service);
const json = await res.json();
setData(json);
#!/usr/bin/env pwsh
# https://stackoverflow.com/questions/8761888/capturing-standard-out-and-error-with-start-process
function Start-Command ([String]$Path, [String]$Arguments) {
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $Path
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $Arguments
@JosePedroDias
JosePedroDias / JSON_number_limits.md
Created July 20, 2019 11:58
JSON number limits

JSON number limits

So we we're using an API which returns a JSON response. One of its attributes is a numeric key. Due to historical reasons we're now being served longer number (longs) so the server, which is not based on JavaScript, started returning long integers.

I had heard about issues like this but hadn't cross against a real use case before.

So what started happening on our JavaScript clients (browser and React Native alike) is that the primitive value we get back once we get the fetch json promise resolved is an overflown number.

JavaScript engines commonly have the symbol Number.MAX_SAFE_INTEGER so one can retrieve the number above which problems start to appear (it is 9007199254740991).

@karanlyons
karanlyons / ZoomDaemon.yara
Last active July 12, 2021 14:07
Fixes for Zoom, RingCentral, Zhumu (and additional white labels) RCE vulnerabilities
private rule Macho
{
meta:
description = "private rule to match Mach-O binaries (copied from Apple's XProtect)"
condition:
uint32(0) == 0xfeedface or uint32(0) == 0xcefaedfe or uint32(0) == 0xfeedfacf or uint32(0) == 0xcffaedfe or uint32(0) == 0xcafebabe or uint32(0) == 0xbebafeca
}
rule ZoomDaemon
{
// This injects a box into the page that moves with the mouse;
// Useful for debugging
async function installMouseHelper(page) {
await page.evaluateOnNewDocument(() => {
// Install mouse helper only for top-level frame.
if (window !== window.parent)
return;
window.addEventListener('DOMContentLoaded', () => {
const box = document.createElement('puppeteer-mouse-pointer');
const styleElement = document.createElement('style');
@PARC6502
PARC6502 / OpenSourceBaas.md
Last active July 19, 2024 04:52
List of open source, self hosted BaaS - Backend as a service

Backend as a Service

Supabase - ~52K stars

  • Designed explicitly as an open source firebase alternative
  • Typescript based
  • Docker support

Appwrite - ~32K stars

  • Written in JavaScript and PHP
  • Docker based
  • Realtime support across all services
@ansulev
ansulev / install-3proxy-debian-ubuntu.sh
Last active December 7, 2023 08:49
Install 3proxy on Debian 9 or Ubuntu 16.4
#
# Install and configure 3proxy for Ubuntu 16.04 or Debian 9
#
# Update the system and install build tools + fail2ban
apt update -y && apt upgrade -y && apt dist-upgrade -y
apt autoremove -y && apt autoclean -y && apt clean -y
apt -y install fail2ban software-properties-common
apt install -y build-essential libevent-dev libssl-dev

Upload images to GitHub

  1. Create a new issue on GitHub.

  2. Drag an image into the comment field.

  3. Wait for the upload process to finish.

  4. Copy the URL and use it in your Markdown files on GitHub.

@mrbar42
mrbar42 / README.md
Last active July 6, 2024 23:08
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X)

running:

bash create-vod-hls.sh beach.mkv

will produce:

    beach/
      |- playlist.m3u8
 |- 360p.m3u8
@schmidt1024
schmidt1024 / sanitizehtml.pipe.ts
Last active December 13, 2019 01:42
angular 4 pipe for bypass security trust html
// <div [innerHTML]="your.value | sanitizeHtml" ></div>
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Pipe({name: 'sanitizeHtml'})
export class SanitizeHtmlPipe implements PipeTransform {
constructor(private _sanitizer:DomSanitizer) {
}
transform(v:string):SafeHtml {