Skip to content

Instantly share code, notes, and snippets.

@fragsalat
fragsalat / adjust-google-sidebar-width.user.js
Created November 22, 2023 14:17
Adjust size of Google Chat sidebar
// ==UserScript==
// @name Adjust size of Google Chat sidebar
// @namespace none
// @version 0.1
// @description This script tries to adjust necessary CSS Rules to increase size of Google Chat sidebar
// @author Thomas Schlage
// @match https://mail.google.com/mail/u/0/
// @match https://mail.google.com/chat/u/0/
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
@fragsalat
fragsalat / proxy.rs
Created November 28, 2019 15:24
A simple and lightweight multi threaded TCP proxy written in Rust language. Not using any 3rd-party libraries but just standard libraries.
use std::net::{TcpListener, SocketAddr, TcpStream, Shutdown, SocketAddrV4, Ipv4Addr};
use std::str::FromStr;
use std::thread::{spawn, JoinHandle};
use std::io::{BufReader, BufWriter, Read, Write};
fn pipe(incoming: &mut TcpStream, outgoing: &mut TcpStream) -> Result<(), String> {
let mut buffer = [0; 1024];
loop {
match incoming.read(&mut buffer) {
Ok(bytes_read) => {
@fragsalat
fragsalat / app.html
Last active March 15, 2019 09:27 — forked from jdanyow/app.html
Aurelia Gist
<template>
<h1>Children selected: ${allSelected}</h1>
<button click.delegate="add98Children()">Add 98 children</button>
<button click.delegate="add1Children()">Add 1 children</button>
<ul>
<li repeat.for="child of children">
${child.id} <input type="checkbox" checked.bind="child.selected" />
</li>
</ul>
</template>
@fragsalat
fragsalat / deep-expression-observer.js
Created March 11, 2019 09:58
Observer based on aurelia expressions which triggers subscribers also when children and parents changed.
@connectable()
@subscriberCollection()
export class DeepExpressionObserver {
constructor(scope, expression, observerLocator: ObserverLocator, lookupFunctions) {
this.scope = scope;
this.expression = expression;
this.observerLocator = observerLocator;
this.lookupFunctions = lookupFunctions;
}
@fragsalat
fragsalat / decorator.js
Created February 27, 2019 23:38
Aurelia computedFrom array of objects
import {Parser, Expression, ComputedExpression, Binding, Scope, createOverrideContext} from 'aurelia-binding';
class ComputedListExpression extends Expression {
/**
* @param {String} expressionStr Expression string for one dependency
*/
constructor(expressionStr: string) {
super();
const parser = new Parser();
@fragsalat
fragsalat / app.html
Last active August 21, 2018 10:22 — forked from jdanyow/app.html
Aurelia Gist
<template>
<require from="./children"></require>
<p>Below are groups which get's re-rendered every time you add a child or re-name one. You can see it because of the logged getter calls.</p>
<div repeat.for="group of groupedChildren">
<h3>${group.title}</h3>
<div repeat.for="child of group.children">
<children child.bind="child"></children>
</div>
</div>
<br/>
@fragsalat
fragsalat / app.html
Last active April 13, 2018 12:56
Binding Behavior binding
<template>
<require from="./lookup"></require>
<h1>${message}</h1>
<div repeat.for="item of items">
Index: $index | Id: ${item.id} | ${item.value & lookup:item.type}
</div>
<button click.delegate="addItem()">Add item ${items.length}</button>
</template>
@fragsalat
fragsalat / aurelia-template-engine.js
Created February 22, 2017 13:52
Small template renderer which acts like aurelia's template engine
const INTERPOLATION_START = '\\${';
const INTERPOLATION_END = '}';
const INTERPOLATION_EXPRESSION = new RegExp(`(${INTERPOLATION_START}(.*?)${INTERPOLATION_END})`, 'g');
class TemplateEngine {
constructor(template) {
this.baseTemplate = template;
}
@fragsalat
fragsalat / example.spec.js
Last active June 25, 2018 14:17
This is an example mock for aurelia-http-client. It provides the ability to expect outgoing calls and emulate the response to test the correct behavior of an function. The expectation can validate the URL, request method, request headers and request body.
import {HttpClientMock} from 'test/unit/mocks/http/http-client-mock';
import {reportUnfulfilled, reportUnexpected} from 'test/unit/mocks/http/mock-helper';
import {SomeViewModel} from 'app/view/some-view';
describe('A ViewModel', function() {
/** @type Element */
let host;
/** @type HttpClientMock */
let http;
/** @type SomeViewModel */
import {HttpClient} from 'aurelia-http-client';
import {Container} from 'aurelia-dependency-injection';
import {Rest} from 'app/util/rest';
import {Page} from 'app/model/page';
export class AbstractModel {
/**
* @type {Array<String>} list of excluded fields