Skip to content

Instantly share code, notes, and snippets.

View ivmirx's full-sized avatar
🐙

Ivan Mir ivmirx

🐙
View GitHub Profile
@ivmirx
ivmirx / delete-all-messages.js
Created November 9, 2023 19:12 — forked from rcx/delete-all-messages.js
Delete all your messages in a Discord channel
/*
* Discord: Don't copy stuff into this box
* Me: dOn'T COpy sTuFf iNtO tHIs bOx
*/
clearMessages = function (guild_id, author_id, authToken, deleted = new Set()) {
if (guild_id[0] == "_" && guild_id[guild_id.length - 1] == "_") {
alert("Oops! You forgot to set the guild_id. Please fill it in.")
return;
}
if (author_id[0] == "_" && author_id[author_id.length - 1] == "_") {
@ivmirx
ivmirx / SilentSwitch.cs
Last active April 30, 2021 00:42
Detecting when sound is muted with the silent switch on iPhone or iPad for .NET & Xamarin. Useful for text-to-speech because it does not work when a device is in silent mode. Based on https://github.com/moshegottlieb/SoundSwitch
// since there is no API for checking if the silent mode is on, the trick is to play a 50ms silent system sound
// if it takes just a few milliseconds, it means the sound wasn't allowed to play and the silent mode is on
using System;
using Foundation;
using AudioToolbox;
using System.Threading.Tasks;
public class SilentSwitch
{
Based on mentalhealth.txt by @potatoqualitee:
https://gist.github.com/potatoqualitee/d873c10d8cc578c11fc2ea508bcb2501
## Politics ##
alt-right
Brexit
Capitol
CCP
China
CIA
@ivmirx
ivmirx / xcode.xml
Created December 28, 2020 14:00
Key bindings to duplicate and delete lines in Xcode
<!--
Nowadays Xcode has a "Delete Line" key binding, but it jumps to the beginning of the next line after deletion.
The custom one jumps to the end of the next line.
Custom key bindings have to be added after every Xcode update.
Open the following file with any text editor:
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
…and insert the following:
-->
@ivmirx
ivmirx / platforms.js
Created November 28, 2020 00:54
Detect the most common platforms, including ipadOS
var is_windows = navigator.platform.indexOf('Mac') > -1;
var is_macOS = false;
var is_ipadOS = false;
var is_iOS = /(iPhone|iPod)/i.test(navigator.platform);
var is_Android = navigator.platform.indexOf('Android') > -1;
var is_Linux = navigator.platform.indexOf('Linux') > -1;
if (navigator.platform.indexOf('Mac') > -1) {
if (navigator.maxTouchPoints > 1)
is_ipadOS = true
@ivmirx
ivmirx / MvxBottomNavigationItemChangedBinding.cs
Last active June 25, 2022 14:09
Using the new Android's BottomNavigationView with MvvmCross 6
// a custom binding for Droid to get "app:MvxBind" in root_view working
using System;
using Android.Support.Design.Widget;
using MvvmCross.Binding;
using MvvmCross.Commands;
using MvvmCross.Platforms.Android.Binding.Target;
namespace YourApp.Droid.Bindings
{
@ivmirx
ivmirx / filter.js
Last active February 10, 2020 20:20
Filter for hckrnews.com (Chrome and Firefox extension)
var words = [
'php', 'js', 'javascript', 'css', 'java', 'ruby', 'rust', 'golang', 'go\'s', 'kotlin', 'perl',
'elixir', 'elm ', 'erlang', 'clojure', 'lisp', 'racket', 'scala',
'mozilla', 'firefox', 'mysql', 'mongo', 'latex', 'webgl',
'dell', 'amd',
'google', 'facebook', 'amazon', 'aws ', 'airbnb', 'uber', 'unicorn', 'damore', 'kalanick', 'bezos',
'kubernetes', 'docker', 'tensor', ' ml ', 'machine learning', 'artificial intelligence',
'self-driving', 'tesla', 'musk', 'spacex', 'hyperloop', 'bitcoin', 'btc', 'ethereum', 'blockchain',
'u.s.', 'president', 'trump', 'congress', 'police', 'military', 'federal', 'fbi', 'nsa ', 'snowden',
'francisco', 'new york', 'california', 'bay area', 'texas', 'wall street', 'verizon',