Skip to content

Instantly share code, notes, and snippets.

@jasonheecs
jasonheecs / set.txt
Created December 8, 2017 10:04
Set Sale Product Label
<span style="color:red;">Sale items are non-returnable and non-refundable.</span>
@jasonheecs
jasonheecs / purge.sh
Created December 10, 2017 15:56 — forked from adrienbrault/purge.sh
Script to reduce VM size before packaging for vagrant
#!/bin/sh
# Credits to:
# - http://vstone.eu/reducing-vagrant-box-size/
# - https://github.com/mitchellh/vagrant/issues/343
aptitude -y purge ri
aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide
aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30
aptitude -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5
@jasonheecs
jasonheecs / debug.yml
Last active June 5, 2018 12:05
Ansible useful debugger snippet
- name: print to stdout
command: echo $PATH
register: hello
- debug: msg=" {{ hello.stdout }} "
@jasonheecs
jasonheecs / pg_hba.conf
Created February 13, 2019 15:26
Configuration for Postgres 10 for permissionless auth
# Alternatively, you can write an IP address and netmask in separate
# columns to specify the set of hosts. Instead of a CIDR-address, you
# can write "samehost" to match any of the server's own IP addresses,
# or "samenet" to match any address in any subnet that the server is
# directly connected to.
#
# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256",
# "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert".
# Note that "password" sends passwords in clear text; "md5" or
# "scram-sha-256" are preferred since they send encrypted passwords.
c = Channel.find 142568
$shopify_session = c.create_shopify_session
ShopifyAPI::Base.activate_session($shopify_session)
include Integrations::Shopify::Paginator
shopify_collection(:product)
sp = _
spids = sp.map(&:id)
spids = spids - c.owners(:product).map(&:online_id).map(&:to_i).uniq
Packsize SKU Variant SKU Quantity
DK0475-JJ-P10 DK0475-JJ 10
DK0280P-JJ-P10 DK0280P-JJ 10
DK0280S-JJ-P10 DK0280S-JJ 10
DK0092-JJ-P10 DK0092-JJ 10
DK0094Y-JJ-P10 DK0094Y-JJ 10
DK0090-JJ-P10 DK0090-JJ 10
DK0095-JJ-P10 DK0095-JJ 10
DK0096-JJ-P10 DK0096-JJ 10
DK0097-JJ-P10 DK0097-JJ 10
@jasonheecs
jasonheecs / user.rb
Created March 11, 2021 07:15
Implementing timeoutable on a Devise User model
class User < ActiveRecord::Base
devise :timeoutable
end
@jasonheecs
jasonheecs / routes.rb
Created March 11, 2021 07:44
new routes for session timeout
devise_scope :user do
get "/check_session_timeout" => "session_timeout#check_session_timeout"
get "/session_timeout" => "session_timeout#render_timeout"
end
@jasonheecs
jasonheecs / session_timeout_controller.rb
Last active September 5, 2024 21:06
SessionTimeoutController
class SessionTimeoutController < Devise::SessionsController
prepend_before_action :skip_timeout, only: [:check_session_timeout, :render_timeout]
def check_session_timeout
response.headers["Etag"] = "" # clear etags to prevent caching
render plain: ttl_to_timeout, status: :ok
end
def render_timeout
if current_user.present? && user_signed_in?
const sessionTimeoutPollFrequency = 5;
function pollForSessionTimeout() {
let request = new XMLHttpRequest();
request.onload = function (event) {
var status = event.target.status;
var response = event.target.response;
// if the remaining valid time for the current user session is less than or equals to 0 seconds.
if (status === 200 && (response <= 0)) {