Skip to content

Instantly share code, notes, and snippets.

View HamedMP's full-sized avatar
💛

hamed HamedMP

💛
View GitHub Profile
const SECRET_KEY = ENTER YOUR SECRET KEY HERE;
const MAX_TOKENS = 200;
// For more cool AI snippets and demos, follow me on Twitter: https://twitter.com/_abi_
/**
* Completes your prompt with GPT-3
*
* @param {string} prompt Prompt
* @param {number} temperature (Optional) Temperature. 1 is super creative while 0 is very exact and precise. Defaults to 0.4.
{
"openapi": "3.0.0",
"servers": [
{
"url": "https://login.auth0.com/"
}
],
"info": {
"title": "login.auth0.com",
"version": "2"
@HamedMP
HamedMP / extractAnnotations.py
Created August 7, 2019 08:49 — forked from stevepowell99/extractAnnotations.py
Extracts annotations and highlighted passages in all .pdf files in a folder recursively and outputs them as text files with the same name and modification date
#!/usr/bin/env python
# see http://socialdatablog.com/extract-pdf-annotations.html
myxkfolder="/home/steve/xk/" #you need to set this to where you want your to-dos to appear
import poppler, os.path, os, time, datetime
for root, dirs, files in os.walk('./'):
for lpath in files:
@HamedMP
HamedMP / dumppdfcomments.py
Created August 7, 2019 08:49 — forked from Samathy/dumppdfcomments.py
Python Script to extract highlighted text from PDFs. Uses python-poppler-qt4. Updated [1] to Python 3 [1] https://stackoverflow.com/questions/21050551/extracting-text-from-higlighted-text-using-poppler-qt4-python-poppler-qt4
import popplerqt4
import sys
import PyQt4
def main():
doc = popplerqt4.Poppler.Document.load(sys.argv[1])
total_annotations = 0
for i in range(doc.numPages()):
@HamedMP
HamedMP / separator.py
Created April 6, 2019 10:33 — forked from jlln/separator.py
Efficiently split Pandas Dataframe cells containing lists into multiple rows, duplicating the other column's values.
def splitDataFrameList(df,target_column,separator):
''' df = dataframe to split,
target_column = the column containing the values to split
separator = the symbol used to perform the split
returns: a dataframe with each entry for the target column separated, with each element moved into a new row.
The values in the other columns are duplicated across the newly divided rows.
'''
def splitListToRows(row,row_accumulator,target_column,separator):
split_row = row[target_column].split(separator)
@HamedMP
HamedMP / sort_elements_all_axis_pandas.py
Last active February 27, 2018 12:01
Sort values in a Pandas DataFrame along all axis and get their index
# # Sort all elements in the `Pandas.Dataframe` object along all axis
import pandas as pd
df = pd.DataFrame([[1,2,3],
[3,-2,4],
[1,4,6]])
@HamedMP
HamedMP / web-fonts-asset-pipeline.md
Created May 6, 2017 17:01 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

Verifying that "hamedmp.id" is my Blockstack ID. https://onename.com/hamedmp
# We save out the graph to disk, and then call the const conversion
# routine.
checkpoint_state_name = "checkpoint_state"
input_graph_name = "input_graph.pb"
output_graph_name = "output_graph.pb"
input_graph_path = os.path.join(FLAGS.model_dir, input_graph_name)
input_saver_def_path = ""
input_binary = False
input_checkpoint_path = os.path.join(FLAGS.checkpoint_dir, 'saved_checkpoint') + "-0"
# This
tf.train.write_graph(sess.graph.as_graph_def(), FLAGS.model_dir, input_graph_name)
# or the following are the same as far as I understood, if you know the difference, let me know!
tf.train.write_graph(sess.graph_def, FLAGS.model_dir, input_graph_name)