Skip to content

Instantly share code, notes, and snippets.

@calvintwr
calvintwr / gist:679cd40f6cef1f5bb02536c005a133bb
Last active April 30, 2022 06:29
Simple stock component
AAPL
Apple Inc.
161.50
↓-4.92
-3.05%
import { ConfigModule } from '@nestjs/config'
ConfigModule.forRoot()
require('module-alias/register')
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'
import { NestFactory } from '@nestjs/core'
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'
import { AppModule } from './app.module'
import { fastifyHelmet } from 'fastify-helmet'
'use strict'
const iCloud = require('apple-icloud')
const debug = require('debug')('autocontact:apps:autocontact:index.js')
const D = require('dottie')
debug.log = console.log.bind(console)
// Note: sessions seemed to be invalidated once every 14 days. #setInterval to re-validate
const cloudRestartInterval = 12 * 24 * 60 * 60 * 1000 // 12 days
let cloudInterval = false
function sendError(message, options) {
var response = {
success: false,
message: message || 'Nil message'
}
if (options.error) {
if (!response.debug) response.debug = {}
if (options.error instanceof Error) {
response.debug.message = options.error.message
response.debug.stack = options.error.stack
/**
* @api {get} /chat/one Retrieve one chat.
* @apiName GetOneChat
* @apiGroup Chat
*
* @apiParam {int} [chatId] Providing chatId alone is sufficient. Else provide travellerId, shopperId and requestId.
* @apiParam {int} [travellerId]
* @apiParam {int} [shopperId]
* @apiParam {int} [requestId]
*
<script>
var BASE_URI = 'http://localhost:2999';
var socket = io.connect(BASE_URI);
var Chat = {
init: function(opts) {
var mandatory = ['socket', 'myUserId'];
for (var i in mandatory) {
if (typeof opts[mandatory[i]] === 'undefined') throw new Error('mandatory options are not defined.');
@calvintwr
calvintwr / gist:cff31b4af91abe720ef1
Created April 29, 2015 15:22
Transaction with promises, ending with array of promises
return DB.sequelize.transaction(function (t) {
return DB.Something.create({
// data to create
}).then(function(something) {
return [
DB.SomethingElse.create({
streamFactory.append.likeText = function(post) {
//console.log('streamFactory.append.likeText');
var theParent = this.parent;
var toPrepend = '';
if(post.totalLikes > 0) {
var likersFollowed = post.likes,
likersFollowedCount = VV.utils.objCount(likersFollowed),
show = 3, //show how many related likers
loopRuns = 0,
//code
console.log(1);
console.log(user.dataMeta);
D.set(user, 'dataMeta.dataShop.shipping', req.body.data.dataShop.shipping);
console.log(2)
console.log(user.dataMeta);