Skip to content

Instantly share code, notes, and snippets.

View kany's full-sized avatar

Frank Kany kany

  • Rickman, TN
View GitHub Profile
@kany
kany / Terminal-Commands.md
Created March 29, 2021 12:32
Handy OSX Terminal Commands
@kany
kany / Show Trailing Whitespace
Created May 1, 2012 16:33
Textmate2 - Show Trailing Whitespace
The following explains how to install the Whitespace Bundle for TextMate2.
1) mkdir -p ~/Library/Application\ Support/Avian/Bundles
2) cd ~/Library/Application\ Support/Avian/Bundles
3) git clone https://github.com/mads379/Whitespace.tmbundle.git
4) Open TextMate > Preferences
5) Create a Variable named 'Invalid' with a value of 'Red'(or whatever color you choose)
6) Restart TextMate

Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver)

This guide will walk you through the steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest.

Prerequisites

This guide assumes that you are using the following setup:

You could still make this guide work with other setups (possibly with some modifications to the commands and whatnot).

Rails 5 and ActionCable

Assumptions: The application already exists. You have two models article.rb and comment.rb. Articles have two attributes, title and text. Comments have two attributes, text and article_id. See these instructions if you need help getting started.

Routes

Assuming that you are nesting your :comments resources inside of :articles, mount ActionCable and make sure you have a root.

config/routes.rb

Rails.application.routes.draw do
@kany
kany / Using GDB to inspect a running Ruby process.md
Last active June 22, 2020 12:37
Using GDB to inspect a running Ruby process

http://robots.thoughtbot.com/post/47202759358/using-gdb-to-inspect-a-running-ruby-process

That’s not a great thing to have to say, is it? However, I bet you’ve said it before and may not have immediately know why.

With liberal use of puts and maybe pry, you can figure out what a problem might be next time you run it, but sometimes you need to figure out what that problem is right now.

As it turns out, and I know this is a shocker, Ruby processes are just regular processes. They can be debugged with gdb.

Having recently had the need to find out why a job of mine was running particularly slowly, I found out about this lovely tool the hard way: frantic googling. I found some very useful functions for gdb in a blog post by Rasmus on Ruby callstacks.

@kany
kany / Deploy-ReactVR-To-Heroku.md
Last active November 6, 2019 11:07
Deploy Facebooks' React VR `TourSample` to Heroku in 5 minutes or less
@kany
kany / README.md
Last active September 20, 2019 01:37
Toggle Wireless Mode

Toggle Wireless Mode

This script will allow switching between managed and monitor mode for a wireless adapter.

Managed mode is the default wireless adapter mode.

Monitor mode allows monitoring all traffic received on a wireless channel and allows packets to be captured without having to associate with an access point.

Environment

@kany
kany / formatting_xml_or_json.rb
Created February 12, 2019 11:50
Formatting XML or JSON
# resource - http://richardlog.com/post/12743073497/pretty-printing-json-and-xml-on-mac-osx
# Formatting XML
cat unformatted.xml | xmllint --format - > formatted.xml
# Formatting JSON
cat unformatted.json | python -m json.tool > formatted.json
@kany
kany / compile_less
Last active March 27, 2017 13:00
compile '.less' files into '.css' files
gem install less --no-ri --no-rdoc
gem install therubyracer --no-ri --no-rdoc
lessc app/assets/stylesheets/less/mobile/common/core.less > app/assets/stylesheets/css/mobile/core.css
1) delete associated css file(s) for modified less file(s) from public/assets/***.css
2) bundle exec rake assets:precompile
@kany
kany / raw_sql_to_calculate_distance.rb
Last active September 26, 2016 16:10
Use raw sql to calculate distance between latitude/longitude coordinates
# Use raw sql to calculate distance between latitude/longitude coordinates
# From the web
# - http://gis.stackexchange.com/questions/31628/find-points-within-a-distance-using-mysql
"SELECT
id, (
3959 * acos (
cos ( radians(78.3232) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(65.3234) )