Skip to content

Instantly share code, notes, and snippets.

View xcv58's full-sized avatar
😀
What's happening?

xcv58 xcv58

😀
What's happening?
View GitHub Profile
@xcv58
xcv58 / test.js
Created February 19, 2023 18:58
Test javascript injection
console.log('works from gist')
@xcv58
xcv58 / Switch to AirPods.scpt
Created December 25, 2022 23:58
AppleScript switch to AirPods
set deviceName to "AirPods 2021"
tell application "System Events" to tell process "Control Center"
set i to 1
repeat with anElement in menu bar items of menu bar 1
if description of anElement is "Sound" then
exit repeat
end if
set i to i + 1
end repeat
click (menu bar item i) of menu bar 1
@xcv58
xcv58 / copy-phab-title.js
Last active August 5, 2021 17:36
copy phab title with rich text
const copySelectedPhabs = () => {
let selection = window.getSelection();
if (selection.rangeCount <= 0) {
return
}
const div = document.createElement('div')
Array.from(document.querySelectorAll('.phui-oi-frame'))
.filter(el => selection.containsNode(el, true))
.forEach(el => {
const tmp = el.cloneNode(true)
@xcv58
xcv58 / Phabricator-toggle-collapse.js
Last active May 29, 2020 18:19
Add a toggle collapse to enable one click collapse/expand.
const mouseEvent = document.createEvent('MouseEvents')
mouseEvent.initEvent('click', true, true)
const COLLAPSE_FILE = 'Hide Changeset'
const EXPAND_FILE = 'Expand File'
const getOptionsButton = (element) => {
const links = [...element.getElementsByTagName('a')].filter(link => link.innerHTML.search('View Options') > -1)
if (links.length <= 0) {
throw new Error('Now Option Button Found!')
}
let test = `
The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError.
The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError.
The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError.
The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError.
The maximum size (in bytes) of each individual item
n = int(input())
prices = [int(i) for i in input().split()]
d = { x: i for i, x in enumerate(prices) }
sorted_prices = sorted(prices)
pairs = [ i - j for i, j in zip(sorted_prices[1:], sorted_prices[:-1]) if d[i] < d[j] ]
print(min(pairs))
public class Hello {
public enum Test {
A("A"), B("B"), C("C"), D("D");
public static String a = "a";
{
System.out.println("Hi Test");
}
Test(String test) {
class MyIter implements Iterator {
private Iter a;
private Iter b;
private Integer common;
public MyIter(Iter a, Iter b) {
if (a == null || b == null) {
throw new Exceptin("Null");
}
@xcv58
xcv58 / prime.py
Created September 23, 2016 14:43
def is_prime(n):
return [1 for i in range(2, n) if n % i is 0] == []
print [i for i in range(2, 100) if is_prime(i)]
@xcv58
xcv58 / prime.py
Created September 23, 2016 14:35
def is_prime(n):
for i in range(2, n/ 2 + 1):
if n % i is 0:
return False
return True
print [i for i in range(2, 100) if is_prime(i)]