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 / gist:8614247
Created January 25, 2014 10:01
DownloadManager [Android]
/**
* Start Download
*/
public void startDownload(String link, String filename) {
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs();
DownloadManager mManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request mRqRequest = new DownloadManager.Request(Uri.parse(link));
mRqRequest.setDescription("Download file...");