Skip to content

Instantly share code, notes, and snippets.

View nk-gears's full-sized avatar
💥
experimenting...

Nirmal nk-gears

💥
experimenting...
View GitHub Profile
@misterhay
misterhay / bitly-api-with-google-apps-script.gs
Last active May 12, 2023 20:54
JavaScript code to interact with the Bitly API
function bitlyGroupId() {
var accessToken = ''; // paste in your access token from https://bitly.is/accesstoken
var headers = {'Authorization' : 'Bearer '+accessToken};
var params = {'headers' : headers};
var fetchUrl = 'https://api-ssl.bitly.com/v4/groups';
var response = UrlFetchApp.fetch(fetchUrl, params);
var group_guid = JSON.parse(response.getContentText()).groups[0].guid;
Logger.log(group_guid)
return group_guid
}
@channeladam
channeladam / Xero-ClientCredentials-Workaround-2020
Last active August 8, 2022 15:08
Xero client_credentials workaround - January 2020
Here is a workaround for the lack of a client credentials flow in Xero's OAuth 2.0 / OpenID Connect implementation.
From Xero's FAQ: https://developer.xero.com/faq/all/oauth-private
"Is there an equivalent of two-legged private apps in OAuth 2.0?
No, all users will follow the same OAuth 2.0 code flow.
Once you have an access token and refresh token you can refresh indefinitely or until the token is revoked by the user."
Workaround:
1. Login to Xero as the Xero user to use for the machine-to-machine flow workaround.
@Timtech4u
Timtech4u / Dockerfile
Last active March 20, 2020 08:47
Hello World - A Containerized Flask Web Application
FROM python:3.7-stretch
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["main.py"]
@kaushikgopal
kaushikgopal / karabiner.edn
Last active May 16, 2024 00:57
My source Karabiner file in Goku's edn format - Now lives @ https://github.com/kaushikgopal/dotfiles/blob/master/.karabiner.edn
;; File has moved over to https://github.com/kaushikgopal/dotfiles/blob/master/.karabiner.edn
;; Feel free to raise github issues in that repo, if you have questions/comments/edits
@kazqvaizer
kazqvaizer / multipartify.py
Last active June 11, 2024 12:47
Python dict to multipart/form-data converter to use it requests
"""
Here is a way to flatten python dictionaries for making multipart/form-data POST requests.
{"some": ["balls", "toys"], "field": "value", "nested": {"objects": "here"}}
->
{"some[0]": "balls", "some[1]": "toys", "field": "value", "nested[objects]": "here"}
@mtunjic
mtunjic / disable.sh
Last active March 31, 2024 18:12
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@doofusdavid
doofusdavid / PY0101EN-2-2-Lists.ipynb
Created November 10, 2019 01:46
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adfindlater
adfindlater / searchablePDF.py
Created October 27, 2019 22:56
Generate a searchable PDF using Tesseract 4.0
import pytesseract
import argparse
import os
from pdf2image import convert_from_path
from PyPDF2 import PdfFileMerger
from progressbar import ProgressBar
def create_searchable_pdf(images: list, output_path: str):
#!/bin/bash
CONTAINER_NAME=stepfunctions
STATE_MACHINE_DEFINITION=/path/to/yourstatemachine.json
STATE_MACHINE_NAME="Name of your process"
ENV_FILE=path/to/your-stepfunctions-local-credentials.txt
INPUT="{ \"myInput\": \"hello world\"}"
function get_value_from_json(){
VALUE="$(jq .$1 temporary.json)"
@ryu1kn
ryu1kn / README.md
Last active June 7, 2024 09:40
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,