Skip to content

Instantly share code, notes, and snippets.

View apnerve's full-sized avatar
🏠
Working from home

Praveen apnerve

🏠
Working from home
View GitHub Profile
@apnerve
apnerve / machine.js
Created January 8, 2021 17:37
Generated by XState Viz: https://xstate.js.org/viz
const webSocketMachine = Machine({
id: "Web Socket",
initial: "connecting",
states: {
connecting:{
on: {
SUCCESS: "open",
ERROR: "closed"
}
},
@apnerve
apnerve / machine.js
Last active January 8, 2021 16:48
Generated by XState Viz: https://xstate.js.org/viz
const roomMachine = Machine({
id: '100ms rooms',
initial: 'home',
context: {
isPermissionGiven: false,
isNew: true
},
states: {
home: {
on: {
@apnerve
apnerve / machine.js
Last active December 7, 2020 09:06
Generated by XState Viz: https://xstate.js.org/viz
const nstates = {
id: "pre call",
initial: "a",
states: {
a: {
on: {
X: 'b'
}
},
@apnerve
apnerve / wStore.js
Last active October 27, 2020 04:35
Whatsapp Store
// Current version copied from https://github.com/open-wa/wa-automate-nodejs/blob/master/src/lib/wapi.js
if (!window.Store||!window.Store.Msg) {
(function () {
function getStore(modules) {
let foundCount = 0;
let neededObjects = [
{ id: "Store", conditions: (module) => (module.default && module.default.Chat && module.default.Msg) ? module.default : null},
{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && (module.default.prototype.processFiles !== undefined||module.default.prototype.processAttachments !== undefined)) ? module.default : null },
{ id: "MediaProcess", conditions: (module) => (module.BLOB) ? module : null },
{ id: "Archive", conditions: (module) => (module.setArchive) ? module : null },
@apnerve
apnerve / machine.js
Created February 23, 2020 06:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@apnerve
apnerve / machine.js
Last active December 7, 2019 17:50
Generated by XState Viz: https://xstate.js.org/viz
const underwritingStates = {
id: "underwriting",
initial: "PENDING",
states:{
PENDING: {
on: {
approve: "APPROVED",
reject: "REJECTED",
ask_for_cosigner: "COSIGNER_NEEDED"
}
@apnerve
apnerve / machine.js
Last active December 7, 2019 11:14
Generated by XState Viz: https://xstate.js.org/viz
const loanMachine = Machine({
id: 'loan',
initial: 'PAYMENT_DETAILS',
context: {
cosigners: 0,
awesome: false,
},
states: {
PAYMENT_DETAILS: {
on: {
@apnerve
apnerve / machine.js
Created December 5, 2019 08:46
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@apnerve
apnerve / gist:720bf7b34121318f343e667dc00557d5
Created January 22, 2019 16:42
Useful docker utilities
docker run --rm -v $(pwd):/app composer:latest install --no-dev
@apnerve
apnerve / gist:c8db4e15cf32af07396b87ddc46e1aee
Created December 11, 2018 07:29
Election results bookmarklet
javascript:window.results = ([].slice.apply(document.querySelectorAll('#div1 tr'))).slice(3,-1).map(row => {const cells = row.querySelectorAll('td');return {c:cells[0].innerText,p: cells[1].innerText,v:Number(cells[2].innerText)}})