Skip to content

Instantly share code, notes, and snippets.

Joshua Paling joshuapaling

Block or report user

Report or block joshuapaling

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joshuapaling
joshuapaling / upgrade.sh
Created Jun 5, 2019
upgrade packages only if your tests pass
View upgrade.sh
declare -a packages=(
"node-sass"
"react-qr-reader"
"moment-timezone"
"qs"
)
for i in "${packages[@]}"
do
View gist:e57b59aab5afd1257ed56232e5016a97
# Here's the code that's a candidate for refactor, I'm just trying
# to get a sense of if dry monads are a good fit or if this isn't really
# complex or nested-ifs enough to make it really worth it.
# I'm more just checking out dry monads for fun (and potential profit!) rather than
# trying to solve an immediate pain point.
#
# Context is: it's an Employee Relationship Management system.
# Employees earn points for doing things. Periodically, the company holds
# a "flash sale" where they can redeem those points for rewards.
#
View gist:a2008d361d7c62ad1e4d3766f81dd978
"the products actually already live in our point of sale system"
Does "live" in this context rhyme with "div" or "dive"? Let's call the "div" version of it "liv" to clarify.
This makes sense: "the products actually already liv in our point of sale system". It means that there are many products, and the place they live/belong is "in our point of sale system".
This also makes sense: "the product's actually already live in our point of sale system". It means there is one product, and it's already "live" (aka deployed or whatever) in our point of sale system.
The rules are:
- NEVER have an apostrophe for plurals
View code_learning
Answer to https://twitter.com/saronyitbarek/status/760853206205292545
If you code (or learning!), do you use a journal/notebook/todo list for code-related tasks/planning?
I always have scrap paper on my desk. I intentially make it scrap, already printed on one side paper, so I don't feel even a tiny bit bad about using it. I'll write ToDos on it when I want them to physically be right in front of me till they get done. I'll also doodle on it when struggling with a concept, when that can help.
I use digital flash cards. When I come across a term I don't know, but want to, I put it in there. I use http://ankisrs.net/, specifically. I could give a whole talk on digtal flash cards, how good they are, and how to use them effectively. TL;DR: They are SO good. To be effective, go through them every day. Keem them short - a word or two on the front, a short sentence or 2, max, on the back. Be selective about which things you want to commit to memory - you have finite space. Focus on concepts, not language syntax.
View romans.rb
class Fixnum
def to_roman
# Roman numeral problem described in Sandi Metz's newsletter:
# http://us3.campaign-archive2.com/?u=1090565ccff48ac602d0a84b4&id=24e2bac263&e=6df8a5006fa
# You don't need conditionals, and you don't need two steps either.
# The trick: there's nothing special about the subtractive cases.
# Treat them as a single numeral that just happens to be two
# characters rather than one.
all_numerals = {
'I' => 1,
View CSS Positioning
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.box {
width: 300px;
height: 300px;
float: left;
border: 9px solid red;
@joshuapaling
joshuapaling / rename_css_scss.rake
Created Mar 31, 2015
Rake task to rename .css.scss files to just .scss (the long extension is deprecated)
View rename_css_scss.rake
task :rename_css_scss do
files = Rake::FileList["app/assets/stylesheets/**/*.css.scss"]
files.each do |f|
new_name = f.gsub(/\.css\.scss/, '.scss')
sh "mv #{f} #{new_name}"
end
end
@joshuapaling
joshuapaling / capistrano log
Last active Aug 29, 2015
BIG Vault Capistrano Deployment
View capistrano log
joshuapaling: /Applications/MAMP/htdocs/BIG/Employee_Management_Website/www
->cap staging deploy
INFO[516fb1c3] Running /usr/bin/env mkdir -p /tmp/the_big_vault_staging/ on XXX.XXX.XXX.XXX
DEBUG[516fb1c3] Command: /usr/bin/env mkdir -p /tmp/the_big_vault_staging/
INFO[516fb1c3] Finished in 0.501 seconds with exit status 0 (successful).
DEBUGUploading /tmp/the_big_vault_staging/git-ssh.sh 0.0%
INFOUploading /tmp/the_big_vault_staging/git-ssh.sh 100.0%
INFO[7f2c25f1] Running /usr/bin/env chmod +x /tmp/the_big_vault_staging/git-ssh.sh on XXX.XXX.XXX.XXX
DEBUG[7f2c25f1] Command: /usr/bin/env chmod +x /tmp/the_big_vault_staging/git-ssh.sh
INFO[7f2c25f1] Finished in 0.069 seconds with exit status 0 (successful).
View gist:14b24e6210abdb6eee53
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
staging 1709 0.0 0.0 10772 1404 ? S 10:14 0:00 bash -c cd '/home/staging/public_html/releases/20141013231355/app/Vendor/kamisama/php-resque-ex/'; VERBOSE=true QUEUE='default' PIDFILE='/home/staging/public_html/releases/20141013231355/app/Plugin/CakeResque/t
staging 1710 0.0 0.7 161472 15492 ? S 10:14 0:00 php ./bin/resque
staging 3437 0.0 0.0 10772 1404 ? S 10:17 0:00 bash -c cd '/home/staging/public_html/releases/20141013231718/app/Vendor/kamisama/php-resque-ex/'; VERBOSE=true QUEUE='default' PIDFILE='/home/staging/public_html/releases/20141013231718/app/Plugin/CakeResque/t
staging 3438 0.0 0.7 161496 15468 ? S 10:17 0:00 php ./bin/resque
staging 4803 0.0 0.0 10772 1404 ? S 10:19 0:00 bash -c cd '/home/staging/public_html/releases/20141013231903/app/Vendor/kamisama/php-resque-ex/'; VERBOSE=true QUEUE='default' PIDFILE='/home/staging/p
@joshuapaling
joshuapaling / gist:cb683d8ec6ecab077c19
Last active Aug 29, 2015
htaccess caching, gzip compression, and blocking bots / scrapers
View gist:cb683d8ec6ecab077c19
<IfModule mod_deflate.c>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
You can’t perform that action at this time.