Skip to content

Instantly share code, notes, and snippets.

JayTeeSF

Block or report user

Report or block JayTeeSF

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JayTeeSF
JayTeeSF / application.html.erb
Created Jun 5, 2019 — forked from Dagnan/application.html.erb
Inline CSS or JS in Rails 5
View application.html.erb
<!DOCTYPE html>
<html>
<head>
<%= inline_js 'application.js' %>
<%= inline_css 'application.css' %>
</head>
<body>
</body>
</html>
@JayTeeSF
JayTeeSF / copy_attachments.rb
Created Mar 14, 2018 — forked from airblade/copy_attachments.rb
Copies S3-stored Paperclip attachments from one AR model to another
View copy_attachments.rb
# 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 Feb 12, 2018 — forked from naiquevin/mysql.py
Examples of Mysql programming in Python
View mysql.py
#!/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 Jan 30, 2018 — forked from martinwicke/automobile.ipynb
Estimator demo using Automobile dataset
View automobile.ipynb
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 Jan 3, 2018 — forked from rpheath/authlogic-to-devise.md
Steps and troubleshooting tips when moving Authlogic to Devise.
View authlogic-to-devise.md

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
View sonic_pi_examples.txt
##############################################
## 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 Oct 7, 2015 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
View rails http status codes
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
View gist:6747856479055a4f0544
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 Aug 29, 2015 — forked from jinnko/pem-split
Take a PEM format file as input and split out certs and keys into separate files.
View pem-split
#!/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 Jun 13, 2015
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
View ar_weirdness.rb
#!/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' \\
You can’t perform that action at this time.