Skip to content

Instantly share code, notes, and snippets.

@vsymguysung
vsymguysung / lambda-not-anon.md
Created April 28, 2018 15:25
The distinction between anonymous functions and lambdas in JavaScript.

TL;DR - Lambda means "function used as data".

Anonymous function means "function without a name".

This is one of the relatively few cases where the Wikipedia definition of a word, while not entirely wrong, is misleading. Lambdas and anonymous functions are distinct ideas.

These ideas are commonly confused because in many programming languages (and lambda calculus) all lambdas are anonymous or vise verse.

In JavaScript, not all lambdas are anonymous, and not all anonymous functions are lambdas, so the distinction has some practical meaning.

@alexcasalboni
alexcasalboni / index.md
Last active November 30, 2022 06:22
Bridge Function between Kinesis Streams and Step Functions

Bridge Function between Kinesis Streams and Step Functions

For each record read from the Kinesis Stream, a StepFunction state machine will be executed asynchronously.

Required Environment Variables

  • region: the AWS region where your StepFunction state machine is defined.
  • stateMachineArn: the ARN of the StepFunction state machine you want to execute.

Notes

@paul-butcher
paul-butcher / checkjobs.groovy
Created November 3, 2016 09:35
Jenkins pipeline to check the status of a set of other jobs
import groovy.json.JsonSlurper
def getJobStatus(String jobName){
def rx = httpRequest "https://jenkins.example.com/job/${jobName}/lastBuild/api/json"
def rxJson = new JsonSlurper().parseText(rx.getContent())
return rxJson['result']
}
node() {
def any_success = false
@kkkrist
kkkrist / app.js
Last active February 26, 2019 00:26
Rate limiting for FeathersJS HTTP (REST API) and Web Sockets connections (Express, Node.js)
'use strict'
const bodyParser = require('body-parser')
const compress = require('compression')
const configuration = require('feathers-configuration')
const cors = require('cors')
const favicon = require('serve-favicon')
const feathers = require('feathers')
const hooks = require('feathers-hooks')
const limiter = require('limiter').RateLimiter // Generic limiter used for authentication attempts inside web socket connection
@antoniomaria
antoniomaria / Splitter.java
Created January 25, 2016 08:28
Java split bytes array into chunks
byte[] data = { 2, 3, 5, 7, 8, 9, 11, 12, 13 };
int blockSize = 3;
int blockCount = (data.length + blockSize - 1) / blockSize;
byte[] range = null;
for (int i = 1; i < blockCount; i++) {
int idx = (i - 1) * blockSize;
range = Arrays.copyOfRange(data, idx, idx + blockSize);
@stackmutt
stackmutt / iTerm2-Change-cursor-blink-speed.sh
Last active August 13, 2019 07:37 — forked from maxgrinev/gist:f02fd7fd6425a8b74dcf
iTerm2: Change cursor blinking speed (quit iTerm, run in Terminal.app, restart iTerm) (requires Nightly build)
@pbakondy
pbakondy / essential-javascript-functions.js
Created July 20, 2015 16:00
7 Essential JavaScript Functions
// http://davidwalsh.name/essential-javascript-functions
/*
debounce
The debounce function can be a game-changer when it comes to event-fueled performance.
If you aren't using a debouncing function with a scroll, resize, key* event, you're
probably doing it wrong. Here's a debounce function to keep your code efficient:
*/
@samselikoff
samselikoff / future-proof.md
Last active August 2, 2025 18:41
Future-proofing your Ember 1.x code

This post is also on my blog, since Gist doesn't support @ notifications.


Components are taking center stage in Ember 2.0. Here are some things you can do today to make the transition as smooth as possible:

  • Use Ember CLI
  • In general, replace views + controllers with components
  • Only use controllers at the top-level for receiving data from the route, and use Ember.Controller instead of Ember.ArrayController or Ember.ObjectController
  • Fetch data in your route, and set it as normal properties on your top-level controller. Export an Ember.Controller, otherwise a proxy will be generated. You can use Ember.RSVP.hash to simulate setting normal props on your controller.
@manmal
manmal / comment.coffee
Created November 14, 2014 07:09
Ember Promised Properties
# /app/controllers/comment.coffee
`import promisedProperty from "../utils/promised_property"`
CommentController = Ember.ObjectController.extend
needs: ["application"]
currentUser: Ember.computed.alias('controllers.application.currentUser')
isCommentController: true
@pwfisher
pwfisher / radio-button-component.js
Last active August 29, 2015 14:07 — forked from courajs/helpers-radio-button.js
radio-button-component.js
// {{ radio-button name='dish' value='spam' groupValue=selectedDish }} Spam
// {{ radio-button name='dish' value='eggs' groupValue=selectedDish }} Eggs
//
App.RadioButtonComponent = Ember.Component.extend({
tagName: 'input',
type: 'radio',
attributeBindings: [ 'checked', 'name', 'type', 'value' ],
checked: function () {