Skip to content

Instantly share code, notes, and snippets.

View ubershmekel's full-sized avatar
🤙
What's a github status?

Yuval Greenfield ubershmekel

🤙
What's a github status?
View GitHub Profile
@ubershmekel
ubershmekel / sorttables.js
Last active January 12, 2024 06:00
Sort tables bookmarklet
/*
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable
@ubershmekel
ubershmekel / main.dart
Last active September 28, 2023 03:00
Test a stackoverflow solution. It doesn't work
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'dart:ui';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@ubershmekel
ubershmekel / main.dart
Created September 26, 2023 06:08
Word wrapping text labels is hard
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@ubershmekel
ubershmekel / remove-crunchbase-overlay.js
Created October 14, 2019 01:21
Crunchbase hides search results behind a darker element and blurs the rows. This removes that.
// E.g used on
// https://www.crunchbase.com/search/principal.investors/8ff469dfad43f418bb327da3508ebddf
// Crunchbase hides search results behind a darker element and blurs the rows. This removes that
// so you can see the top 15 results instead of just 5. Though you won't be able to see beyond that.
document.querySelector('.all-results-upsell-wrapper').remove()
document.querySelectorAll('grid-row').forEach((it) => { it.setAttribute("class", "") })
@ubershmekel
ubershmekel / json_history_to_kml.py
Last active July 4, 2023 10:08
Convert LocationHistory.json from Google takeout of location history (latitude) to a usable KML file for viewing in Google Earth.
"""
Convert LocationHistory.json from Google takeout of location history (latitude)
to a usable KML file for viewing in Google Earth.
Usage:
python json_history_to_kml.py LocationHistory.json
@ubershmekel
ubershmekel / sort-youtube-comments-bookmarklet.js
Last active April 5, 2023 02:08
On a video page, run this in the console, or click the bookmarklet, to have the comments sorted by their upvotes
javascript: function findNodes(el) {
return el.querySelectorAll('#vote-count-middle');
}
function isDigit(str) {
return str.length === 1 && str.match(/[0-9]/i);
}
function metricVal(el) {
let modifiers = {
@ubershmekel
ubershmekel / example.py
Last active February 23, 2023 08:16
Windows python process that upon death windows will kill its subprocesses
import subproc
import time
subproc.Popen('calc')
print('now close this window and see calc closing itself')
while True:
time.sleep(1)
@ubershmekel
ubershmekel / sort-youtube-bookmarklet.js
Last active February 1, 2023 01:24
Paste the following into a bookmark. When you're on a youtube channel's video page, you can now sort that page by view count. This new version works with the 2022 UI refresh that added rows to the mix.
javascript: function findMetrics(el) {
return el.textContent;
}
function findNodes(el) {
return el.querySelectorAll('#metadata-line');
}
function isDigit(str) {
return str.length === 1 && str.match(/[0-9]/i);
@ubershmekel
ubershmekel / race-condition.js
Created July 22, 2019 07:07
An example race condition in JavaScript
// An example race condition in JavaScript
// When you run this script using Node or in a browser, you'll find it
// does not print "Ended with 0", but a random number. Even though the functions running
// simply loop 100 iterations of adding and subtracting. The reason the end result is random
// is because the sleeps are of random duration and the time between the read of the variable
// causes the eventual write to be incorrect when `adder` and `subber` interleave.
// This problem is similar to https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use
let number = 0;
const times = 100;
@ubershmekel
ubershmekel / monaco-highlight-finder.js
Last active October 12, 2022 16:52
This is slow, but it works, to find the text that's highlighted by a monaco editor
// Paste this into JS to find an ACE editor in your browser window
// Based off of https://stackoverflow.com/questions/12102425/recursively-search-for-a-value-in-global-variables-and-its-properties/12103127#12103127
function isTarget(obj) {
// return typeof obj == typeof value && obj == value
if (obj && obj['getModel'] && obj.getModel() && obj.getModel().getValueInRange) {
const highlight = obj.getModel().getValueInRange(obj.getSelection())
if (highlight) {
console.log('highlight', highlight);
return true;
}