Skip to content

Instantly share code, notes, and snippets.

View jrmanrique's full-sized avatar

James Manrique jrmanrique

View GitHub Profile
@jrmanrique
jrmanrique / sentiment.py
Created July 3, 2025 17:37
Python script for determining polarity of a Korean text
import re
import csv
import math
import pandas as pd
from konlpy.tag import Komoran
class PolarityDictionary:
"""
Manages the loading and lookup of polarity scores from a dictionary file.
@jrmanrique
jrmanrique / Emojis.ahk
Last active September 23, 2022 19:19
AutoHotkey hotstring replacements for emojis using Discord/Joypixel shortcodes.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Hotstring EndChars :
#Hotstring O
; Source: https://emojibase.dev/docs/shortcodes
:::interrobang::⁉
@jrmanrique
jrmanrique / sudoku.py
Created February 15, 2020 03:30
Sudoku solver using backtracking (Source: Computerphile).
def possible(y, x, n):
global grid
for i in range(0, 9):
if grid[y][i] == n:
return False
for i in range(0, 9):
if grid[i][x] == n:
return False
x0 = (x // 3) * 3
y0 = (y // 3) * 3
@jrmanrique
jrmanrique / lcs.lua
Last active November 1, 2018 20:37
Test Lua implementation of Longest Common Subsequence.
local function lcsRecursive(a, b)
if #a == 0 or #b == 0 then
return ''
elseif a:sub(-1, -1) == b:sub(-1, -1) then
return lcs(a:sub(1, -2), b:sub(1, -2)) .. a:sub(-1, -1)
else
local a_sub = lcs(a, b:sub(1, -2))
local b_sub = lcs(a:sub(1, -2), b)
if #a_sub > #b_sub then
@jrmanrique
jrmanrique / genetic_world.py
Created April 29, 2018 08:50
Genetic algorithm script to evolve Hello World in Python.
#! usr/bin/env python3
import random
from itertools import combinations
from string import printable as ALPHA
def generate_seed(popsize, target):
return [''.join(random.sample(ALPHA, len(target))) for _ in range(popsize)]
@jrmanrique
jrmanrique / word_factory.py
Last active April 19, 2018 02:00
Test Python implementation of Word Factory solver.
class WordFactory:
def __init__(self, board):
self.board = board
self.width = len(board[0])
self.height = len(board)
def get_neighbors(self, r, c):
MOVES = {
'U': (r - 1, c),
'D': (r + 1, c),
@jrmanrique
jrmanrique / coin_change.py
Created April 10, 2018 07:34
Test Python implementation of coin change problem.
def coinchange(n, coins):
ways = []
stack = [[n, [], coins]]
while stack:
rem, change, coins = stack.pop()
if rem == 0:
ways.append(change)
continue
sort = list(filter(lambda x: x <= rem, coins))
for coin in sort:
@jrmanrique
jrmanrique / word_search.py
Last active April 10, 2018 07:39
Test Python implementation of word search.
def stringify_items(lst, reverse=False):
if reverse:
return [''.join(reversed(item)) for item in lst]
return [''.join(item) for item in lst]
def flip_grid(grid):
return [[grid[r][c] for r in range(len(grid))] for c in range(len(grid[0]))]
@jrmanrique
jrmanrique / n_puzzle.py
Last active March 15, 2018 23:02
Test Python implementation of n-puzzle solution.
from copy import deepcopy
from math import log10
import random
import sys
import time
class Puzzle():