Skip to content

Instantly share code, notes, and snippets.

View liweiyap's full-sized avatar
🌹
Roses are red, violets are blue. Segmentation fault on line 32.

Li-Wei Yap liweiyap

🌹
Roses are red, violets are blue. Segmentation fault on line 32.
View GitHub Profile
@MidSpike
MidSpike / readme.md
Last active February 5, 2024 18:09
CVE-2022-23812 | RIAEvangelist/node-ipc is malware / protest-ware
@mxalbert1996
mxalbert1996 / Scrollbar.kt
Last active July 6, 2024 07:45
Modifiers to draw scrollbars in Jetpack Compose
/*
* MIT License
*
* Copyright (c) 2022 Albert Chang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@DesignFront
DesignFront / detect-dark-mode.js
Last active September 12, 2021 20:04
Detect Darkmode
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// dark mode
}
// to watch for changes:
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
console.log(`changed to ${e.matches ? "dark" : "light"} mode`)
});
import Foundation
import Combine
var subscriptions = Set<AnyCancellable>()
let start = Date()
Timer.publish(every: 1.0, on: .main, in: .common)
.autoconnect()
.map({ (output) in
return output.timeIntervalSince(start)
@dhbalaji
dhbalaji / darkModeDetection.md
Last active July 23, 2021 07:33
Detect Dark Mode in Javascript & media query css

Detect Dark Mode in Javascript & Media Query CSS

Problem Context

Most operating systems have a setting to set the apps background to dark colors. This is done to reduce the eye strain. Web apps can detect the OS setting and adjust the application colors accordingly. This is an UX enhancement which we can showcase.

Solution

Javascript code to detect dark mode

@RobertAKARobin
RobertAKARobin / python.md
Last active June 13, 2024 04:24
Python Is Not A Great Programming Language
import requests
import praw
import logging
import time
import random
import schedule
import pickle
import sys
from datetime import datetime, timedelta
@mbinna
mbinna / effective_modern_cmake.md
Last active July 6, 2024 03:59
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@anthonygclark
anthonygclark / variant_queue.cc
Created May 2, 2017 22:28
std::queue with boost::variant and dispatch type handling
#include <iostream>
#include <queue>
#include <boost/variant.hpp>
struct message_tag {
bool handled = false;
message_tag() = default;
message_tag(std::nullptr_t) { }
};