Skip to content

Instantly share code, notes, and snippets.

@odhiambo123
odhiambo123 / Basic API call (JavaScript).EXCEL.yaml
Created May 11, 2019 08:29
Performs a basic Excel API call using plain JavaScript & Promises.
name: Basic API call (JavaScript)
description: Performs a basic Excel API call using plain JavaScript & Promises.
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
function run() {
return Excel.run(function(context) {

Keybase proof

I hereby claim:

  • I am odhiambo123 on github.
  • I am ajuoga (https://keybase.io/ajuoga) on keybase.
  • I have a public key ASB0RU2_3fF4dtRAlfF9yFO3haCn9gga74lhjj1Ie8womQo

To claim this, I am signing this object:

@odhiambo123
odhiambo123 / general_funcs.py
Created April 4, 2022 15:12
find three consecutive numbers adding to num
def find_3_consec_nums(num):
x=[]
if num % 3 !=0:
return x
else:
n=num//3
m=n-1
o=n+1
x.append(m)
x.append(n)
@odhiambo123
odhiambo123 / general_funcs.py
Created April 4, 2022 17:15
rearange num digits to create a smallest number possible with no leading zeroes
def rearange_to_smalest(num):
arr = sorted(str(abs(num))) #sort and rteturn the absolute value
if num<=0: #check if its 0 or negative
return -int(''.join(arr[::-1])) #rearange, combine, and add the negative
# make sure there are no leading zeroes by looping over and swaping with the 1st non-zero
i = 0
while arr[i] == '0':
i +=1
arr[0], arr[i] = arr[i],arr[0]
@odhiambo123
odhiambo123 / general_funcs.py
Created April 7, 2022 21:46
Creating JSON from CSV file
# Reading csv files into JSON
def csv_to_json(csvFilePath, jsonFilePath):
jsonArray = []
with open(csvFilePath, encoding='utf-8') as csvf:
csvReader = csv.DictReader(csvf)
for row in csvReader:
jsonArray.append(row)
@odhiambo123
odhiambo123 / general_funcs.py
Created April 7, 2022 21:55
Replace text in a string
# replace string
def replace_string(txt, x, y):
z = txt.replace(x,y)
print(z)
@odhiambo123
odhiambo123 / general_funcs.py
Created April 7, 2022 21:56
Replacing a character in a string
# replace string
def replace_string(txt, x, y):
z = txt.replace(x,y)
print(z)
@odhiambo123
odhiambo123 / general_funcs.py
Created April 9, 2022 22:19
Text to Speech using Python pyttx3
def text_to_speech():
try:
import pyttsx3
except ImportError:
print("pyttsx3 needs to be installed, you can install it on windows by running: ")
print("pip install pyttsx3")
sys.exit()
tts = pyttsx3.init() #Initialize the TTS engine
print("enter text to speak, or QUIT to quit")
@odhiambo123
odhiambo123 / admin.py
Created April 17, 2022 17:20
admin.py
from django.contrib import admin
from .models import Profile, FriendRequest
admin.site.register(Profile)
admin.site.register(FriendRequest)
@odhiambo123
odhiambo123 / forms.py
Created April 17, 2022 17:31
covering forms.py
"""
learn about forms at https://docs.djangoproject.com/en/4.0/topics/forms/
be sure to look for the latest version
this form covers
UserRegisterForm
UserUpdateForm
ProfileUpdateForm
"""