Skip to content

Instantly share code, notes, and snippets.

View kevinmarx's full-sized avatar

Kevin Marx kevinmarx

  • Microsoft
  • Minneapolis
  • 16:00 (UTC -06:00)
View GitHub Profile
@brycesch
brycesch / mysql_string_sanitizer.rb
Created September 6, 2017 16:30
String sanitizer for MySQL's default utf8 encoding - You can avoid needing to use this by switching to utf8mb4
class MysqlStringSanitizer
def self.sanitize(str)
str = str.force_encoding('utf-8').encode
clean_text = ""
# emoticons 1F601 - 1F64F
regex = /[\u{1f600}-\u{1f64f}]/
clean_text = str.gsub regex, ''
#dingbats 2702 - 27B0
@supinf
supinf / s3-invalidation.js
Last active January 7, 2023 08:57
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;
@stuartnelson3
stuartnelson3 / killall
Created January 21, 2014 16:17
kill -9 everything
#!bin/bash
ps aux |
grep $1 |
ruby -ne 'print $_.split[1]+"\n"' |
xargs kill -9
@branneman
branneman / better-nodejs-require-paths.md
Last active October 18, 2024 20:29
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@sterlingwes
sterlingwes / tourney.html
Created December 3, 2012 23:42
Tournament Bracket Generator (Javascript + CSS, no tables)
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)