This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
# make sure you are running the same major ruby version locally as will be used in the OpenWhisk Ruby runtime (currently 2.5.0) | |
ruby '>= 2.5.0', '< 2.6' | |
# the gems you need for your action | |
gem 'betterlorem' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# initialize standalone bundler | |
require __dir__ + '/bundle/bundler/setup.rb' | |
# require the gems we want to use | |
require 'betterlorem' | |
def main(params = {}) | |
length = (params["length"] || 20).to_i | |
{ lipsum: BetterLorem.w(length, true) } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var yearlyIncomePersonA = 120000; | |
var yearlyIncomePersonB = 100000; | |
var query = '.expense:not(.summary)' | |
var delayMultiplier = 20; | |
var elLength = $(query).length; | |
var i = 0; | |
var maxNum = 0; // maximum number of items it should edit | |
var interval = setInterval(function () { | |
var elements = $(query).toArray(); | |
var el = elements[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project: | |
# All of these params you will need to grab from your OpenWhisk credentials page | |
# In IBM Cloud Functions the url where you can get these is: | |
# https://console.bluemix.net/openwhisk/learn/api-key | |
apiHost: REPLACE-ME-WITH-YOUR-API-HOST-FOR-EXAMPLE | |
# example apiHost: openwhisk.ng.bluemix.net | |
credential: REPLACE-ME-WITH-YOUR-CREDENTIALS | |
# credential is the same as your API Key | |
namespace: REPLACE-ME-WITH-YOUR-NAMESPACE | |
# exmple namespace: cloud-foundry-org_cloud-foundry-space |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
# name of our dockerized action | |
action: | |
# current directory is where our projects root | |
build: . | |
# docker hub account repo | |
# IMPORTANT: rename this to your docker hub username/project-name | |
image: juice10/openwhisk-ruby # rename me! | |
# expose ports |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# image with ruby installed | |
FROM ruby:2.5 | |
# install Sinatra, sinatra helpers and thin, our fast webserver | |
RUN gem install sinatra && gem install sinatra-contrib && gem install thin | |
# load our code into the container | |
ADD action.rb / | |
# expose port 8080 | |
EXPOSE 8080 | |
# run our ruby script | |
CMD [ "ruby", "/action.rb" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import Sinatra | |
require 'sinatra' | |
# Import Sinatra's JSON package needed for neat JSON responses. | |
require 'sinatra/json' | |
# setup port, ip address and environment | |
set :port, 8080 | |
set :bind, '0.0.0.0' | |
set :environment, :production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dockerfile | |
docker-compose.yml | |
manifest.yaml | |
action.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# please substitute your username and api key below, | |
# SoftLayer library will look to see if these global variables are set when making a connection | |
# more information here: https://github.com/softlayer/softlayer-ruby/blob/master/lib/softlayer/Config.rb#L11-L58 | |
SL_API_USERNAME = "<your username here>" | |
SL_API_KEY = "<your apikey here>" | |
require 'softlayer_api' # Requires softlayer_api >= 3.2 | |
require 'pp' # used to display results | |
# Create a client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SoftLayer | |
from pprint import pprint as pp | |
# HELP: please scroll to the very bottom to see how this works | |
class example(): | |
def __init__(self): | |
self.client = SoftLayer.Client() |