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 / sort-hackernews.js
Created January 17, 2022 21:32
Sort the front page of hacker news by score with this bookmarklet. Save it as a bookmark.
javascript: function findNodes(el) {
return el.querySelectorAll('.score');
}
function isDigit(str) {
return str.length === 1 && str.match(/[0-9]/i);
}
function metricVal(el) {
let modifiers = {
@ubershmekel
ubershmekel / find_ace.js
Last active October 12, 2022 10:41
Find an ace editor in your window or any other object
// 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
return obj && obj['getSelectedText'];
}
function globalSearch(startObject, isTargetFunc) {
var stack = [[startObject, '']];
var searched = [];
var found = false;
@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;
}
@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 / 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 / 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 {