Skip to content

Instantly share code, notes, and snippets.

View ksmithbaylor's full-sized avatar
🐻
Sic 'em Bears!

Kevin Smith ksmithbaylor

🐻
Sic 'em Bears!
View GitHub Profile
@ksmithbaylor
ksmithbaylor / recint.rb
Last active January 5, 2022 16:30
Recursive Interest Calculator
#!/usr/bin/env ruby
# Copy this file as `recint` (or whatever you want) somewhere in your path and
# use it according to the usage notes below!
if ARGV.size < 4
puts "Usage: recint <collateral_factor> <supply_apr> <supply_bonus> <borrow_apr> <borrow_bonus>"
puts
puts " Example - To calculate the net interest on recursively lending this asset:"
puts
@ksmithbaylor
ksmithbaylor / foo.txt
Last active August 20, 2019 18:02
Testing
Hello world
asdf
; src/ui/helpers/antd.clj
(ns ui.helpers.antd)
(defn- has-dots? [sym]
(not (clojure.string/blank? (re-matches #".*\..*" (str sym)))))
(defn- to-property-access [name]
(symbol (str ".-" name)))
// Visit https://www.youtube.com/user/{username}/videos
// Keep scrolling down to trigger loading of all videos so they are all visible
// Run this to get the user's combined view count
function countViews() {
return Array.from(document.querySelectorAll('.yt-lockup-meta-info li'))
.map(li => li.textContent)
.filter(text => text.includes('views'))
.map(text => text.replace(',', '').replace(' views', ''))
.map(num => parseInt(num))
def factorial n
(1..n).reduce :* || 1
end
def snake_case_paths size
factorial(2 * size) / factorial(size) ** 2
end
puts snake_case_paths 10
var gulp = require('gulp');
function exec(command, env) {
require('child_process').execSync(command, {
stdio: 'inherit',
env: Object.assign({}, process.env, env, {
PATH: `./node_modules/.bin:${process.env.PATH}`
})
});
}

A fix for Ghost taking too long to authenticate due to some strange behavior in the bcrypt-nodejs library. This simply makes the passwords hash using Sha1 instead of bcrypt. Probably not the best/cleanest/most secure solution, but it works for most purposes.

INSTRUCTIONS:

  1. In the file core/server/models/user.js, replace the 'add' function with the contents of user-add.js.
  2. In the same file, replace the 'check' function with the contents of user-check.js.
  3. At the top, add the line 'sha1 = require('sha1'),' in the require section.
  4. In package.json, add the following line in the 'dependencies' section: "sha1": "1.1.0",
  5. You can remove references to the bcrypt library if you want. These are the only two places it is used.
  6. Remove all users from the databases in content/data/ by executing 'delete from users;' on the sqlite db (or delete the whole database if there's not anything important there yet).
@ksmithbaylor
ksmithbaylor / gist:3180048
Created July 26, 2012 03:20
Troubleshooting the jruby-rawr-swt-helloworld template
I actually just fixed it! Here's what was happening, in case the information is useful to you.
I am using OS X 10.7.4, rawr 1.4.5, and jruby 1.6.7.
After doing a git pull, I did the following:
$ ./bin/build-osx-app.sh
$ open package/osx/jruby-rawr-swt-helloworld.app
The app then launches for a split second and then quits.
// Splitting out conditionals makes things more readable
const someCondition = (something.is == true)
// Ternary expressions are really useful for assigning values in an immutable
// way. This avoids setting `a` to something as a "default", and then
// conditionally setting it to something else.
const a = someCondition ?
oneThing :
anotherThing;
var gulp = require('gulp');
var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var uglifyify = require('uglifyify');
var source = require('vinyl-source-stream');
var chalk = require('chalk');
var inputDir = './src/';
var outputDir = './dist/';