Skip to content

Instantly share code, notes, and snippets.

View gregpalaci's full-sized avatar

Greg Palaci gregpalaci

  • Cactus & Dove Ltd.
  • London, UK
View GitHub Profile
@gregpalaci
gregpalaci / GL-AR750S-EXT Slate upgrade guide.md
Last active May 30, 2024 02:30
GL-AR750S-EXT Slate upgrade guide

GL-AR750S-EXT Slate upgrade guide

Uboot guide here

  • v3.104(Uboot img) here
  • v.3.105 (sysupgrade tar through web gui local upgrade) here
  • v.3.212 (web gui system auto check upgrade) http://192.168.8.1
  • latest 3.215 beta 2 (local upgrade) source
Analysis of sampling nwjs Helper (Renderer) (pid 61391) every 1 millisecond
Process: nwjs Helper (Renderer) [61391]
Path: /Applications/Popcorn-Time 15.app/Contents/Frameworks/nwjs Framework.framework/Versions/119.0.6045.105/Helpers/nwjs Helper (Renderer).app/Contents/MacOS/nwjs Helper (Renderer)
Load Address: 0x104b80000
Identifier: nwjs Helper (Renderer)
Version: ???
Code Type: ARM64
Platform: macOS
Parent Process: ??? [1]
@gregpalaci
gregpalaci / doAwait.js
Created January 15, 2024 19:23
await without catch
const doAwait = async (promise) => {
try {
const data = await promise;
return [undefined, data];
} catch (error) {
return [error, undefined];
}
};
const [error, result] = await doAwait(myPromise);
@gregpalaci
gregpalaci / tryCatch.ts
Last active November 11, 2023 14:16
tryCatch.ts
type TryCatchProps<T> = {
tryFn: () => T;
catchFn: (error: unknown) => T;
}
function tryCatch<T>({ tryFn, catchFn }: TryCatchProps<T>): T {
try {
return tryFn();
} catch (error) {
return catchFn(error);
@gregpalaci
gregpalaci / jsonSchema.ts
Created November 3, 2023 00:38
jsonSchema.ts
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
type Literal = z.infer<typeof literalSchema>;
type Json = Literal | { [key: string]: Json } | Json[];
const jsonSchema: z.ZodType<Json> = z.lazy(() =>
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
);
jsonSchema.parse(data);
@gregpalaci
gregpalaci / safeJsonParse.ts
Created November 2, 2023 20:10
safeJsonParse
const safeJsonParse = <T>(str: string) => {
try {
const jsonValue: T = JSON.parse(str);
return jsonValue;
} catch {
return undefined;
}
};
@gregpalaci
gregpalaci / isPromise.js
Created October 16, 2023 17:37
isPromise.js
/**
* Determine whether the given `promise` is a Promise.
*
* @param {*} promise
*
* @returns {Boolean}
*/
function isPromise(promise) {
return !!promise && typeof promise.then === 'function'
}
@gregpalaci
gregpalaci / isNumericString.js
Created October 4, 2023 17:43
Ensure a String is Numeric in JavaScript
/**
* Determine whether the given `input` is a number.
*
* @param {String} input
*
* @returns {Boolean}
*/
const isNumericString = (input) => typeof input === 'string' && !Number.isNaN(input)
@gregpalaci
gregpalaci / ucFirst.js
Created October 4, 2023 17:42
Capitalize the First Letter of a String in JavaScript
/**
* Uppercases the first character in the `string`.
*
* @param {String} string
*
* @returns {String}
*/
function ucFirst (string) {
if (!(typeof string !== 'string')) {
return ''
@gregpalaci
gregpalaci / isObject.js
Created October 4, 2023 17:40
isObject
const isObject = (value) => Object.prototype.toString.call(value) === '[object Object]'