Skip to content

Instantly share code, notes, and snippets.

View shilangyu's full-sized avatar
🗿
I have no idea what I am doing

Marcin Wojnarowski shilangyu

🗿
I have no idea what I am doing
View GitHub Profile
@shilangyu
shilangyu / README.md
Created February 19, 2023 20:47
Static assert in C

Enum variant values have to be constant expression integers. Division by 0 does not yield an integer so the compilation fails.

class Event {}
class CoolEvent extends Event {}
class EventHandler<T extends Event> {}
extension<T extends Event> on EventHandler<T> {
Type get eventType => T;
}
void func(List<int?> l) {
l.followedBy([]);
}
void main() {
List<int> l1 = [123];
func(l1);
}
@shilangyu
shilangyu / index.ts
Last active July 24, 2019 21:31
Strongly typed Mobx-React `inject` that separates injects from props
import { inject, IStoresToProps } from 'mobx-react'
import { Component } from 'react'
import UserStore from './UserStore' // import your stores
import AuthStore from './AuthStore' // import your stores
export const user = new UserStore()
export const auth = new AuthStore()
export interface IStores {
user: UserStore,
@shilangyu
shilangyu / YTthumbnail.js
Created April 30, 2019 11:16
Get youtube thumbnail
javascript: (() => { window.open(`http://img.youtube.com/vi/${ytplayer.config.args.video_id}/hqdefault.jpg`); })();
@shilangyu
shilangyu / brainly.js
Last active March 27, 2023 14:34
Unlock brain.ly answers (bookmarklet)
javascript: (() => {document.querySelector('#answers > div > div.brn-kodiak-answer.js-kodiak-answer.js-answer.brn-kodiak-answer--locked > div.brn-kodiak-answer__content > div.js-access-to-answers__with-access.js-first-question.js-hidden').classList.remove("js-hidden");document.querySelector('#answers > div > div.brn-kodiak-answer.js-kodiak-answer.js-answer.brn-kodiak-answer--locked > div.brn-kodiak-answer__unlock.js-scroll-to-unlock-section').remove();document.querySelector('#answers > div > div.brn-kodiak-answer.js-kodiak-answer.js-answer.brn-kodiak-answer--locked > div.brn-kodiak-answer__preview-end').remove();document.querySelector('#answers > div > div.brn-kodiak-answer.js-kodiak-answer.js-answer.brn-kodiak-answer--locked > div.brn-kodiak-answer__content > div.js-access-to-answers__preview-start.brn-kodiak-answer__content--cut').remove();})()
@shilangyu
shilangyu / file-lister.js
Created September 22, 2018 13:30
Creates a json file listing all files and dirs from the caller dir (node.js)
const [path, fs] = ['path', 'fs'].map(require)
// config
const config = {
outputFile: {
name: 'files.json',
dir: './',
indent: 2