Skip to content

Instantly share code, notes, and snippets.

@mixja
mixja / security.json
Last active June 28, 2020 08:20
AWS IAM Policy for MFA
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:GetAccountPasswordPolicy",
"iam:ListUsers",
@gSrikar
gSrikar / Solution to TypeError or ValueError caused by Tensor dtype
Last active April 11, 2018 04:39
Example that resolves the TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int32 of argument 'x' or ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float64 in Tensorflow.
import tensorflow as tf
node1 = tf.constant(5) # dtype is int32
node2 = tf.constant(6.0) # dtype is float32
print('Node 1: ', node1) # Node 1: Tensor("Const:0", shape=(), dtype=int32)
print('Node 2: ', node2) # Node 2: Tensor("Const_1:0", shape=(), dtype=float32)
# Multiplication
# Convert the node1 type to float32 before multiplying
@hackedunit
hackedunit / install-redis.md
Last active October 11, 2023 12:37
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
@paulirish
paulirish / what-forces-layout.md
Last active May 23, 2024 14:12
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@todgru
todgru / aws-ec2-redis-cli.md
Created June 12, 2014 23:01
AWS redis-cli on EC2
@blessdyb
blessdyb / common.css
Last active December 18, 2015 00:29
A common css file including normalize and reset css
@import 'https://github.com/necolas/normalize.css/blob/master/normalize.css'
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
@pies
pies / ExcelFormulas.js
Created November 29, 2012 04:55
Few Excel formulas - PMT, PPMT, XIRR - expressed in Javascript
/* Based on
* - EGM Mathematical Finance class by Enrique Garcia M. <egarcia@egm.co>
* - A Guide to the PMT, FV, IPMT and PPMT Functions by Kevin (aka MWVisa1)
*/
var ExcelFormulas = {
PVIF: function(rate, nper) {
return Math.pow(1 + rate, nper);
},
@axelpale
axelpale / combinations.js
Last active July 7, 2023 10:37
JavaScript functions to calculate combinations of elements in Array.
/**
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
*
* <license>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
@getify
getify / the-rafpolyfill.js
Created June 27, 2012 06:44
setTimeout vs. nested-RAF
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];