Skip to content

Instantly share code, notes, and snippets.

@cezr
cezr / legacy detection
Created May 30, 2019 00:25
detect legacy browsers
function enableButtons () {
// removes a "disabled" class when all form inputs have value
$("input").keyup(function() {
var inputs = $(".form-field input");
for (var i = 0; i < inputs.length; i++) {
if (!inputs[i].value) {
$("button").addClass("disabled");
return;
}
}
@cezr
cezr / find_and_kill_process.sh
Last active November 2, 2018 23:46
Find and kill ruby process using port 3000
# Puma occasionally doesn't kill all ruby processes
# Find and kill the processes
# Find pid of process running on specified port
lsof -i :3000
# Kill process
sudo kill -9 [pid]
@cezr
cezr / server_bash_profile.sh
Created June 7, 2018 05:51
Simple python server script. Add it to your environment profile (.profile or .bash_profile or .bashrc etc). Run it by typing server from the directory you want to serve at http://127.0.0.1:8888
# Start an HTTP server from a directory
# Set a port (optional)
function server() {
local port="${1:-8888}"
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}

My OSX Dev Setup

  • Cez

Dev Enviroment

Computer:

  • MacOS Sierra
  • OSX 10.12.6
  • MacBook Pro 13" 2.5 intel i5

Main Installed binaries

@cezr
cezr / atom-settings.md
Last active October 16, 2017 22:55
Settings, shortcuts notes for Atom IDE

My Atom IDE Setup:

Atom Shell Command

  • Launch Atom and select "Atom - Install Shell Commands" menu to install atom and apm commands
  • Add /usr/local/bin to PATH environment variable
    • Now, you can load file from terminal with atom [directory or file]
  • echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile

Plugin packages

@cezr
cezr / update openssl
Last active July 3, 2017 08:11
osx update openssl
https://medium.com/@katopz/how-to-upgrade-openssl-8d005554401
https://www.reddit.com/r/osx/comments/5oafqg/trouble_linking_openssl_on_osx_el_capitan/
#terminal .bash_profile
export PATH=$(brew --prefix openssl)/bin:$PATH
#ssl certs
https://github.com/rubygems/rubygems/issues/1736
# manual solution to SSL issue
@cezr
cezr / upgrading ruby ruby-build with rbenv.bash
Last active December 5, 2022 20:19
Upgrading Ruby with rbenv
###
# Install new Ruby version
# Locally or server-side
###
# updating the list of ruby versions (ruby-build) to get the latest ones.
# with Hombrew
brew update && brew upgrade ruby-build
# with rbenv plugin
# https://github.com/rbenv/ruby-build
@cezr
cezr / addthis_reload.js
Last active May 11, 2017 18:19
addThis Social Sharing Reload
//
// Reload (or initialize) addThis social share buttons.
// Can be used for dynamic buttons after ajax.
//
// Insert addthis script tag in html page and replace with your correct pubid.
// http://www.addthis.com/academy/sharing-button-api-overview/
//
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid={YOUR_PUBID_HERE}" async="async"></script>
....
window.reinitializeAddThis = function() {
@cezr
cezr / mailgun_validate.js
Last active January 16, 2017 19:44
mailgun email validation API
//
// Mailgun Custom Address Validation API w/ v3
//
// Include in form submit:
//
// email_validator(email_address, event, {
// //api_key: ' api-key',
// in_progress: in_progress_callback, // called when request is made to validator
// success: success_callback, // called when validator has returned
// error: validation_error // called when an error reaching the validator has occured