Skip to content

Instantly share code, notes, and snippets.

View rockhowse's full-sized avatar
🎯
Focusing

Nate Rock rockhowse

🎯
Focusing
View GitHub Profile
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@rockhowse
rockhowse / csv_export.rb
Created May 17, 2018 17:37 — forked from foxumon/csv_export.rb
Export table to CSV with all attributes in rails console
require 'csv'
file = "#{Rails.root}/public/data.csv"
table = User.all;0 # ";0" stops output. Change "User" to any model.
CSV.open( file, 'w' ) do |writer|
writer << table.first.attributes.map { |a,v| a }
table.each do |s|
writer << s.attributes.map { |a,v| v }
@rockhowse
rockhowse / vagrant_setdate.sh
Created April 27, 2018 12:07 — forked from unfulvio/vagrant_setdate.sh
How to change server time on a Vagrant box on Virtualbox
#!/bin/bash
# Log in into the box
vagrant ssh
# VirtualBox syncs host time with guest, so we need to shut off VBox Guest Additions first
sudo service vboxadd-service stop
# Now you can set any date and time
sudo date -s "2020-10-01 10:25:00"
@rockhowse
rockhowse / Install Ruby and RubyGems
Created May 24, 2017 20:52 — forked from chiraggude/Install Ruby and RubyGems
Install Ruby 2.1.1 and RubyGems 1.8.25 on CentOS 6.5
# Install Ruby
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
tar xvzf ruby-2.1.1.tar.gz
cd ruby-2.1.1
./configure --prefix=/usr
make
make install
# remove "ruby-2.1.1" folder in /root

Keybase proof

I hereby claim:

  • I am rockhowse on github.
  • I am rockhowse (https://keybase.io/rockhowse) on keybase.
  • I have a public key ASBHXbtloxkk6Zi7nKOaVlPpHR-vkhrWzDsA1S7knEtzDwo

To claim this, I am signing this object:

@rockhowse
rockhowse / OpenSSL-1_1_0-stable-VS2015.md
Created February 22, 2017 14:17 — forked from terrillmoore/OpenSSL-1_1_0-stable-VS2015.md
Building OpenSSL 1.1.0 with Microsoft VS 2015

Building OpenSSL 1.1.0 with Microsoft VS 2015

MCCI needs OpenSSL for a Windows project (that will be cross-platform). A casual search didn't turn up either a good source for cross-platform libraries, which meant we have to build them ourselves. A deeper search found a detailed guide here, and yet the details don't match what I found when I checked out the code; and the post doesn't talk about doing it directly from GitHub (which I wanted to do).

Here's the procedure for building OpenSSL on 64-bit Windows 10, with Visual Studio 2015.

  1. If you don't have it, please install git bash from git-scm.com.
  2. Start a git bash window.

    In the following, I'll use lines beginning with {dir} $ to designate input to a bash Window. We'll also have to use a cmd.exe Window for much of the build, and those lines will be marked {dir}>, just as on Windows..

from django.db import models
class Address(models.Model):
ADDRESS_UNIT_CHOICES = (
('STE', 'Suite'),
('FLR', 'Floor'),
('NUM', 'Number'),
('RM', 'Room'),
('UNIT', 'Unit'),
('PO', 'PO Box'),
)
@rockhowse
rockhowse / MakeZip
Created February 19, 2014 21:21 — forked from KT-1000/MakeZip
import os
import zipfile
# project folder, where the files and zip resides
root_dir = "C:\\User\\MyProject\\"
# list files in root_dir
file_name_list = os.listdir(root_dir)
# name new zipfile