Skip to content

Instantly share code, notes, and snippets.

fuzzy logic

Josh Goodall inopinatus

fuzzy logic
View GitHub Profile
View DirectUpload.vue
<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser')
i {{label}}
input(type='file' :multiple='multiple' ref='input' style='display: none')
devloco / download-pdf.js
Last active Jul 27, 2022
Download a PDF via POST with Fetch API
View download-pdf.js
let fnGetFileNameFromContentDispostionHeader = function (header) {
let contentDispostion = header.split(';');
const fileNameToken = `filename*=UTF-8''`;
let fileName = 'downloaded.pdf';
for (let thisValue of contentDispostion) {
if (thisValue.trim().indexOf(fileNameToken) === 0) {
fileName = decodeURIComponent(thisValue.trim().replace(fileNameToken, ''));
andyyou /
Last active Aug 9, 2022
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
jrunning / base58.rb
Last active Nov 17, 2020
UUID to Base 58 in Ruby
View base58.rb
# base58_to_int and int_to_base58 loosely based on base58 gem by Douglas F. Shearer
ALPHABET = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ".chars
def base58_to_int(base58_val)
.reduce(0) do |int_val, (char, index)|
vgeshel / function.js
Last active Feb 9, 2022
AWS Lambda function for forwarding SNS notifications to Slack
View function.js
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = '';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
ryndel /
Last active Nov 2, 2017
Float label css only solution

Float label

A web component that create a CSS-only floating label for input tags


The syntax for generating a float-label input is as follows:

View big_decimal_inspect_override.rb
class BigDecimal
def inspect
"#<BigDecimal: #{to_s}>"
inopinatus / hstore_accessor.rb
Last active Feb 22, 2019
hstore accessor class method for AR
View hstore_accessor.rb
# include from an initializer
module HstoreAccessor
def self.included(base)
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
jbarnette / stupid.rb
Created Mar 22, 2012
Incredibly stupid Ruby tricks. Please add more.
View stupid.rb
# The worst possible way to memoize something.
class X
def value
@value = really_expensive_operation
def value; @value end
steveclarke / gist:1411146
Created Nov 30, 2011
Git: Setting up a Remote Repository and Doing Initial Push
View gist:1411146

Setup remote repository:

mkdir my_project.git
cd my_project.git
git init --bare

On local machine:

cd my_project