Skip to content

Instantly share code, notes, and snippets.

@scottserok
scottserok / ruby-pre-commit
Last active March 20, 2020 13:55
A Git pre-commit hook for Ruby projects that validates syntax, looks for any lingering puts or byebug statements.
#!/bin/sh
#
# A pre-commit hook for Ruby projects.
#
# == Installation
#
# From within a Ruby project directory in your terminal:
#
# curl https://gist.github.com/scottserok/0838cdda3f07a6eb30b44ee475b1e57c/raw/fe00beb4a69c529c6391def23a4dc61e2711c2cb/ruby-pre-commit >> .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
@lawso017
lawso017 / mentionable_trix.js.coffee
Last active July 6, 2022 10:13
@mentions with trix-editor and selectize.js
window.addEventListener "trix-initialize", (e) =>
Utility.TrixMentions.prepare($(e.target))
@PimDeWitte
PimDeWitte / Efficient Bad Word Filter
Last active February 11, 2024 14:57
Simple profanity filter written in Java for efficient comparison. Runtime grows based on string input, not list size.
static Map<String, String[]> words = new HashMap<>();
static int largestWordLength = 0;
public static void loadConfigs() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new URL("https://docs.google.com/spreadsheets/d/1hIEi2YG3ydav1E06Bzf2mQbGZ12kh2fe4ISgLg_UBuM/export?format=csv").openConnection().getInputStream()));
String line = "";
int counter = 0;
while((line = reader.readLine()) != null) {
@carolineschnapp
carolineschnapp / gist:5397337
Last active January 20, 2023 10:11
Sample JavaScript file added with ScriptTag resource. This sample file is meant to teach best practices. Your app will load jQuery if it's not defined. Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@davidbgk
davidbgk / server.py
Created October 25, 2011 01:37
A very simple HTTP server in Python using wsgiref.simple_server
from cgi import parse_qs
from wsgiref.simple_server import make_server
def simple_app(environ, start_response):
status = '200 OK'
headers = [('Content-Type', 'text/plain')]
start_response(status, headers)
if environ['REQUEST_METHOD'] == 'POST':
request_body_size = int(environ.get('CONTENT_LENGTH', 0))
request_body = environ['wsgi.input'].read(request_body_size)