Skip to content

Instantly share code, notes, and snippets.

View nathanhere's full-sized avatar
🤠

Nathan nathanhere

🤠
View GitHub Profile
@nathanhere
nathanhere / calc-gpu-layers.py
Created March 17, 2024 09:08 — forked from mrseanryan/calc-gpu-layers.py
Rough PoC using binary search to find the optimal number of model layers to offload to the GPU, for this LLM and this hardware.
"""
Rough PoC using binary search to find the optimal number of model layers to offload to the GPU, for this LLM and this hardware.
"""
import time
def call_llm(prompt, gpu_layers):
# TODO fill in the actual call to LLM here
# dummy GPU memory limit
test_best_layers = 60
@nathanhere
nathanhere / selection-command.js
Created December 19, 2019 17:36 — forked from erquhart/selection-command.js
Text selection commands for Cypress.io
/**
* Credits
* @Bkucera: https://github.com/cypress-io/cypress/issues/2839#issuecomment-447012818
* @Phrogz: https://stackoverflow.com/a/10730777/1556245
*
* Usage
* ```
* // Types "foo" and then selects "fo"
* cy.get('input')
* .type('foo')
@nathanhere
nathanhere / removeListDuplicates.py
Created July 27, 2013 06:37
Remove duplicates from a list
def removeListDuplicates(seq):
seen = set()
seen_add = seen.add
return [ x for x in seq if x not in seen and not seen_add(x) ]
@nathanhere
nathanhere / ListDirectoryContents.py
Created May 15, 2013 06:33
List current directory contents in web browser (for Koding.com)
#!/usr/bin/python
# Make sure file permission is set so that Owner, Group, and Everyone can EXECUTE.
# Otherwise server error
import os
import platform
print "Content-Type: text/html"
print
@nathanhere
nathanhere / emailFromPython.py
Created May 13, 2013 23:40
Secure method to send emails from Python. Currently only works to send email to self, as more header information is needed for other servers.
from smtplib import SMTP_SSL
smtp = SMTP_SSL()
def emailUser():
from_who_alias = 'Jarvis'
from_who_real = 'sender@domain.com'
to = 'recipient@domain.com'
subject = 'Your Subject'
msg = 'Your message'
@nathanhere
nathanhere / python-linkedin-API-Calls.py
Created May 9, 2013 08:29
Some examples of using the python-linkedin API calls. Must pass OAuth in order to use.
# Actual Search URL takes the form of https://api.linkedin.com/v1/people-search:(people:(first-name,last-name))?keywords=apple%20microsoft
results = application.search_profile(selectors=[{'people': ['first-name', 'last-name', 'headline', 'id', 'location', 'public-profile-url']}], params={'keywords': 'apple microsoft'})
profiles = [p for p in results['people']['values']] # returns the list of profiles only
# Set connection search limit. Start is the starting profile number, count is the number of profiles returned from the start number. In this case, it is 100.
application.get_connections(selectors=['headline', 'id','first-name', 'last-name','location'], params={'start':0, 'count':100})
profiles = [p for p in results['people']['values']] # returns the list of profiles only
# As of late 2012, this only retrieves the app user's own full profile info, and will not fetch full profile features (i.e. SKILLS) of connections, only basic profile info. Calling this function without a member_id parameter will pull the
Initial Gist Test
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae, sit, reprehenderit qui labore ab aliquam officiis magnam optio esse voluptatum non libero vel praesentium! Vero qui et repellat itaque iusto.</div>
<div>Animi, cumque, neque voluptatum quod ea recusandae commodi maxime quae voluptate quis nihil nobis deserunt illo suscipit nostrum blanditiis impedit ipsum eaque dolor repellendus odit sapiente ipsam? Quae, et, voluptatem?</div>
<div>Omnis, vitae, quos, ipsum nulla iure accusantium tempore ex officiis corporis sint minima vero nihil aut suscipit sit fuga amet quia hic necessitatibus qui quas recusandae accusamus tempora in repellat.</div>
<div>Vel, possimus, ipsam, sapiente est minus dignissimos itaque dicta magni vero aut sed quia nobis omnis eveniet iste nulla maiores incidunt a quasi dolore ex iusto nihil fugit. Quaerat, quis.</div>
<div>Tempore, voluptates, quis dolor reprehenderit sunt vel eius delectus incidunt qui quasi animi provident sint labore sed natus. Volu
@nathanhere
nathanhere / Linkedin-API-OAuth.py
Created May 9, 2013 08:08
Snippet used to successfully OAuth into the Linkedin API. Uses python-linkedin, requests, and a local Flask server to grab the authentication token from the preauthorization redirect URL containing the AUTH_CODE.
# Currently for use with local flask server only -- See corresponding flask code snippet
from linkedin import linkedin
import requests
API_KEY = ''
API_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_SECRET= ''
SCOPE = 'r_fullprofile%20r_network%20r_emailaddress%20r_contactinfo'