Skip to content

Instantly share code, notes, and snippets.

View idoshamun's full-sized avatar

Ido Shamun idoshamun

View GitHub Profile
@idoshamun
idoshamun / daily-cla.md
Last active May 21, 2020 19:51
Daily's CLA based on Microsoft's CLA

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”), and conveys certain license rights to Ido Shamun and its affiliates (“Daily”) for Your contributions to Daily open source projects. This Agreement is effective upon Your acknowledgment via the CLA Assistant tool. All prospective contributors to Daily open source projects must sign this Agreement (digitally or otherwise) before any changes will be merged.

1. Definitions.

“Code” means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to Daily under this Agreement.

“Project” means any of the projects owned or managed by Daily in which software is offered under a license approved by the Open Source Initiative (OSI) (www.opensource.org) and/or documentation offered under an OSI or a Creative Commons license ([https://creativecommons.org/licenses](https://creativecommons.or

@idoshamun
idoshamun / sync.js
Created October 9, 2018 06:14
Optimistic Offline-First Apps With Vuex
const plugin = (store) => {
store.subscribe((mutation, state) => {
switch (mutation.type) {
case '...':
// dispatch request
break;
case '...':
// dispatch request
break;
default:
@idoshamun
idoshamun / loadState.js
Created October 8, 2018 15:49
Optimistic Offline-First Apps With Vuex
import store from './store';
import { getState } from './storage';
export default function () {
if (store.initialized) {
return Promise.resolve();
}
return getState()
.then(state => store.commit('loadFromCache', state));
@idoshamun
idoshamun / store.js
Created October 8, 2018 15:42
Optimistic Offline-First Apps With Vuex
import Vue from 'vue';
import Vuex from 'vuex';
import cache from './plugins/cache';
import sync from './plugins/sync';
Vue.use(Vuex);
export default new Vuex.Store({
state: {
@idoshamun
idoshamun / storage.js
Last active June 17, 2019 14:07
Optimistic Offline-First Apps With Vuex
import localForage from 'localforage';
const store = localForage.createInstance({
name: 'app',
});
const mapStateForCache = (state) => {
// Your business logic here
};
@idoshamun
idoshamun / cache.js
Last active June 17, 2019 14:18
Optimistic Offline-First Apps With Vuex
import { setState } from './storage';
const shouldSkipCache = (mutation) => {
// Your business logic here
};
const plugin = (store) => {
store.subscribe((mutation, state) => {
if (!shouldSkipCache(mutation)) {
setState(state).catch(err => console.warn('failed to cache state', err));
@idoshamun
idoshamun / Dockerfile
Created November 3, 2017 07:39
Dockerizing Scala Application
FROM openjdk:8-jre-alpine
RUN mkdir -p /opt/app
WORKDIR /opt/app
COPY ./run_jar.sh ./app-assembly.jar ./
ENTRYPOINT ["./run_jar.sh"]
@idoshamun
idoshamun / withBrowserStack.groovy
Created August 22, 2017 06:44
BrowserStack integration with Jenkins
#!/usr/bin/env groovy
def call(body) {
lock(label: 'BrowserStack', quantity: 1) {
env.BROWSERSTACK_LOCAL_IDENTIFIER = env.BUILD_TAG
// Start the connection
sh "BUILD_ID=dontKillMe nohup /opt/BrowserStackLocal --force-local --only-automate --key ${env.BROWSERSTACK_ACCESSKEY} --local-identifier ${env.BROWSERSTACK_LOCAL_IDENTIFIER} > /var/tmp/browserstack.log 2>&1 & echo \$! > /var/tmp/browserstack.pid"
try {
body()
}
@idoshamun
idoshamun / icla.txt
Created November 10, 2016 17:30
The Elegant Monkeys Ltd. Individual Contributor License Agreement
The Elegant Monkeys Ltd.
Individual Contributor License Agreement ("Agreement") V1.0
In order to clarify the intellectual property license granted with
Contributions from any person or entity,The Elegant Monkeys Ltd. ("TEM")
must have a Contributor License Agreement ("CLA") on file that has been
signed by each Contributor, indicating agreement to the license terms
below. This license is for your protection as a Contributor as well as
the protection of TEM; it does not change your rights to use your own
Contributions for any other purpose.
@idoshamun
idoshamun / deleteSubscriptions.js
Last active June 12, 2016 12:52
Delete all Google Pub/Sub subscriptions
'use strict';
const async = require('async');
const gcloud = require('gcloud')();
const pubsub = gcloud.pubsub();
const callback = function (err, subscriptions, nextQuery) {
if (!err) {
async.forEach(subscriptions, (subscription, callback) => {
subscription.delete(callback);