Skip to content

Instantly share code, notes, and snippets.

View jules2689's full-sized avatar

Julian Nadeau jules2689

View GitHub Profile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
@jules2689
jules2689 / CFK Ruby
Last active August 29, 2015 14:01
Code For Kids Ruby Script
puts 'Put the lower number'
lowest = gets.to_i
puts 'Put the higher number'
highest = gets.to_i
puts "Choosing a random number in the range " + lowest.to_s + " and " + highest.to_s
our_number = (lowest..highest).to_a.choice
guess_counter = 0
#!/usr/bin/env ruby
# The above tell the terminal it is Ruby
# Do not forget to chmod +x the file in terminal
require 'shopify_api' # We need to use the api!
module ShopifyTest # encapsulates the methods and constants
# the self. in the methods refers to this module (ShopifyTest)
# Fill these out from your store (https://storename.myshopify.com/admin/apps/private)
@jules2689
jules2689 / README.md
Last active January 31, 2019 10:17
Tracking users' actions throughout an application in an "activity feed"

What this does

This is the initial code. Improvements are likely to be had.

  • This creates an activity feed that can track updates, destroys, creates in a MySQL database.
  • This is inspired by part of the "public_activity" gem.
  • For Updates, what changed will be automatically stored as a hash.
  • Bootstrap's usage is assumed, as is Devise's "current_user". ActiveRecord must be used as well. These can easily be changed however.

How to use it

# This controller is intended to be extended to another controller.
# - This controller assumes a User model with a polymorphic "role". Devise was used for the user model initially.
# - The User model must implement the "role"? methods. I.e. .tutor? .parent? .admin? methods
# - This controller should be the base of all "restricted" users.
# - This controller will automatically sandbox users to show, edit, update, and destroy.
# - This controller will allow the user to view new and use create if the user does not have a role_id set
# - This controller will work with any type of user given that the controller is "Role_Type"Controller.
# - The subclass controller needs to override resource_params with its own necessities. This is all it needs to do.
class UsersController < ApplicationController
# Will restrict the [:create, :new] actions to a parent object
# Will restrict the [:index, :show, :edit, :update, :destroy] actions to the owner (parent) of the kid
class KidsController < RestrictedParentController
...
end
root@ubuntu-512mb-tor1-01:~# pip install caravel
Requirement already satisfied (use --upgrade to upgrade): caravel in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): alembic<0.9.0,>=0.8.5 in /usr/local/lib/python2.7/dist-packages (from caravel)
Requirement already satisfied (use --upgrade to upgrade): cryptography<2.0.0,>=1.1.1 in /usr/local/lib/python2.7/dist-packages (from caravel)
Requirement already satisfied (use --upgrade to upgrade): flask-appbuilder<2.0.0,>=1.6.0 in /usr/local/lib/python2.7/dist-packages (from caravel)
Requirement already satisfied (use --upgrade to upgrade): flask-cache<0.14.0,>=0.13.1 in /usr/local/lib/python2.7/dist-packages (from caravel)
Requirement already satisfied (use --upgrade to upgrade): flask-migrate<2.0.0,>=1.5.1 in /usr/local/lib/python2.7/dist-packages (from caravel)
Requirement already satisfied (use --upgrade to upgrade): flask-script<3.0.0,>=2.0.5 in /usr/local/lib/python2.7/dist-packages (from caravel)
Requirement al
#!/usr/bin/env ruby
require 'json'
header = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
EOF
import Foundation
class Secrets {
enum SecretsError: Error {
case NotFound
}
class func secrets() -> Dictionary<String, Any?> {
if let path = Bundle.main.path(forResource: "Secrets", ofType: "plist") {
if let dict = NSDictionary(contentsOfFile: path) as? Dictionary<String, AnyObject> {
@jules2689
jules2689 / after.txt
Last active March 17, 2017 16:59
An example input and output for DiaTeX
Markdown
---
This is a markdown file
```ruby
ruby_var = 'ruby_var'
```
<!---
```latex