Skip to content

Instantly share code, notes, and snippets.

let people = [
{ name: 'Bob', age: 28, child: { name: 'Sally', age: 8, grade: 3 } },
{ name: 'Sara', age: 46, child: { name: 'Lois', age: 14, grade: 9 } },
{ name: 'Ann', age: 27, child: { name: 'George', age: 9, grade: 4 } },
{ name: 'Dave', age: 52, child: { name: 'Hale', age: 17, grade: 11 } },
];
const add1 = (x) => x + 1;
const toFieldApplyFunc = (field, fn) => {
return (obj) => {
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active October 11, 2024 01:20
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
files:
"/opt/elasticbeanstalk/support/conf/sidekiq.conf":
mode: "000755"
content: |
description "Elastic Beanstalk Sidekiq Upstart Manager"
start on runlevel [2345]
stop on runlevel [06]
# explained above
respawn
respawn limit 2 30
@Ashoat
Ashoat / text-height-measurer.js
Created May 11, 2017 04:24
React Native component for measuring text height
// @flow
import type {
StyleObj,
} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
import React from 'react';
import PropTypes from 'prop-types';
import { Text, View, StyleSheet } from 'react-native';
import invariant from 'invariant';
@printercu
printercu / rails-5.0-integration-tests-speedup.md
Last active March 7, 2022 01:20
Speed up Rails 5 integration tests

Speed up integration tests in Rails 5 app

Rails 5 recompiles templates on every request in test env. Fix will be released only in 5.0.2.

Add this lines to test helper to get the performance now (I've got x2 improvement):

class << ActionView::LookupContext::DetailsKey
 def clear
@sbarski
sbarski / index.js
Last active January 5, 2023 11:10
A Lambda function that creates and submits an Elastic Transcoder job after being invoked by an S3 bucket
'use strict';
var AWS = require('aws-sdk');
var s3 = new AWS.S3({
apiVersion: '2012-09-25'
});
var eltr = new AWS.ElasticTranscoder({
apiVersion: '2012-09-25',
region: 'us-east-1'
});
@hiattp
hiattp / sidekiq.config
Last active March 6, 2020 09:14
Sidekiq Config for Elastic Beanstalk
# Sidekiq interaction and startup script
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
. /opt/elasticbeanstalk/hooks/common.sh
. /opt/elasticbeanstalk/support/envvars
@henrik
henrik / config--initializers--rails4_to_rails3_downgradability.rb
Created June 18, 2015 09:55
Fix "NoMethodError: undefined method `sweep'" error when downgrading from Rails 4 to Rails 3.
# Without this fix, downgrading from Rails 4 to Rails 3 causes session cookies to blow up.
#
# The way the flash is stored in the session changed in a backwards-incompatible way.
if Rails::VERSION::MAJOR == 3
module ActionDispatch
class Flash
def call(env)
if (session = env['rack.session']) && (flash = session['flash'])
@larrybolt
larrybolt / bootstrap-server.sh
Created August 23, 2014 13:55
Bootstrap server to use with ansible
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
echo "please supply a servername: bootstrap-server.sh node.example.com"
exit 1
fi
username=`whoami`
# copy public rsa key to server for root user
read -r -p "Transfer ssh public keys to server for root? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
@benjchristensen
benjchristensen / EventBus.java
Last active February 24, 2022 03:02
EventBus.java
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* Simple pass-thru event bus with error handling and reconnect.
*/
public class EventBus {