Skip to content

Instantly share code, notes, and snippets.

@achillesrasquinha
achillesrasquinha / import-python-string.md
Created June 12, 2019 21:51
Import into Python via String

Handles

  • import foobar
  • import foo.bar as baz
  • from foo import bar
  • from foo.bar import Baz
  • from foo.bar import BAZ
class HandlerRegistry(dict):
@davidmreed
davidmreed / simple-salesforce-jwt.py
Created January 15, 2019 01:32
Using simple_salesforce with JWT authentication
import jwt
import requests
import datetime
from simple_salesforce import Salesforce
from simple_salesforce.exceptions import SalesforceAuthenticationFailed
def jwt_login(consumer_id, username, private_key, sandbox=False):
endpoint = 'https://test.salesforce.com' if sandbox is True else 'https://login.salesforce.com'
jwt_payload = jwt.encode(
{
@michoelchaikin
michoelchaikin / postmanNetSuiteTBA.js
Last active December 23, 2023 19:06
Postman pre-request script to generate TBA variables for NetSuite Web Services
/*
Usage:
1. Define a NetSuite environment in Postman (https://www.getpostman.com/docs/postman/environments_and_globals/manage_environments)
with the following keys set: account, consumerKey, consumerSecret, tokenId, tokenSecret
2. Add this script to your "Pre Request Script" in Postman (https://www.getpostman.com/docs/postman/scripts/pre_request_scripts)
3. Add the Token Passport in your request with variable placeholders
@Tatsh
Tatsh / delall-icloud-photos.py
Last active December 17, 2023 03:40
Use pyicloud to delete all photos from iCloud (may need to be run multiple times)
#!/usr/bin/env python
from __future__ import print_function
import json
import sys
from authentication import authenticate
from future.moves.urllib.parse import urlencode
if __name__ == '__main__':
username = sys.argv[1]
@princebot
princebot / install_wormhole.bat
Created July 29, 2017 17:44
Install Python magic-wormhole on Windows.
::
:: This script installs wormhole (https://github.com/warner/magic-wormhole) and
:: its prerequisites. Run this as an administrator.
::
:: Install chocolatey.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
:: Install Python 3.
choco install -y python
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active May 11, 2024 18:47 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@NelsonMinar
NelsonMinar / mp.py
Last active December 5, 2023 15:26
multiprocessing Pool example
#!/usr/bin/env python2
"Demonstrate using multiprocessing.Pool()"
import multiprocessing, time, logging, os, random, signal, pprint, traceback
logging.basicConfig(level=logging.DEBUG)
_L = logging.getLogger()
class JobTimeoutException(Exception):
@yryozo
yryozo / orgtbl-to-gfm.el
Created June 18, 2013 17:02
Orgtbl Translator function for the GitHub-Flavored-Markdown(GFM)
;; Usage Example:
;;
;; <!-- BEGIN RECEIVE ORGTBL ${1:YOUR_TABLE_NAME} -->
;; <!-- END RECEIVE ORGTBL $1 -->
;;
;; <!--
;; #+ORGTBL: SEND $1 orgtbl-to-gfm
;; | $0 |
;; -->