Skip to content

Instantly share code, notes, and snippets.

View dencorg's full-sized avatar

Dennis Rodis dencorg

View GitHub Profile
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active May 22, 2024 08:34
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@rsp
rsp / GitHub-Project-Guidelines.md
Last active May 22, 2024 12:38
Git Strict Flow and GitHub Project Guidelines - setup rules and git flow for commercial and open-source projects by @rsp

Git Strict Flow and GitHub Project Guidelines

Or how to turn this:

into this:

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@tjklemz
tjklemz / asyncAll.js
Last active October 5, 2018 04:52
asyncAll example
/*
* A simple asyncAll example.
*
* Ignores any error handling and only returns the results to the done callback.
* Each task is expected to take a callback for its first parameter.
*/
// Example call:
asyncAll([doSomething, doSomethingElse], function (results) {
console.log('all done', results);
@gingerwizard
gingerwizard / demo template
Created August 10, 2017 16:57
Template for main index on ecommerce demo
{
"cyclops": {
"aliases": {},
"mappings": {
"product": {
"properties": {
"attributes": {
"properties": {
"color": {
"type": "text",
{
"primary_image": {
"id": 56871
},
"on_offer": false,
"discount_amount": 0,
"default_price": 20.99,
"rating": 4,
"description": """upper_material_clothing:95% polyester, 5% spandex;productmodel_length:24.5 " (Size 8);pattern:plain;model_height:Our model is 71.5 " tall and is wearing size 8;washing_instructions:do not tumble dry;washing_instructions:machine wash at 30°C;washing_instructions:Machine wash on gentle cycle;sleeve_length_option:sleeveless;correct_fit:regular;shirt_collar_type:Mandarin collar;clothing_length:standard""",
"discount_percentage": 0,
@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@seeebiii
seeebiii / LambdaConstants.java
Last active February 9, 2024 04:17
Available default environment variables in AWS Lambda. Just copy&paste into your Node or Java project.
public class Constants {
/**
* Contains the path to your Lambda function code.
*/
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT");
/**
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function:
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10
let webpack = require('webpack');
let path = require('path');
module.exports = {
entry: {
app: './resources/assets/js/app.js',
vendor: ['vue', 'axios']
},
output: {