Skip to content

Instantly share code, notes, and snippets.

View qqilihq's full-sized avatar
🏃‍♂️
Finished 1/2 Marathon in 1:56:07

Philipp Katz qqilihq

🏃‍♂️
Finished 1/2 Marathon in 1:56:07
View GitHub Profile
@kevinoid
kevinoid / error-reporting.js
Last active April 11, 2023 03:50
More Robust Client-Side JavaScript Error Reporting
// JavaScript error reporting functions, including automatic window.onerror
// and unhandledrejection reporting.
//
// Based on:
// https://kevinlocke.name/bits/2019/07/30/more-robust-javascript-error-reporting/
//
// API:
// reportError(message, error):
// Report an exception with optional message and exception value.
// reportRejection(message, cause):
@sploders101
sploders101 / fileDrop.vue
Last active September 17, 2023 15:25
Vuetify file drop box (drag-n-drop enabled, no directory support, uses vuetify-loader)
<template>
<!-- Drop box -->
<div class="dropzone"
@dragover.prevent
@dragleave="dragleave"
@dragenter="dragenter"
@drop="drop"
ref="dropzone"
>
<!-- Box Label -->
@eikw
eikw / test.js
Last active August 28, 2017 10:39
Initial Test
var http = require('http');
var url = require('url');
var cheerio = require('cheerio');
var result = [];
var myURL = url.parse(process.argv[2]);
var options = {
host: myURL.host,
@CodeMyUI
CodeMyUI / custom-round-checkbox.markdown
Created June 16, 2017 03:24
Custom Round Checkbox
@Rich-Harris
Rich-Harris / service-workers.md
Last active May 6, 2024 22:10
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@bcherny
bcherny / using-typescript-and-angular-1.x-in-the-real-world.md
Last active October 9, 2022 12:55
Using Typescript + Angular 1.x in the Real World

Work in progress!

A little while ago I started using Typescript with the Angular 1.5 app I'm working on, to help ease the migration path to Angular 2. Here's how I did it. We'll go example by example through migrating real world code living in a large, mostly non-Typescript codebase.

Let's start with a few of the basic angular building blocks, then we'll go through some of the higher level patterns we derived.

Filters

Javascript

@stanislavb
stanislavb / mongoconsole.sh
Last active February 10, 2023 16:34
Backup and restore MongoDB running in a Docker container
#!/bin/bash
usage() {
echo "Usage $0 -c mongo_docker_container_name"
}
while [[ $# > 1 ]]
do
key="$1"
@julianlam
julianlam / provisioning-unprivileged-lxc-containers-via-login-or-script.md
Last active September 7, 2023 12:45
Provisioning and usage of unprivileged LXC containers via indirect login or script #blog

Provisioning and usage of unprivileged LXC containers via indirect login or script

As I've discovered, managing LXC containers is fairly straightforward, but when building out a system for provisioning out user maintained instances of NodeBB, it was imperative that unprivileged LXC containers were used, so that in the event of shell breakout from NodeBB followed by privilege escalation of the saas user, the root user in the LXC container would only be an unprivileged user on the host machine.

During the course of development, I ran into numerous blockers when it came to managing LXC containers in unexpected circumstances. Namely:

  • Using LXC in a subshell is not directly supported. This usually happens under one of the following two circumstances:
    • After switching users via su or executing lxc-* commands as another user via sudo
    • Executing lxc-* commands via a program, application, or script. In my case, a Node.js application.
@jorgecasar
jorgecasar / localStorageFallback.js
Created August 26, 2014 18:43
It's an Angular Factory with $fakeStorage fallback. LocalStorage is not working in Safari, then we create a session storage in a local variable. Take care about the data you save on it, remember that it's a local variable.
angular.module('myApp.factories', [])
.factory('$fakeStorage', [
function(){
function FakeStorage() {};
FakeStorage.prototype.setItem = function (key, value) {
this[key] = value;
};
FakeStorage.prototype.getItem = function (key) {
return typeof this[key] == 'undefined' ? null : this[key];
}
@soheilhy
soheilhy / nginxproxy.md
Last active May 8, 2024 09:56
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers