Skip to content

Instantly share code, notes, and snippets.

View 4gray's full-sized avatar
:octocat:
Focusing

4gray

:octocat:
Focusing
View GitHub Profile
@4gray
4gray / 01.sh
Created January 28, 2023 22:59
Create menubar app with Tauri
$ npm create tauri-app
@4gray
4gray / .mocharc.json
Last active December 29, 2020 22:29
Spectron Headless Testing on Github Actions CI
{
"require": "ts-node/register",
"watch-files": [
"./e2e/**/*.ts"
],
"timeout": 300000
}
@4gray
4gray / git-tag-delete-local-and-remote.sh
Created August 23, 2019 11:53 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@4gray
4gray / index.ts
Created October 30, 2018 13:40
Angular window resize listener
@HostListener('window:resize', ['$event'])
onResize(event) {
// magic here
}
@4gray
4gray / index.html
Created October 26, 2018 12:19
Angular If, Then, Else in html template
<ng-container*ngIf="isLoggedIn; then loggedIn; else loggedOut"></ng-container>
<ng-template #loggedIn>
<div>
Welcome back, friend.
</div>
</ng-template>
<ng-template #loggedOut>
<div>
Please friend, login.
@4gray
4gray / fileSize.ts
Created July 31, 2018 10:03 — forked from Solomko2/fileSize.ts
fileSize pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'fileSize'
})
export class FileSizePipe implements PipeTransform {
private units = [
'bytes',
'KB',
@4gray
4gray / gulpfile.js
Created December 30, 2017 13:13
Gulp: Sync folders
var gulp = require('gulp');
gulp.task('watch', function() {
return gulp.watch('./source/**/*', function(obj){
if( obj.type === 'changed') {
gulp.src( obj.path, { "base": "./source/"})
.pipe(gulp.dest('./dest'));
}
});
});
@4gray
4gray / image.component.ts
Created December 22, 2017 11:34
Append global event listener in Angular app
import {Renderer } from '@angular/core';
export class ImagegalleryComponent implements OnInit {
constructor(private renderer: Renderer, private imageService: ImageService) {
this._renderer.listen('document', 'dragstart', (evt) => {
this.imageService.setImageToUpload(evt.path[0].src, evt.path[0].id);
});
}
<div ng-class="condition ? 'class-if-true' : 'class-if-false'">
@4gray
4gray / ID.js
Created March 2, 2017 15:26
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`