Skip to content

Instantly share code, notes, and snippets.

View nicobytes's full-sized avatar
🏠
Working from home

Nicolas Molina Monroy nicobytes

🏠
Working from home
View GitHub Profile
@nicobytes
nicobytes / deploy-gh.sh
Last active August 3, 2020 20:14
Deploy gh-pages ionic pwa
#!/bin/bash
git branch -D gh-pages
git push origin --delete gh-pages
git checkout -b gh-pages
ionic build --prod
find . -type d ! -path './www*' ! -path './.git*' ! -path '.' | xargs rm -rf
rm -r *.*
mv www/* .
rm -rf www
git add .
@nicobytes
nicobytes / page.ts
Created November 1, 2017 13:34
watchPosition
import { Geolocation } from '@ionic-native/geolocation';
...
constructor(private geolocation: Geolocation) {}
...
let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
apt-get update
apt-get install graphviz
pip install pygraphviz
pip install pyparsing==1.5.7
pip install pydot
python manage.py graph_models --pydot -a -g -o {{project}}-dbmodel.png
@nicobytes
nicobytes / app.component.ts
Last active February 15, 2018 18:45
app.component.ts
import { PageTopTransition } from './core/transitions/page-top.trasnsition';
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
@Component({
templateUrl: 'app.html'
})
node_modules/.bin/knex migrate:make migrate_name
node_modules/.bin/knex seed:make seed_name
vim ~/.ssh/config
Host name
HostName xxxx
Port 22
User root
IdentityFile ~/.ssh/your_key
ssh name
@nicobytes
nicobytes / gist:243760f9a1af798e8d7bf8531a1f6c65
Created April 22, 2019 14:12
Create service for docker-cleanup in docker swarm
docker service create -d \
-e CLEAN_PERIOD=900 \
-e DELAY_TIME=600 \
--log-driver json-file \
--log-opt max-size=1m \
--log-opt max-file=2 \
--name=cleanup \
--mode global \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
meltwater/docker-cleanup
export class GeneratorService {
generate(labels: string[], numRange: [number, number], width: number): EmployeeData[] {
const result: EmployeeData[] = [];
for (let i = 0; i < width; i += 1) {
result.push(this.generateNode(labels, numRange));
}
return result;
}
const fibonacci = (num: number): number => {
if (num === 1 || num === 2) {
return 1;
}
return fibonacci(num - 1) + fibonacci(num - 2);
};
static passwordMatchValidator(control: AbstractControl) {
const password: string = control.get('password').value; // get password from our password form control
const confirmPassword: string = control.get('confirmPassword').value; // get password from our confirmPassword form control
// compare is the password math
if (password !== confirmPassword) {
// if they don't match, set an error in our confirmPassword form control
control.get('confirmPassword').setErrors({ NoPassswordMatch: true });
}
}