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 / 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 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 / 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
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
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, 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 / 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
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 / there-is-a-hole-in-my-bucket.js
Created June 25, 2021 14:14
There's a hole in my bucket song as a state chart
const bucketMachine = Machine({
id: 'fetch',
initial: "There's a hole in my bucket",
states: {
"There's a hole in my bucket": {
on: {
THEN_FIX_IT: 'With what should I fix it?'
}
},
@apnerve
apnerve / sum.js
Created December 10, 2021 16:42
Write a function sum such that sum(a)(b)(c)...(n)() returns a+b+c+...+n
const sum = x => y => y ? sum(x+y) : x