|
This file contains 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/env bash | |
PROFILE=${PROFILE:-my-profile-to-use} | |
AWS=/opt/homebrew/bin/aws | |
SSO_ACCOUNT=$($AWS sts get-caller-identity --query "Account" --profile "$PROFILE") | |
# kill existing pending sessions | |
pgrep -f 'aws sso login' | xargs kill | |
if [ ${#SSO_ACCOUNT} -eq 14 ]; then # 14 because 2 quotes + 12-digit account number | |
exit 0 |
This file contains 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
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts, | |
that detects and handles AJAXed content. | |
Usage example: | |
waitForKeyElements ( | |
"div.comments" | |
, commentCallbackFunction | |
); |
This file contains 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
filename='yourfilename' | |
filetype='text/csv' | |
token='my oauth token' | |
url='http://localhost/upload' | |
curl "$url" \ | |
--form "data=@$filename;type=$filetype" \ | |
--form "name=somename" \ | |
-H "Authorization: Bearer $token" | |
This file contains 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 makeReplacer(str) { | |
const regex = /\$\w+\.(\w+)/g; | |
let strFragments = []; // stores static strings, or a function to get value from map | |
let m; // regex match object | |
let idx; // index tracking the position of one match in `str` | |
while ((m = regex.exec(str)) !== null) { | |
// This is necessary to avoid infinite loops with zero-width matches | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} |
This file contains 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
{ | |
"title": "Emit Command+Backtick if Command and Escape are pressed", | |
"rules": [ | |
{ | |
"description": "Change escape to backtick if pressed with command", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "escape", |
This file contains 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 unfollow() { | |
window.scrollTo(0, document.body.scrollHeight); | |
setTimeout(function() { | |
console.log('unfollowed'); | |
let list = document.querySelectorAll('.follow-link.zg-unfollow.meta-item'); | |
list[0].click(); | |
unfollow() | |
}, 1000) | |
} | |
unfollow() |
This file contains 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
test |
This file contains 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
import java.util.*; | |
public class UniqueArray { | |
public static int[] unique(int[] integers) { | |
return Arrays.stream(integers).distinct().toArray(); | |
} | |
} |
NewerOlder