Skip to content

Instantly share code, notes, and snippets.

View ardeearam's full-sized avatar
💭
https://blog.klaudsol.com

Ardee Aram ardeearam

💭
https://blog.klaudsol.com
View GitHub Profile
@ardeearam
ardeearam / shopify-auth-before-billing.js
Created July 13, 2020 02:39
Shopify Auth - Before Billing Code
server.use(
createShopifyAuth({
apiKey: SHOPIFY_API_KEY,
secret: SHOPIFY_API_SECRET,
scopes: [SCOPES],
async afterAuth(ctx) {
//Auth token and shop available in session
//Redirect to shop upon auth
const { shop, accessToken } = ctx.session;
theme.ShippingBar = (function(theme) {
var bar = document.querySelector('.announcement-bar');
if(bar)
{
var promote_txt = bar.dataset.promote;
var unlocked_txt = bar.dataset.unlocked;
var treshold = bar.dataset.treshold;
}
function update()
{
@ardeearam
ardeearam / Map.map.js
Created August 22, 2019 06:27
Map.map() should be a thing in ES6. It just makes sense.
/**
How to use:
let m = new Map();
m.set(1, 1);
m.set(2, 2);
// Map(2) {1 => 1, 2 => 2}
let n = m.map((key, value) => value * 2);
// Map(2) {1 => 2, 2 => 4}
@ardeearam
ardeearam / loop.rb
Last active June 17, 2019 12:10
Ruby Loop
int i;
for(i = 1; i <= 100; i++) {
printf("%d\n", i);
}
@ardeearam
ardeearam / Dockerfile
Last active April 12, 2019 03:23
Ready to use Rails 5.2 + Ruby 2.6
# Usage: `docker build --build-arg RAILS_MASTER_KEY=$RAILS_MASTER_KEY -t myapp .
FROM ruby:2.6.2-slim
ARG RAILS_MASTER_KEY
# Install NodeJS
RUN apt-get update \
&& apt-get install -y apt-transport-https curl gnupg2 \
&& curl --silent --show-error --location https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_6.x/ stretch main" > /etc/apt/sources.list.d/nodesource.list \
https://13.229.228.16?otp=0cb7f2da1194f554d34113cd2c88d960ab42984818e7b8d9641052d7f79f6669
version: '3'
services:
postgres:
container_name: postgres
image: postgres:9.5.2
ports:
- "5432:5432"
volumes:
- /Users/ardeearam/Docker/postgres:/var/lib/postgresql/data
environment:
@ardeearam
ardeearam / rails_test_smtp.rb
Last active December 1, 2016 04:53
rails_test_smtp.rb
#start of with a (hopefully) working Rails Settings
settings = ActionMailer::Base.smtp_settings
#Change credentials that you want to test
settings[:user_name] = "new_username@example.com"
settings[:password] = "Password"
settings[:key] = "Password" #For TLS, this is usually the same with password
envelope_from = "new_username@example.com" #For most SMTP servers, this should be consistent
destinations = "destination@example.com,destination2@example.com"
message = <<< MESSAGE
--http://stackoverflow.com/a/17298994/95552
--Generate lookup
create table work_minutes (
work_minute timestamp primary key
);
insert into work_minutes
select work_minute
from
(select generate_series(timestamp '2016-01-01 00:00:00', timestamp '2016-12-31 11:59:00' - interval '1 minute', '1 minute') as work_minute) t
@ardeearam
ardeearam / test_loop.rb
Last active May 16, 2016 03:48
test_loop.rb
1.upto 100 do
sample_question = Question.where(description: "8000").sample
puts sample_question.id
entity_outcome = sample_question.entity_outcome
if entity_outcome.nil?
puts "Error!"
break
elsif entity_outcome.result != "Abnormal" or entity_outcome.risk_point != 21
puts "Error!"
break