Skip to content

Instantly share code, notes, and snippets.

@wosephjeber
wosephjeber / apache_setup.md
Last active September 22, 2015 21:05
Opportunity dev environment setup

##Apache setup

Apache is included with OSX. The configuration files are found at /etc/apache2/. We'll be editing two files: /etc/apache2/httpd.conf and /etc/apache2/extras/httpd-vhosts.conf.

####httpd.conf

First, we need to enable some modules. Uncomment (remove the #) the lines that contain #LoadModule php5_module libexec/apache2/libphp5.so and LoadModule rewrite_module libexec/apache2/mod_rewrite.so.

Just a bit below that line, you'll see this:

@wosephjeber
wosephjeber / add_user.sh
Last active March 31, 2018 22:41
Giving new users SSH access
# 1. Start by ssh-ing into the server
ssh opportunity.org # or whatever server you need to access
# 2. Once in the server add a user with whatever username you'd like. You must use the sudo command unless you're logged in as root.
sudo adduser {username}
sudo adduser {username} sudo # to add user to sudo group
# 3. Change into the new users directory. /home contains all the users on the system.
cd /home/{username}
@wosephjeber
wosephjeber / local_modx_setup.md
Last active May 9, 2018 15:29
Instructions for setting up a local copy of our MODX installation

Here's an outline of the instructions for creating a local dev copy of our MODX installation:

####1. Package and download files from server You'll want to tar and gzip the files on the server for two reasons. First and foremost, it will be faster when you download the files via FTP. Downloading one 100mb file is significantly faster than downloading one hundred 1mb files. Secondly, we want to avoid the potential of messing with hidden files and permissions/ownership.

Use the tar command with gzip enabled: tar -czvf path_to_target path_to_source. For example, to package up the assets directory, you might run tar -czvf backup/assets.tar.gz assets/. This will package and compress the assets directory and save it as a .tar.gz file in the backup directory. You can then download that file via Transmit or another FTP client.

####2. Dump production database and import to local database Use Sequel Pro to export the production database and import it locally. You can name the local database whatever you'd

@wosephjeber
wosephjeber / name_form.jsx
Last active October 6, 2019 22:19
Render Props vs Higher Order Components
import React, { Component } from 'react'
import PropTypes from 'prop-types'
class NameForm extends Component {
constructor() {
super()
this.state = { value: '' }
}
@wosephjeber
wosephjeber / getAllColors.js
Created October 15, 2020 22:19
Quick and dirty function for scraping colors from web page
function getAllColors() {
const COLOR_CONTAINING_PROPERTIES = ["backgroundColor", "borderTopColor", "borderRightColor", "borderLeftColor", "borderBottomColor", "color"]
let colors = []
let elements = document.querySelectorAll('*')
elements.forEach(element => {
const styles = window.getComputedStyle(element)
COLOR_CONTAINING_PROPERTIES.forEach(property => {
@wosephjeber
wosephjeber / upgrade_postgres
Last active November 26, 2020 23:03
Upgrade from postgres 9.6.2 to 10.5 on OSX
## Following these commands should upgrade and migrate your existing database.
## This is an example of going from 9.6.2 to 10.5 on OSX.
## Be sure to update any version numbers based on the versions you're upgrading from and to.
## Adapted from https://stackoverflow.com/questions/24379373/how-to-upgrade-postgresql-from-version-9-6-to-version-10-1-without-losing-data
## Backup your database, just in case (replace databasename with your actual DB name)
pg_dump databasename > ~/Desktop/dev_dump
## Stop postgres
@wosephjeber
wosephjeber / get_all_regex_matches.ts
Created March 17, 2023 13:03
Get all regex matches in a string
function getAllRegexMatches(regex: RegExp, string: string) {
if (regex.constructor !== RegExp) {
throw new Error('not RegExp');
}
const matches = [];
let match = regex.exec(string);
if (regex.global) {
while (match) {
@wosephjeber
wosephjeber / find_and_kill_process.sh
Last active July 2, 2023 08:02
Find and kill ruby process using specified port
# Puma occasionally doesn't kill all ruby processes when
# I shut down my local web server. Here are the steps
# to find and kill the processes.
# Find pid of process running on specified port
lsof -i :3000
# Kill process
sudo kill -9 [pid]
@wosephjeber
wosephjeber / index.js
Last active September 11, 2023 19:02
Quick Node script to find largest dependency in package.json
const { dependencies } = require('../package.json');
const deps = Object.keys(dependencies).map((p) => `${p}@${dependencies[p]}`);
function pluralize(count, singular, plural) {
if (count === 1) return `${count} ${singular}`;
return `${count} ${plural}`;
}
@wosephjeber
wosephjeber / notes.md
Created September 13, 2023 18:19
Notes from learning SolidJS

I'm learning SolidJS coming from React. I'm taking notes here on things that trip me up in the process.

  • Don't destructure props. It breaks reactivity with signals passed down as props.
  • Use untrack() to reference signal values in an effect without rerunning the effect when those signals change. Might be a less common use case? (Mine was referencing updated signal values in an interval started by the effect).