Skip to content

Instantly share code, notes, and snippets.

@marcorei
marcorei / idea-for-default-intent-handlers.ts
Created April 11, 2018 07:51
idea for states with default intent handlers
const defaultIntents = [
{
intentName: 'AMAZON.HelpIntent',
handler: yourFunctionPointer
},
// ... more Intents that are the same for each state.
]
const firstStateIntents = [
{
@cognitom
cognitom / quickstart.js
Last active June 4, 2024 04:16
Unspaghetti version of Google Spreadsheet API example code
import {readFile, writeFile, mkdir} from 'mz/fs'
import readline from 'mz/readline'
import promisify from 'es6-promisify'
import google from 'googleapis'
import googleAuth from 'google-auth-library'
import clientSecret from './client_secret.json'
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/sheets.googleapis.com-nodejs-quickstart.json
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
@daliborgogic
daliborgogic / delay.js
Created December 16, 2016 15:26
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@amysimmons
amysimmons / js-tricky-bits.md
Last active October 30, 2024 11:38
Understanding closures, callbacks and promises in JavaScript

#Understanding closures, callbacks and promises

For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.

10 months into my full-time dev career, and I would struggle to explain these words to a peer.

So I decided it was time to face my fears, and try to get my head around each concept.

Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.

public function chunk()
{
$chunk = $this->db
->where('page_id', $this->attribute('id'))
->where('slug', $this->attribute('name'))
->get('page_chunks')
->row_array();
if ($chunk)
{
@talkingnews
talkingnews / .htaccess
Created August 21, 2012 21:48
htaccess which comes with Pyrocms Pro
# Multiple Environment config
# Set this to development, staging or production
# SetEnv PYRO_ENV production
<IfModule mod_rewrite.c>
# Make sure directory listing is disabled
Options +FollowSymLinks -Indexes
RewriteEngine on
@talkingnews
talkingnews / nginx_pyrocms_pro_config
Created August 21, 2012 21:47
Nginx config file working with pyrocms pro.
server {
listen x.x.x.x:80;
server_name mysite.co.uk *.mysite.co.uk;
root /var/www/mysite.co.uk/web/pyrocms-professional;
index index.php;
error_log /var/www/mysite.co.uk/error.log;
access_log /var/www/mysite.co.uk/access.log combined;
{{ streams:edition where="`edition_number`='[segment_4]'" no_results="<br />Please enter some details for this edition first" }}
{{ entries }}
<h2>{{ streams:date date="{{edition_date}}" format="F j, Y" }}</h2>
{{ /entries }}
{{ /streams:edition }}
@Darkflib
Darkflib / gist:1884880
Created February 22, 2012 12:42
Generating RSS 2.0 with SimpleXML in PHP
<?php
$link=mysql_pconnect($db['write']['host'],$db['write']['user'],$db['write']['pass']) or die ("Could not connect to datadase");
mysql_select_db($db['write']['name']) or die ("could not select database");
//patharray is an essentially an exploded $_SERVER['REQUEST_URI']
//for articles rss feeds it would be /rss/articles/categoryname
//so $patharray[0]='rss', $patharray[1]='articles' and $patharray[2]='categoryname'
const('SITENAME','Example.com');
const('WEBMASTER','[email protected] ([email protected])');