Skip to content

Instantly share code, notes, and snippets.

Avatar

Sophia Li srli

View GitHub Profile
@srli
srli / CMakeLists.txt
Created Oct 17, 2019
Modified CMakeLists.txt for v1.91 h-encore build
View CMakeLists.txt
cmake_minimum_required(VERSION 3.9)
find_package(Threads)
find_package(LibXml2 REQUIRED)
if (MINGW)
add_definitions(-mno-ms-bitfields)
endif ()
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS)
@srli
srli / caesar_cipher.py
Created Jun 26, 2018
Sample encoding and decoding caesar cipher generator
View caesar_cipher.py
import string
import random
from collections import Counter
"""
An easy implementation of the Caesar cipher
Written by Sophie Li, 2018
http://blog.justsophie.com/caesar-cipher-generator/
"""
@srli
srli / stt_py3.py
Created Jun 25, 2018
Speech to text with PocketSphinx for Python3
View stt_py3.py
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import os
import pyaudio
import wave
import audioop
from collections import deque
import time
import math
@srli
srli / astar_destruct_pseudo.py
Created Mar 9, 2018
A* with path destruction
View astar_destruct_pseudo.py
def solve(self):
# Add starting cell to open heap queue
heapq.heappush(self.opened, (self.start.f, self.start))
while len(self.opened):
# Pop cell from heap queue
f, cell = heapq.heappop(self.opened)
# Add cell to closed list so we don't process it twice
self.closed.add(cell)
@srli
srli / astar_pseudo.py
Created Mar 9, 2018
Pseudo code for an A* path solver
View astar_pseudo.py
#!/usr/bin/python
import heapq
class Cell(object):
def __init__(self, x, y, is_wall):
self.reachable = not is_wall
self.x = x
self.y = y
self.parent = None
View ros_smile_detector.py
#!/usr/bin/python
"""
This code is part of ros package that subscribes to an image topic
and detects smiles found in the image. Results are then republished to a ros
image topic.
This node is an example of how I prefer to write my ROS nodes, as a single
class with a run function.
@srli
srli / ros_simple_sample.py
Last active Dec 17, 2017
Simple implmentation of a ros node in python
View ros_simple_sample.py
#!/usr/bin/python
import rospy
from std_msgs.msg import String
from sensor_msgs.msg import Image
import cv2
import numpy as np
class FaceFinder:
def __init__(self):
@srli
srli / image_steganography.py
Created Mar 5, 2017
Hide text in images using steganography!
View image_steganography.py
"""A program that encodes and decodes hidden messages in images through LSB steganography"""
from PIL import Image, ImageFont, ImageDraw
import textwrap
def decode_image(file_location="images/encoded_sample.png"):
"""Decodes the hidden message in an image
file_location: the location of the image file to decode. By default is the provided encoded image in the images folder
"""
encoded_image = Image.open(file_location)
@srli
srli / tour.py
Last active Feb 9, 2017
Better Knights Tour w/ visualizer
View tour.py
#!/usr/bin/env python
"""
This code generates the path required for a knight's tour
around a chessboard with user-specified dimensions
Written by Sophie Li, 2017
http://blog.justsophie.com/algorithm-for-knights-tour-in-python/
"""
import sys
@srli
srli / spi_tester.c
Last active Oct 26, 2016
Updated spi_tester.c
View spi_tester.c
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: