Skip to content

Instantly share code, notes, and snippets.

View meesterdude's full-sized avatar
🎯
Building something cool

Russell meesterdude

🎯
Building something cool
View GitHub Profile
@meesterdude
meesterdude / total_pairs.rb
Created January 3, 2022 17:00
problem: find all pairs of numbers in a range of 1..n that add up to n
# $ time ruby total_pairs.rb
# there are 999 pairs that create 2000 between 1 and 2000
# real 0m0.129s
# user 0m0.074s
# sys 0m0.046s
max_size = 2000
numbers = (1..max_size).to_a
@meesterdude
meesterdude / gist:403319a079828497bff7c4f52e7451d3
Last active April 30, 2021 09:38
installing handlebars-helpers in ghost
// installing handlebars-helpers for V3 of ghost platform (current as of version 3.37)
// in your ghost install directory, run `yarn add handlebars-helpers` to install the package
// in your project directory of versions/YOUR_VERSION/core/frontend/helpers/index.js
// change L4 to be
// const helpers = require('handlebars-helpers')();
// on production server, edit versions/YOUR_VERSION/node_modules/gscan/lib/spec.js
// remove the method body but keep the theme return value; without this change, themes using custom helpers will fail gscan
function elementNamer(element)
{var name = element.nodeName + " class='" + element.className + "' id='" + element.id + "'"return name;};
@meesterdude
meesterdude / README.md
Last active March 23, 2017 17:42
emoji_spec is a microgem to put emoji in your rspec output.

Emoji Spec

results Tired of the same, dull rspec output? liven it up with some emoji!

Below are the sets presently available, and their corresponding id. if you don't set an ID, one will be randomly chosen every run. Emoji icons may not render in certain terminals.

(pass, fail, pending)

emoji

@meesterdude
meesterdude / gist:5063477
Created March 1, 2013 09:24
chef_client output
[2013-03-01T10:21:52+01:00] INFO: Storing updated cookbooks/openssl/metadata.json in the cache.
[2013-03-01T10:22:02+01:00] INFO: Storing updated cookbooks/openssl/metadata.rb in the cache.
[2013-03-01T10:22:12+01:00] INFO: Storing updated cookbooks/openssl/README.md in the cache.
[2013-03-01T10:22:22+01:00] INFO: Storing updated cookbooks/iptables/recipes/chef.rb in the cache.
[2013-03-01T10:22:32+01:00] INFO: Storing updated cookbooks/iptables/recipes/default.rb in the cache.
[2013-03-01T10:22:42+01:00] INFO: Storing updated cookbooks/iptables/recipes/statsd.rb in the cache.
================================================================================
Error Syncing Cookbooks:
@meesterdude
meesterdude / gist:4982567
Created February 19, 2013 02:21
bash_profile
PS1="[\u@\h] \w\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/(\1)/')\$(git stash list 2> /dev/null | grep -e 'stash' | wc -l | sed 's/^ *//' | sed -n 's/\([1-9]\)/\{stashed:\1\}/p')\$ "
=> [ruru64@ruru64s-iMac] ~/adev/creativebug(master){stashed:1}$
or if no git..
=> [ruru64@ruru64s-iMac] ~/adev$
@meesterdude
meesterdude / _before.rb
Last active December 12, 2015 09:59
before and after comments. Note the changes in clarity and depth of understanding.
require "semantic"
require "pp"
corpus = Semantic::Corpus.new([], :transforms => [:LSA])
Dir.glob("/tmp/some_texts/*.txt").each do |file|
corpus << Semantic::Document.new(open(file), :name => File.basename(file))
end
corpus.build_index
@meesterdude
meesterdude / gist:4380860
Created December 26, 2012 15:12
solr console output
[ruru64@ruru64s-iMac] ~/adev/creativebug(resend_gift)$ solr ~/adev/creativebug/solr/
2012-12-26 10:11:40.998:INFO:oejs.Server:jetty-8.1.2.v20120308
2012-12-26 10:11:41.013:INFO:oejdp.ScanningAppProvider:Deployment monitor /usr/local/Cellar/solr/4.0.0/libexec/example/contexts at interval 0
2012-12-26 10:11:41.017:INFO:oejd.DeploymentManager:Deployable added: /usr/local/Cellar/solr/4.0.0/libexec/example/contexts/solr.xml
2012-12-26 10:11:41.675:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /solr, did not find org.apache.jasper.servlet.JspServlet
2012-12-26 10:11:41.714:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/solr,file:/usr/local/Cellar/solr/4.0.0/libexec/example/solr-webapp/webapp/},/usr/local/Cellar/solr/4.0.0/libexec/example/webapps/solr.war
2012-12-26 10:11:41.714:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/solr,file:/usr/local/Cellar/solr/4.0.0/libexec/example/solr-webapp/webapp/},/usr/local/Cellar/solr/4.0.0/libexec/example/webapps/solr.war
Dec 26, 2012 10:11:41 AM
@meesterdude
meesterdude / simpler-rails.sublime-project
Created December 19, 2012 19:19
Sublime Text 2 Project file for day to day Ruby on Rails work.
{
"folders":
[
{
"path": "/",
"folder_exclude_patterns": [
"app/mailers",
"app/helpers",
"app/assets/images",
@meesterdude
meesterdude / image_finder.rb
Created October 1, 2012 05:07
Automatically fixes missing images by downloading from live site, if present.
# check pages for missing images. if present on live site, pull down to same path.
# in app controller
def correct_missing_file
return unless Rails.env == 'development'
tpath = params[:file].split('?').first
fpath = tpath.split('/')
fpath.pop
fpath = fpath.join('/')
uri = URI('http://www.creativebug.com' + tpath)