Skip to content

Instantly share code, notes, and snippets.

View Saturate's full-sized avatar
🛠️
Building Stuff

Allan Kimmer Jensen Saturate

🛠️
Building Stuff
View GitHub Profile
@Saturate
Saturate / utils.d.ts
Created November 21, 2023 15:18
Modify typescript type
/*
Helpful utility type for modifying a interface defined by for example swagger, where we can't edit the type/interface directly.
Let's say that we have the following:
baskets: BasketTypes.ISavedBasket[];
But the ID in `ISavedBasket` can be undefined due to the type, but this is not the real case from the API, just the type
as a basket without id could never exsist.
const key = [8, 131, 214, 191, 186, 15, 133, 27, 56, 78, 231, 188];
const password_enc = "5bf6a6dac85ce0784a7d93ec69f0a5c88a7de13a";
const encrypt = (bytes, key) => {
for (var i = 0; i < bytes.length; i++) {
bytes[i] = bytes[i] ^ key[i % key.length];
}
return bytes;
};
@Saturate
Saturate / add-style.css
Created October 6, 2023 13:44
Twitter Titles for link CSS
[data-testid="card.layoutLarge.media"] a[aria-label]::after {
content: "Title: " attr(aria-label);
display: block;
position: relative;
color: #fff;
padding: 1em;
margin: 0 0 1.5em;
}
@Saturate
Saturate / README.md
Created October 4, 2022 16:56
Project Zomboid - Generate WorkshopItems from Steam Workshop Collection

Project Zomboid - Generate WorkshopItems from Steam Workshop Collection

This snippet will generate a list suited for the Project Zomboid config from a Steam Workshop Collection.

How to use:

  1. Navigate to your collection (eg. https://steamcommunity.com/sharedfiles/filedetails/?id=2871262277)
  2. Copy the code in console.js
  3. Open the devtools for your browser (F12)
  4. Paste and run the code
  5. Copy the output
  6. Paste the config line into your config.
@Saturate
Saturate / rf-2019.schedule.json
Last active June 14, 2019 11:05
Roskilde Festival 2019 Schedule as JSON!
[
{
"name": "SØN",
"country": "DK",
"time": "21:30",
"detailsLink": "https://www.roskilde-festival.dk/en/years/2019/acts/søn/",
"date": "2019-06-30T19:30:00.000Z",
"stage": "Rising",
"shortDescription": "Portrait of a young generation, painted with delicious guitar pop"
},
{
"name": "",
"version": "1.0.0",
"description": "",
"license": "UNLICENCED",
"author": "Allan",
"main": "index.js",
"private": true,
"scripts": {
"translations": "cross-env NODE_ENV=development extract-messages -l=en,da -o Components/Translations -d da --flat true \"Components/**/!(*.test).{ts,tsx}\""
admin.auth().createUser({
uid: '203757', // should match the user id in the database, in the DB we store additional information.
email: 'allankimmerjensen@gmail.com',
emailVerified: false,
password: 'secretPassword',
displayName: 'Allan Kimmer Jensen',
photoURL: 'http://www.example.com/12345678/photo.png',
@Saturate
Saturate / action-keys.test.js
Created March 22, 2019 13:47
When you use redux, you might have an actions keys file, a common error is having two const export the same thing. This will test for that, and maybe make your coverage 100%!
import * as actionKeys from './action-keys';
describe('action keys', () => {
it('should have a unique string for each key', () => {
let uniq = Object.keys(actionKeys)
.map(objKey => {
return { count: 1, name: actionKeys[objKey] };
})
.reduce((a, b) => {
a[b.name] = (a[b.name] || 0) + b.count;
@Saturate
Saturate / mock.date.now.js
Last active March 18, 2019 12:32
Mocking Date.prototype.toLocaleString with Jest, as it's not working in jsdom
Date.now = jest.fn(() => 1482363367071);
@Saturate
Saturate / apis.txt
Last active January 7, 2019 10:12
poe.ninja API URI's
https://poe.ninja/api/Data/GetFragmentOverview?league=Betrayal
https://poe.ninja/api/Data/GetCurrencyOverview?league=Betrayal