Skip to content

Instantly share code, notes, and snippets.

@JayTeeSF
JayTeeSF / application.html.erb
Created June 5, 2019 21:48 — forked from Dagnan/application.html.erb
Inline CSS or JS in Rails 5
<!DOCTYPE html>
<html>
<head>
<%= inline_js 'application.js' %>
<%= inline_css 'application.css' %>
</head>
<body>
</body>
</html>
@JayTeeSF
JayTeeSF / copy_attachments.rb
Created March 14, 2018 21:26 — forked from airblade/copy_attachments.rb
Copies S3-stored Paperclip attachments from one AR model to another
# lib/paperclip/copy_attachments.rb
# Copies S3-stored Paperclip attachments from one AR model to another.
#
# This module should be mixed into the target AR model.
if Gem::Version.new(::AWS::VERSION) >= Gem::Version.new(2)
raise NotImplementedError, 'coded for aws-sdk v1'
end
@JayTeeSF
JayTeeSF / mysql.py
Last active February 12, 2018 18:59 — forked from naiquevin/mysql.py
Examples of Mysql programming in Python
#!/usr/bin/env python
# first, on cli: pip install mysqlclient
## Mysql-Python basic examples.
## All code is taken from [here](http://zetcode.com/databases/mysqlpythontutorial/)
## Gist created only for quick reference purpose
import sys
// import _mysql
@JayTeeSF
JayTeeSF / automobile.ipynb
Created January 30, 2018 18:29 — forked from martinwicke/automobile.ipynb
Estimator demo using Automobile dataset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JayTeeSF
JayTeeSF / authlogic-to-devise.md
Created January 3, 2018 16:27 — forked from rpheath/authlogic-to-devise.md
Steps and troubleshooting tips when moving Authlogic to Devise.

How To: Authlogic to Devise

Step 1: Migration

  1. bin/rails g migration AuthlogicToDevise
  2. (see the file below for the actual migration, authlogic_to_devise.rb)
  3. bin/rake db:migrate

Step 2: Update Gemfile

  1. gem "devise", "~> 2.2.0"
  2. bundle install
@JayTeeSF
JayTeeSF / sonic_pi_examples.txt
Created December 18, 2015 18:48 — forked from darinwilson/sonic_pi_examples.txt
Sonic Pi Examples
##############################################
## Example 1 - play a note
play 60
##############################################
## Example 2 - play 4 random notes
4.times do
play rrand_i(60, 90)
sleep 0.5
@JayTeeSF
JayTeeSF / rails http status codes
Created October 7, 2015 14:29 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
require "./compiler/crystal/**"
while line = gets
compiler = Crystal::Compiler.new
program = Crystal::Program.new
program.target_machine = compiler.target_machine
prelude = program.normalize(Crystal::Require.new("prelude"))
@JayTeeSF
JayTeeSF / pem-split
Last active August 29, 2015 21:34 — forked from jinnko/pem-split
Take a PEM format file as input and split out certs and keys into separate files.
#!/usr/bin/awk -f
#
# Take a PEM format file as input and split out certs and keys into separate files
#
BEGIN { n=0; cert=0; key=0; if ( ARGC < 2 ) { print "Usage: pem-split FILENAME"; exit 1 } }
/-----BEGIN RSA PRIVATE KEY-----/ { key=1; cert=0 }
/-----BEGIN CERTIFICATE-----/ { cert=1; key=0 }
split_after == 1 { n++; split_after=0 }
/-----END CERTIFICATE-----/ { split_after=1 }
@JayTeeSF
JayTeeSF / ar_weirdness.rb
Created June 13, 2015 00:36
Calling new on an AR class, from within the context of an ActiveRelation on a subclass of said class, assumes the "id" attribute defined in the relation's where clause
#!/usr/bin/env ruby
class ArWeirdnessUsage
def self.run
message = <<-EOF
Usage:
0) make this file executable and run it in order to see these instructions
1) Create a Rails Project (rails new foo) and add this file: cp %s ./foo/lib/
2) rails g scaffold TestClass name && RAILS_ENV=test rake db:create db:migrate
3) echo 'TestClass; ArWeirdness.test_suite' \\