This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ctx | |
| import "context" | |
| // Value returns a strongly-typed value from the given context using ctx.Value. | |
| // ok will be true if found in the context and if the correct type. | |
| func Value[T any](ctx context.Context, key any) (val T, ok bool) { | |
| if val, ok = ctx.Value(key).(T); ok { | |
| return val, ok | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| from variety.plugins.IQuoteSource import IQuoteSource | |
| import subprocess, re | |
| from locale import gettext as _ | |
| class FortuneSource(IQuoteSource): | |
| @classmethod | |
| def get_info(cls): | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Gist: 11375877 | |
| # Url: https://gist.github.com/goodevilgenius/11375877 | |
| # | |
| # All memcache functions are supported. | |
| # | |
| # Can also be sourced from other scripts, e.g. | |
| # source membash.sh | |
| # MCSERVER="localhost" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # cheat_sheet.org.sh | |
| # The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License. | |
| # Best viewed in emacs org-mode. | |
| # Alternately, one can keep this cheat sheet handy by adding the following line to ~/.bashrc: | |
| # | |
| # alias cheatsheet="less ~/path_to_cheat_sheet.org.sh" | |
| # | |
| # Originally by WilliamHackmore: https://github.com/WilliamHackmore/linuxgems | |
| # This version by goodevilgenius: https://gist.github.com/goodevilgenius/2d1c01251c524610a2cd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func Tern[V any](choice bool, one, two V) V { | |
| if choice { | |
| return one | |
| } | |
| return two | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clickRemove() { | |
| const button = [...document.querySelectorAll('.yt-formatted-string')].find(el => el.innerText === 'Remove from '); | |
| if (!button) { | |
| console.log("Can't find remove button"); | |
| return; | |
| } | |
| button.click(); | |
| setTimeout(emptyList, 1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Promise.prototype.getQueryable = function () { | |
| if (this.isFulfilled) return this; | |
| let isPending = true; | |
| let isRejected = false; | |
| let isFulfilled = false; | |
| let value = undefined; | |
| let error = undefined; | |
| let result = this.then(v => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* global $, data */ | |
| // data should be the object/array/etc to be JSON-ified. | |
| // First, with jQuery | |
| var $el = $('<a>'); | |
| $(document.body).append($el); | |
| // If data is a jQuery selector, then do data = data.toArray() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Method for accessing private/protected properties/methods without Reflection. | |
| * | |
| * This is particularly useful when debugging from the command-line, for example, with psysh. | |
| * | |
| * Static methods/properties can be accessed by passing the class instead. | |
| * Constants are not acccessible. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Assuming you name the file pushover.sh, place somewhere within your $PATH, then chmod +x /path/to/pushover.sh | |
| # Invoke with: pushover.sh [-d device_name] [-t Title] [-u Url] [-ut URL Title] [-p] [-ts timestamp] "notifcation text" | |
| token="" | |
| user="" | |
| test -f ~/.pushover && source ~/.pushover # Put your API token and user key here |
NewerOlder