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 / 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 / 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 / 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 / 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 / resizer.rb
Last active October 23, 2015 10:11
Resize Images Using MiniMagick While Preserving Subdirectory Structure
require 'fileutils'
require 'mini_magick'
# Get all files of any type within the 4x folder, within any subdirectory
sources = Dir.glob(File.join('**', '4x', '**', '*.png'))
# Create our target directories, and the size factor for that directory
target_directories = [
{ name: '2x', size_factor: 0.5 },
{ name: '1x', size_factor: 0.25 }
@obahareth
obahareth / speed_up_terminal_launch.sh
Last active March 17, 2024 00:30
Speed up launch of Terminal or iTerm 2
# Apparently Apple keeps system logs in this folder as .asl files. They're
# loaded into terminal sessions and can slow things down when there's a lot of
# them.
#
# Taken from:
# https://ariejan.net/2011/11/08/fixing-a-slow-starting-terminal-or-iterm2-on-mac-os-x/
sudo rm /private/var/log/asl/*.asl
@obahareth
obahareth / setup_os_x.sh
Last active October 22, 2023 12:57
A script to setup OS X with the apps and formulas I use.
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
# Tap sources we need
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew tap caskroom/versions
@obahareth
obahareth / 0_reuse_code.js
Created August 29, 2014 07:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/* Taken zigmob's (http://forums.macrumors.com/showthread.php?t=1742566) workaround a step further
And added some triggers to clean up these dodgy character combinations (ff, fi, fl).
Still crashes on initial message read but saves having to manually run the sql query eve time a message contains the character combinations */
-- Working well for me so far --
CREATE TRIGGER insert_Ff AFTER INSERT ON ZWAMESSAGE
BEGIN
UPDATE ZWAMESSAGE
SET ZTEXT = replace( ZTEXT, 'ff', 'f f')
WHERE ZWAMESSAGE.ZTEXT like '%ff%';
package com.deviant.security.shield;
public final class BuildConfig {
public static final String BUILD_TYPE = "debug";
public static final boolean DEBUG;
public static final String FLAVOR = "";
public static final String PACKAGE_NAME = "com.deviant.security.shield";
public static final int VERSION_CODE = 4;
public static final String VERSION_NAME = "2.2";