Skip to content

Instantly share code, notes, and snippets.

View obahareth's full-sized avatar
🧉
In the Zone

Omar Bahareth obahareth

🧉
In the Zone
View GitHub Profile
@obahareth
obahareth / Playing with NLTK and Stanford NER.md
Last active October 23, 2020 11:04
Playing around with NER using Stanford's NER and NLTK

Description

I'm playing around with NER (Named Entity Recognition) and the basic idea is that I can pass in multiple paragraphs and get recognized entities in a nicely formatted dictionary of lists.

I might look into running the Java servelet that stanford made to increase performance.

Example Output

{
  'organizations': ['Wall', 'Street', 'Journal', 'Apple', 'Inc.', 'Apple', 'TV', 'Apple', 'Mac', 'App', 'Store', 'Apple', 'Computer', ',', 'Inc.', 'Apple', 'Inc.', 'National', 'Hockey', 'League', 'Montreal', 'Canadiens', 'Stanley', 'Cups', 'Toronto', 'Blue', 'Jays'],
 'locations': ['France', 'Cupertino', 'California'],
@obahareth
obahareth / parse_and_index_pdf.rb
Last active January 3, 2021 13:47
Using Tika through Yomu to turn a PDF into nicely formatted HTML, parsing the HTML using Nokogiri, and then using Algolia to get the PDF contents indexed and searchable. See https://medium.com/@obahareth/indexing-pdf-or-other-file-contents-for-searching-b2499c23568f
require "nokogiri"
require "yomu"
require "algoliasearch"
def invalid_paragraph?(str)
disallowed_strings = [ "", " ", "\n", " \n" ]
disallowed_strings.include?(str)
end
def get_pdf_paragraphs(filename)
@obahareth
obahareth / Gemfile
Created January 26, 2017 21:05 — forked from goncalvesjoao/Gemfile
Changes you need to make in order to make Devise use JWT Header Authentication
# Add the "https://github.com/jwt/ruby-jwt" gem to your "Gemfile"
gem 'jwt'
@obahareth
obahareth / README.md
Created June 11, 2017 10:29
GitHub GraphQL API Starred Repositories With Pagination

GitHub GraphQL API Starred Repositories Examples With Pagination

You can play with the GraphQL API live here. It's pretty nice and has autocompletion based on the GraphQL schema.

The first example gets your first 3 starred repos, the cursor values can be used for pagination.

Here's an example response from the first query:

{
@obahareth
obahareth / old_algolia_delete_by_query.rb
Created August 25, 2017 15:51
Old version of Algolia's Ruby Client delete_by_query method
#
# Delete all objects matching a query
#
# @param query the query string
# @param params the optional query parameters
#
def delete_by_query(query, params = nil)
raise ArgumentError.new('query cannot be nil, use the `clear` method to wipe the entire index') if query.nil? && params.nil?
params ||= {}
params.delete(:hitsPerPage)

Keybase proof

I hereby claim:

  • I am obahareth on github.
  • I am obahareth (https://keybase.io/obahareth) on keybase.
  • I have a public key whose fingerprint is CAB8 5952 5444 8B43 F4F2 0615 BFFD 1B8F 549C C61D

To claim this, I am signing this object:

{
# The first 2 films, after a given cursor value
allFilms(first: 2, after: "YXJyYXljb25uZWN0aW9uOjA=") {
# An edge is an entry in a "list"
edges {
# Get a cursor value for each "edge"
# Used for pagination, in combination with filters like
# before and after.
@obahareth
obahareth / dark.md
Created December 25, 2018 10:55 — forked from a7madgamal/dark.md
Dark mode for Slack on MacOS
  1. Close slack
  2. Open this file /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
  3. Append this to it
document.addEventListener('DOMContentLoaded', function() {
 $.ajax({
   url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
   success: function(css) {
 $("").appendTo('head').html(css);
@obahareth
obahareth / mac-keyboard-shortcuts-for-windows.ahk
Created May 11, 2019 15:03
I recently begun migrating from macOS to Windows and needed to get the same keyboard shortcuts my muscle memory is used to working on Windows. This is an amalgamation of many AutoHotkey scripts I found online.
;-----------------------------------------
; Make Windows keyboard behave like Mac
;=========================================
; --------------------------------------------------------------
; NOTES
; --------------------------------------------------------------
; ! = ALT
; ^ = CTRL
; + = SHIFT
@obahareth
obahareth / config.yml
Created May 13, 2019 18:38
My Fusuma config
swipe:
2:
left:
command: 'xdotool key alt+Left'
right:
command: 'xdotool key alt+Right'
3:
left:
command: 'xdotool key alt+Left'
right: