Skip to content

Instantly share code, notes, and snippets.

@cosminnicula
cosminnicula / gist:e32ccabed695fb646aefa2cb6e1609c8
Created January 3, 2023 07:42
CDKTF Using Iterators on Complex Types error
[2023-01-03T08:54:34.404] [ERROR] default - ╷
│ Error: Invalid for_each set argument
│ on cdk.tf.json line 36, in module.s3-bucket:
│ 36: "for_each": "${toset(local.my-list)}",
│ ├────────────────
│ │ local.my-list is tuple with 2 elements
│ The given "for_each" argument value is unsuitable: "for_each" supports maps
basic-ec2-stack ╷
@cosminnicula
cosminnicula / MyDropdownList.js
Last active September 15, 2016 08:46
Salesforce Lightning Design System: custom PickList
'use strict';
import React from 'react';
import Menu from 'ui/components/menus/index.react';
import componentUtil from 'app_modules/ui/util/component';
import MyPickList from 'MyPickList';
import RootCloseWrapper from 'react-overlays/lib/RootCloseWrapper';
const pf = componentUtil.prefix;
const PT = React.PropTypes;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>Modal example</title>
<link href="../../../../../node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet"/>
var DisabledList = React.createClass({
// proptypes tell the parent widget what to pass into it
// the DropdownList will inspect propTypes and _.pick() those keys to pass in
propTypes: {
disabledItems: React.PropTypes.array,
...List.type.propTypes,
},
componentWillMount(){
@cosminnicula
cosminnicula / JSBind
Created July 11, 2012 11:07
A common mistake for new JavaScript programmers is to extract a method from an object, then to later call that function and expect it to use the original object as its this
//Varint 1: use bind function https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
var val = 1;
var myObject = {
val: 11,
getVal: function() { return this.val; }
};
console.log(module.getVal()); // 11
var getVal = myObject.getVal;
@cosminnicula
cosminnicula / nodejsexpressauthstaticres
Created June 8, 2012 15:39
node.js express authorize static resources
app.use(express.static(__dirname + './../public/default'));
//Session support
app.use(express.cookieParser());
app.use(express.session({
key : 'sid',
secret : sessionSecret,
//1h * 24(hours per day) * 365(days per year)
cookie : {
expires : new Date(Date.now() + 3600000 * 24 * 365)