Skip to content

Instantly share code, notes, and snippets.

View ajmendez's full-sized avatar

Alexander Mendez ajmendez

View GitHub Profile
@chrisuehlinger
chrisuehlinger / the-algorithm.lua
Created January 19, 2024 21:47
Factorio self-expanding factory algorithm
-- Input Signal Key:
-- - red[some-item] - The number of that item in the logistic network,
-- negative if there is unsatisfied demand
-- - green[ore-type] - The amount of ore appearing on the resource scanner
-- Output Signal Key:
-- - out['red/signal-X'] - The X coordinate to survey
-- - out['red/signal-Y'] - The Y coordinate to survey
-- - out['red/signal-W'] - The width of the survey
-- - out['red/signal-H'] - The height of the survey
-- - out['construction-robot'] - The index of the blueprint to deploy
@jsomers
jsomers / websockets.md
Created September 27, 2018 12:50
Using websockets to easily build GUIs for Python programs

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:

high-priority

(Each row represents a "worker" in my model, and each rectangle represents a "task.")

@gabrieleara
gabrieleara / Dockerfile
Last active August 1, 2019 02:45
ROS Kinetic container used for my Robotics course
FROM ubuntu:xenial
RUN apt-get update && apt-get install -y software-properties-common
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list && \
apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
RUN apt-get update && \
apt-get install --no-install-recommends -y \
ros-kinetic-desktop-full \
@butuzov
butuzov / Installing Google Test on Mac.md
Last active April 4, 2024 10:08
Bash Script to install Google Test and Google Mock on Mac

Installing Google Test on Mac

One bash script to install google test (and mock) on your Mac. I assume you already had install cmake (if not, use brew - brew install cmake).

It use brew directories to store gmock and gtest.

gtest_installer.sh

#!/usr/bin/env bash
@aenniw
aenniw / display-buttons.py
Last active July 23, 2018 05:04
Waveshare 3.2' [Clone] Buttons handling
#!/usr/bin/env python
# sudo apt-get install python-dev python-rpi.gpio
import RPi.GPIO as GPIO
from time import sleep
import signal, os
buttons = [24, 23, 18]
@jrk
jrk / saveGmailAsPDF.js
Created October 4, 2016 02:12
Google Apps Script to save all Gmail messages matching a label/search query as PDFs to a chosen folder on Drive. via https://ctrlq.org/code/19117-save-gmail-as-pdf
function saveGmailAsPDF() {
var gmailLabels = "PDF";
var driveFolder = "My Gmail";
var threads = GmailApp.search("in:" + gmailLabels); // optional count limit:, 0, 5);
if (threads.length > 0) {
/* Google Drive folder where the Files would be saved */
@jsomers
jsomers / a-wotd-custom-word-list.md
Last active October 23, 2023 20:20
How to use a custom word list with OS X's "Word of the Day" screensaver

OS X's "Word of the Day" screensaver is a great way to passively learn words:

But I've always thought that its word list kind of stunk—it was full of obscure words that I could never really see myself using. I'd prefer something like Norman Schur's 1000 Most Important Words. What if you could plug your own word list into the screensaver?

On a rather obscure comment thread, someone explained where you might find the word list that Apple uses to power the screensaver. It is at /System/Library/Graphics/Quartz\ Composer\ Plug-Ins/WOTD.plugin/Contents/Resources/NOAD_wotd_list.txt. The file looks like this:

m_en_us1282510	quinsy
@jeamland
jeamland / gist:11284662
Created April 25, 2014 10:20
Bluetooth LE on OS X via Python
import select
import socket
import sys
import objc
from PyObjCTools import AppHelper
objc.loadBundle("CoreBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))
@pjobson
pjobson / remove_mcafee.md
Last active March 26, 2024 04:26
OSX McAfee Removal

Removal of McAfee from OSX

Note: This was written in 2015, it may be out of date now.

There are a lot of commands here which I use sudo if you don't know what you're doing with sudo, especially where I rm you can severely screw up your system.

There are many reasons which you would want to remove a piece of software such as McAfee, such as not wanting it to hammer your CPU during work hours which seems like primetime for a virus scan.

I intend this to be a living document, I have included suggestions from peoples' replies.

@vikrum
vikrum / firedns.js
Created January 14, 2013 18:56
A custom DNS server in NodeJS that saves off queries to Firebase so they can be retrieved later. Accompanying blog post: http://5f5.org/ruminations/dns-debugging-over-http.html
var crypto = require('crypto');
var dns = require('native-dns');
var rest = require('restler');
var server = dns.createServer();
server.on('request', function (request, response) {
var domain = request.question[0].name;
if(domain == 'webutils.flourishworks.com') {
// Don't log this because it can't be uniquely identified and subsequently retrieved