Skip to content

Instantly share code, notes, and snippets.

View ansgarm's full-sized avatar

Ansgar Mertens ansgarm

View GitHub Profile
@DanielMSchmidt
DanielMSchmidt / clone.sh
Created January 13, 2022 15:49
Clone all repos in an org
#!/bin/bash
# gh is the GitHub CLI
ORG='cdk8s-team'
gh repo list cdk8s-team --json "name" | jq -r ".[] | .name" | xargs -I '{}' gh repo clone "cdk8s-team/{}"
@skorfmann
skorfmann / custom-data-source.ts
Last active February 3, 2021 11:05
This uses the external Terraform provider (https://registry.terraform.io/providers/hashicorp/external) to build ad hoc data sources for cdktf.
import { Construct, } from "constructs";
import { Resource, TerraformResource } from 'cdktf';
import * as fs from "fs";
import * as path from 'path'
import { DataExternal } from "../.gen/providers/external"
export interface CustomDataSourceConfig<Inputs, Outputs> {
code(input: Inputs): Promise<Outputs>
inputs: Inputs;
dependsOn?: TerraformResource[];
@ansgarm
ansgarm / reduce.js
Created April 23, 2018 12:27
PSA: Don't use es6 default parameters for Array.reduce() accumulator function
// PSA: Don't use es6 default parameters for Array.reduce() accumulator function
a = [1, 2, 3];
a.reduce((sum = 0, x) => sum + x); // = 6
a.reduce((sum, x) => sum + x, 0); // = 6
// seems to work...
c = a.reduce((sum = 3, x) => sum + x); // = 6
// but! other initial value doesn't have an effect
// even better
@klaaspieter
klaaspieter / ASS.md
Created June 22, 2017 07:59 — forked from anonymous/ASS.md
Acronyms Seriously Suck - Elon Musk

From time to time, Musk will send out an e-mail to the entire company to enforce a new policy or let them know about something that's bothering him. One of the more famous e-mails arrived in May 2010 with the subject line: Acronyms Seriously Suck:

There is a creeping tendency to use made up acronyms at SpaceX. Excessive use of made up acronyms is a significant impediment to communication and keeping communication good as we grow is incredibly important. Individually, a few acronyms here and there may not seem so bad, but if a thousand people are making these up, over time the result will be a huge glossary that we have to issue to new employees. No one can actually remember all these acronyms and people don't want to seem dumb in a meeting, so they just sit there in ignorance. This is particularly tough on new employees.

That needs to stop immediately or I will take drastic action - I have given enough warning over the years. Unless an acronym is approved by me, it should not enter the SpaceX glossary.

@HyperBrain
HyperBrain / lifecycle-cheat-sheet.md
Last active March 20, 2024 00:17
Serverless Lifecycle Cheat Sheet

Serverless plugin author's cheat sheet

This cheat sheet provides a detailed overview of the exposed lifecycle events and available commands (and entrypoints) of the Serverless framework, that can be hooked by plugins (internal and external ones). The document is structured by the commands invoked by the user.

Lifecycle events are shown as the globally available outer events (all providers) and sub lifecycle events that are provider specific in the called order. Currently only the AWS provider is shown. If you have information about the other provider,

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 4, 2024 06:22
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@BraunreutherA
BraunreutherA / custom_fields.js
Created December 6, 2016 01:12
Keystone.js custom fields
/**
* This little script copies the custom fields into the node modules directly into the keystone types.
* Afterwards it hooks into the keystone field types and registers the new model.
*
* ATTENTION if a model already exists it'll overwrite it.
* This way you can copy the fields and update them to your liking.
*/
var _ = require('lodash');
var shell = require('shelljs');
#!/bin/bash
# Put this in /hooks/after_prepare/
PLIST=platforms/ios/*/*-Info.plist
cat << EOF |
Add :NSAppTransportSecurity dict
Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool YES
Add :NSAppTransportSecurity:NSExceptionDomains:facebook.com:NSIncludesSubdomains bool YES
Add :NSAppTransportSecurity:NSExceptionDomains:facebook.com:NSThirdPartyExceptionRequiresForwardSecrecy bool NO
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =