Skip to content

Instantly share code, notes, and snippets.

Avatar

Constant Meiring constantm

View GitHub Profile
@constantm
constantm / itr.js
Created Jul 14, 2021
NodeJS implementation in Pipedream of "Intent to Receive" for Xero webhooks
View itr.js
async (event, steps) => {
// NodeJS implementation in Pipedream of "Intent to Receive" for Xero webhooks
const { createHmac } = await import('crypto');
const xero_webhook_key = 'OSd0eLlVIY9ZhViEqlDUh4+6n6M+Lo+eDaEJheJ6OCCgWwIz2D3JIAU6jPMipHRbgKTLz2uJ+xiACXGDBLrgdA==' // Get this from the Xero app
const body_string = Buffer.from(steps.trigger.raw_event.body_b64, 'base64').toString() // Use RAW body data so that Pipedream doesn't break our data
const xero_hash = steps.trigger.event.headers["x-xero-signature"] // Could probably shorten, but keeping it long for consistency
let our_hash = createHmac('sha256', xero_webhook_key).update(body_string).digest("base64") // Generate the hash Xero wants
let statusCode = xero_hash == our_hash ? 200 : 401 // If the hashes match, send a 200, else send a 401
@constantm
constantm / settings.json
Created Sep 26, 2018
Getting VSCode Jest extension to work with Vue CLI
View settings.json
{
"jest.pathToJest": "node_modules/@vue/cli-service/bin/vue-cli-service.js test:unit",
}
@constantm
constantm / launch.json
Created Sep 26, 2018
Get VSCode debug and breakpoints to work with Vue Cli and Jest
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vue-cli-service-tests",
"request": "launch",
"env": {
"NODE_ENV": "test"
},
@constantm
constantm / gist:764192168f02733fe264
Last active Dec 5, 2018
Straight forward deployment of Ember on Semaphore CI
View gist:764192168f02733fe264
npm install ember-cli -g
npm install
bower install
ember build
ssh-keyscan host.com >> ~/.ssh/known_hosts
tar -cvf tmp.tar.gz -C dist .
scp -r tmp.tar.gz user@host.com:/var/www/versions/
ssh user@host.com "mkdir -p /var/www/versions/$REVISION && tar -xf /var/www/versions/tmp.tar.gz -C /var/www/versions/$REVISION/ && rm /var/www/versions/tmp.tar.gz && rm /var/www/current && ln -s /var/www/versions/$REVISION/ /var/www/current && ls -tr /var/www/leaply-ember/versions | head -n -3 | xargs rm -rf"
View test-output.sh
➜ git:(vueJS-user-list) ✗ yarn test
yarn run v1.3.2
$ jest --config spec/vue/jest.conf.json
FAIL spec/vue/users-add-remove.spec.js
UsersAddRemove
✕ loads users from remote JSON endpoint and renders table (1531ms)
● UsersAddRemove › loads users from remote JSON endpoint and renders table
expect(string).toContain(value)
@constantm
constantm / cheatsheet.md
Last active Feb 21, 2017
Shopify theme commands cheat sheet
View cheatsheet.md

##Configure existing theme on store:

theme configure --themeid=12345 --password=12345 --store=yourshop.myshopify.com

##Setup up new theme

theme configure --themeid=12345 --password=12345 --store=yourshop.myshopify.com
@constantm
constantm / Ruby countries hash
Last active Oct 27, 2016 — forked from vxnick/gist:380904
Ruby countries hash
View Ruby countries hash
countries = {
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
View track_signup.rb
def candidate_analytics_track(user)
# Alias user on Mixpanel so we can track unique visits -> signup
if cookies['visit_id']
Analytics.alias(previous_id: cookies[:visit_id], user_id: user._id.to_s)
Analytics.flush # We need this to prevent race conditions and split profiles on Mixpanel
cookies.delete :visit_id
end
Analytics.identify(
user_id: "#{user._id}",
@constantm
constantm / tshirt.html
Last active Jul 15, 2016
tshirt popup
View tshirt.html
<div id="tshirt-claim">
<div class="close" onclick="document.getElementById('tshirt-claim').style.display = 'none';">&times;</div>
<img src="https://gifts.offerzen.com/tshirt.jpg" alt="Offerzen Tshirt">
<h3>Get a free shirt!</h3>
<h4>JSinSA attendees get a free tshirt, just complete Offerzen's onboarding.</h4>
<a class="button button-primary" href="https://www.offerzen.com?source=jsinsa&id=IDPARAMGOESHERE">Claim my tshirt</a>
</div>
<style>
#tshirt-claim {
@constantm
constantm / application.controller.js
Last active Oct 12, 2015
ember map cli test not working
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
coords: ["-26.2041028", "28.0473051"]
});