Skip to content

Instantly share code, notes, and snippets.

View jonniesweb's full-sized avatar
💭
hacking

Jon Simpson jonniesweb

💭
hacking
View GitHub Profile
@jonniesweb
jonniesweb / FixedBuffer.java
Created March 15, 2015 02:33
A quick and dirty fixed buffer to determine medians of a set of numbers
/**
* A fixed buffer that determines the median of its values. Very inefficient for
* high buffer lengths.
*
* Here you go Matt!
*/
import java.util.ArrayList;
import java.util.Collections;
@jonniesweb
jonniesweb / docker-compose.yml
Last active November 21, 2015 19:27
A simple configuration for Hubot
hubot:
image: registry:5000/zdirect/zbot
ports:
- "8081:8080"
links:
- redis
restart: always
environment:
REDIS_URL: tcp://redis:6379
@jonniesweb
jonniesweb / deploy.sh
Last active November 22, 2015 00:39
A simple deploy/update script for a docker-compose project
#!/bin/bash
cd /to/corect/dir/
docker-compose up -d
@jonniesweb
jonniesweb / changelog.xml
Created March 26, 2016 02:56
Liquibase configuration for a FULLTEXT index on a mediumtext field
<!-- Liquibase change log file. Note the "comment(255)" which allows the index to exist on a mediumtext -->
<createIndex indexName="idx_fulltext_comment" tableName="comment">
<column name="comment(255)"/>
</createIndex>
@jonniesweb
jonniesweb / changelog.xml
Created March 27, 2016 22:34
Liquibase configuration for setting the MySql engine and charset for each table
<changeSet>
<createTable>
...
</createTable>
<!-- Place this <modifySql> block at the bottom of each table definition. Search and replace works really well. -->
<modifySql dbms="mysql">
<append value="ENGINE=INNODB DEFAULT CHARSET=UTF8"/>
</modifySql>
</changeSet>
@jonniesweb
jonniesweb / Dockerfile.cilk
Last active October 6, 2016 16:38
A simple dockerfile for developing and running Cilk applications
# Ubuntu 16.04 has the GCC cilk compiler built in to version 5.4, we just need to install it
FROM ubuntu:16.04
# install g++ and vim
RUN apt-get update && \
apt-get install -y g++ vim
@jonniesweb
jonniesweb / webhook_refresh_controller.rb
Created February 12, 2017 03:34
Code for a shopify_app controller to synchronize the needed webhooks with the Shopify API
class WebhookRefreshController < ShopifyApp::AuthenticatedController
def index
webhooks = ShopifyApp.configuration.webhooks
ShopifyApp::WebhooksManager.new(webhooks).create_webhooks
end
end
@jonniesweb
jonniesweb / code.java
Last active June 11, 2017 20:09
Example optimization of implementing existing Java business logic into SQL update statements. The example is of code that moves an 'item' to the correct next 'step' based on if the item is associated to a 'click' of a 'link'.
Step process(Item item, LinkStep step, DataAccess access) {
boolean result = false;
if (step.getLink() == null) {
// item associated with any link being clicked
result = access.userClickedOnAnyLink();
} else {
// item associated with a specific link being clicked
@jonniesweb
jonniesweb / compiler.rb
Created March 12, 2018 14:48
Destroy All Software - Build a Compiler
class Tokenizer
TOKEN_TYPES = [
[:def, /\bdef\b/],
[:end, /\bend\b/],
[:identifier, /\b[a-zA-Z]+\b/],
[:integer, /\b[0-9]+\b/],
[:oparen, /\(/],
[:cparen, /\)/],
[:comma, /,/]
]
@jonniesweb
jonniesweb / lazy_resolver.rb
Created March 23, 2018 13:36
Lazily Resolved GraphQL
# app/graphql/ticket_resolver.rb
class TicketResolver
def initialize(id)
@id = id
end
def ticket
if @ticket
@ticket
else