Skip to content

Instantly share code, notes, and snippets.

View tonivj5's full-sized avatar
👨‍🎓
Studying...

Toni Villena tonivj5

👨‍🎓
Studying...
View GitHub Profile
@krimple
krimple / README.md
Last active June 7, 2018 15:37
Test and class under test for Http mocking - Angular 2 beta 1

This snippet is a working example of a test against the Http service in Angular 2.0.

It is a very simple test, and provides an example of how to:

  • Provide the right wiring to the test injector
  • Inject the fake XHRBackend (i.e. MockBackend)
  • Define a potential request
  • Run the request in the framework
  • Set expectations on the result

Revised generics design

Roger Peppe, 2018-09-01

One common response to the new generics design has been that contracts seem a bit too much like interfaces but not the same.

They are indeed very similar if you squint a little. Consider these two definitions:

type IReader interface {

Read([]byte)(int, error)

@ananace
ananace / user_settings.py
Created August 22, 2018 15:56
Example configuration for Steam Proton user settings
#!/usr/bin/env python3
import os
user_settings = {
#logs are saved to $HOME/steam-$STEAM_APP_ID.log, overwriting any previous log with that name
# "WINEDEBUG": "+timestamp,+pid,+tid,+seh,+debugstr,+module",
# "DXVK_LOG_LEVEL": "info",
@bmeurer
bmeurer / bench-instanceof-versus-typeof-megamorphic.js
Created January 28, 2019 15:10
Demonstrate the performance impact of using `instanceof` vs. checking for some existing property (in the megamorphic case)
// Copyright 2013-2019 Benedikt Meurer
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@EtienneR
EtienneR / Gulpfile.js
Created March 17, 2016 14:56
Auto reload your Go webserver with Gulp
const gulp = require('gulp'),
util = require('gulp-util'),
notifier = require('node-notifier'),
sync = require('gulp-sync')(gulp).sync,
reload = require('gulp-livereload'),
child = require('child_process'),
os = require('os');
var server = null;
@stupidawesome
stupidawesome / button.ts
Last active February 24, 2020 15:22
How to use ng-effects to create UI "traits"
import { ElementRef, Injectable, Renderer2 } from "@angular/core"
import { Context, Effect, State } from "ng-effects"
import { merge, Subject } from "rxjs"
import { disable, EventMap, fromEvents, toggle } from "../utils"
enum ButtonEvents {
"click",
"pointerenter",
"pointerleave",
"pointerdown",
@richjenks
richjenks / gmail.php
Last active April 29, 2020 23:16
Send email using a PHP 5.5 Generator and cURL
class Gmail {
private $mail;
private $email;
private $pass;
public function __construct($email, $pass){
$this->email = $email;
$this->pass = $pass;
}
@jesussegado
jesussegado / nx-generate-deps.ts
Last active July 15, 2020 09:56 — forked from westmark/nx-generate-deps.ts
package.json generator for @nrwl:node apps
import * as fs from 'fs';
import { resolve } from 'path';
import { promisify } from 'util';
import { argv as params } from 'yargs';
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const root = resolve(process.cwd());
@taxilian
taxilian / README.md
Last active July 15, 2020 15:33
Improved type definitions

Why these types?

These types are forked from the current (as of Jan 2020) mongoose types on definitelytyped; they add things like automatic handling of "lean" documents (including toObject) and advanced types for filter and update queries

Why not update these in DefinitelyTyped?

Well, I want to and I think we should, but I'm hesitant to try to push it through because there are some breaking

@dannyockilson
dannyockilson / <projectRoot>styles.scss
Created February 14, 2019 12:37
Angular + scss(optional) + Tailwindcss
/**
* This injects Tailwind's base styles, which is a combination of
* Normalize.css and some additional base styles.
*
* You can see the styles here:
* https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css
*
* If using `postcss-import`, use this import instead:
*
* @import "tailwindcss/preflight";