Skip to content

Instantly share code, notes, and snippets.

View sai-manoj-kumar's full-sized avatar
🌴
On vacation

Sai Manoj Kumar sai-manoj-kumar

🌴
On vacation
View GitHub Profile
let fileMang = FileManager.default
var filePath = NSHomeDirectory()
do {
let appSupportDir = try FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
filePath = appSupportDir.appendingPathComponent("points.txt").path
}
catch{}
print(filePath)
if fileMang.fileExists(atPath: filePath) {
do {
pm.sendRequest({
url: 'https://login.microsoftonline.com/' + pm.environment.get("tenantId") + '/oauth2/token',
method: 'POST',
header: 'Content-Type: application/x-www-form-urlencoded',
body: {
mode: 'urlencoded',
urlencoded: [
{key: "grant_type", value: "client_credentials", disabled: false},
{key: "client_id", value: pm.environment.get("clientId"), disabled: false},
{key: "client_secret", value: pm.environment.get("clientSecret"), disabled: false},

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 26, 2024 06:07
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@DaveWoodCom
DaveWoodCom / String+Email.swift
Last active February 28, 2021 16:45
Swift method to check for a valid email address (uses Apples data detector instead of a regex)
extension String {
func isValidEmail() -> Bool {
guard !self.lowercaseString.hasPrefix("mailto:") else { return false }
guard let emailDetector = try? NSDataDetector(types: NSTextCheckingType.Link.rawValue) else { return false }
let matches = emailDetector.matchesInString(self, options: NSMatchingOptions.Anchored, range: NSRange(location: 0, length: self.characters.count))
guard matches.count == 1 else { return false }
return matches[0].URL?.scheme == "mailto"
}
}
@squarism
squarism / iterm2.md
Last active June 11, 2024 18:05
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
javascript:(function(){
var overlay = document.getElementById('mw-sopaOverlay');
overlay.parentNode.removeChild(overlay);
var pages = ['mw-page-base', 'mw-head-base', 'content', 'mw-head', 'mw-panel', 'footer'];
var i = 0;
for (i = 0; i < pages.length; i++) {
var pageName = pages[i];
var page = document.getElementById(pageName);
page.setAttribute('style', '');
page.style.display = 'block';
@sai-manoj-kumar
sai-manoj-kumar / git commands
Created December 18, 2011 11:19
git commands to create a git locally and then push it to github.com
git config --global user.name "Your Name"
git config --global user.email uremailid@domain.com
Next steps:
mkdir Test
cd Test
git init
touch README
git add README
git commit -m 'first commit'