Skip to content

Instantly share code, notes, and snippets.

View larsroettig's full-sized avatar

Lars Roettig larsroettig

View GitHub Profile
@larsroettig
larsroettig / pwaCacheClean.js
Created August 18, 2021 09:11 — forked from revanth0212/pwaCacheClean.js
While using PWA Studio's scaffolding command if you run into any errors or if you notice the command using old packages, run this file to clear your cache and try again.
const fs = require("fs");
const os = require("os");
const { promisify } = require("util");
const exec = promisify(require("child_process").exec);
const temptdir = os.tmpdir();
if (fs.existsSync(`${temptdir}/@magento`)) {
fs.rmdirSync(`${temptdir}/@magento`, { recursive: true });
{
"editor.formatOnSave": true,
// Enable per-language
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
@larsroettig
larsroettig / rollyourown.php
Created May 20, 2019 13:37 — forked from mathiasverraes/rollyourown.php
We don't need no DIC libs / we don't need no deps control
<?php
// Context: I'm trying to argue that DI (and DIC) are great, and DIC libs suck.
// Happy to be proven wrong!
final class Router {
private $dependencies;
public function __construct (Dependencies $dependencies) {
$this->dependencies = $dependencies;
// You might say that this is Service Locator, but it's not. This router is toplevel,
// and toplevel must have access to dependencies. After that it can all just bubble nicely using proper DI.
@larsroettig
larsroettig / Exsample.php
Last active August 30, 2021 16:02
Magento 2 Helper to Translate by Zend_Locale
<?php
namespace Your\Module;
class Example
{
/**
* @var Helper\Translation
*/
private $translation;
@larsroettig
larsroettig / git-commit-log-stats.md
Created November 3, 2017 20:08 — forked from eyecatchup/git-commit-log-stats.md
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.




git log --shortstat --author="Your Name" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", files, inserted, deleted, delta, ratio }' -
@larsroettig
larsroettig / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console