Skip to content

Instantly share code, notes, and snippets.

View coolsoftwaretyler's full-sized avatar

Tyler Scott Williams coolsoftwaretyler

View GitHub Profile
@coolsoftwaretyler
coolsoftwaretyler / _deobfuscating-unminifying-obfuscated-web-app-code.md
Created April 5, 2024 16:57 — forked from 0xdevalias/_deobfuscating-unminifying-obfuscated-web-app-code.md
Some notes and tools for reverse engineering / deobfuscating / unminifying obfuscated web app code
@coolsoftwaretyler
coolsoftwaretyler / mst-type-tests.ts
Last active February 16, 2024 03:11
Weird TS Test Failure
// These assertions don't work, from https://github.com/mobxjs/mobx-state-tree/blob/master/__tests__/core/type-system.test.ts. Fails with TS 4.3 and greater. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-3.html
test("maybe / optional type inference verification", () => {
const T = types.model({
a: types.string,
b: "test",
c: types.maybe(types.string),
d: types.maybeNull(types.string),
e: types.optional(types.string, "test")
})
@coolsoftwaretyler
coolsoftwaretyler / Text.tsx
Last active December 29, 2023 21:15
React Native Text Wrapper
import React from 'react';
import {
StyleSheet,
Text as RNText,
TextProps as RNTextProps,
TextStyle,
} from 'react-native';
const styles = StyleSheet.create({
header: {
@coolsoftwaretyler
coolsoftwaretyler / ask
Last active October 22, 2023 01:32
I use this code to interface with my OpenAI account and "ask" from my command line. It will take input directly, or you can point it to a markdown file and get a response. Usage instructions in the code comments, or feel free to leave a comment on the gist if you need any help.
#!/usr/bin/env node
/**
* If you put this program in your PATH, you can use it like this:
*
* ask "What is the meaning of life?"
*
* or
*
* ask my_file.md
@coolsoftwaretyler
coolsoftwaretyler / bench-mobx.ts
Created September 26, 2023 17:22 — forked from thegedge/bench-mobx.ts
MobX benchmark
import { makeAutoObservable, makeObservable, observable } from "mobx";
import { DataModel, Model, model, prop } from "mobx-keystone";
import { types } from "mobx-state-tree";
function bench(f: () => { value: number }) {
// Warmup
let sum = 0;
for (let index = 0; index < 100_000; ++index) {
sum += f().value;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="css/app.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
@coolsoftwaretyler
coolsoftwaretyler / prereqs.md
Last active April 15, 2020 19:59
Make a Website Super Fast Crash Course
@coolsoftwaretyler
coolsoftwaretyler / sample_object.rb
Last active February 7, 2020 03:50
Rails Fragment Caching and Low Level Caching
class SampleObject < ApplicationRecord
def external_components
Rails.cache.fetch("#{cache_key_with_version}/components", expires_in: 12.hours) do
# Some long running task that fetches "components"
end
end
end
doSomeLongRunningTask(function(response, error) {
// This function is running as a CALLBACK inside the long task
// So it logs on completion
console.log(response)
// Return the response
return response;
}
var res = doSomeLongRunningTask(function(response, error) {
@coolsoftwaretyler
coolsoftwaretyler / flatten.rb
Last active May 28, 2019 17:25
An array flatten method written in Ruby for Theorem LLC interview. Uses RSpec for unit tests. Created by Tyler Williams. tyler@ogdenstudios.xyz
# Use RSpec for testing https://rspec.info/
require 'rspec'
# Define the flatten function, we'll use it recursively
# On the initial run, set `results` to an empty array
def flatten(array, results = [])
# Check that array is not nil
if array
# For each item in the array, check if it's a nested array
array.each do |item|