Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working from home

Julian David juliandavidmr

:octocat:
Working from home
View GitHub Profile
@yannxou
yannxou / ForegroundTextColor.swift
Created Dec 23, 2020
Foreground text color based on background color #SwiftUI
View ForegroundTextColor.swift
// Taken from Apple's App Dev Training: https://developer.apple.com/tutorials/app-dev-training/
/// This color is either black or white, whichever is more accessible when viewed against the scrum color.
var accessibleFontColor: Color {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
UIColor(self).getRed(&red, green: &green, blue: &blue, alpha: nil)
return isLightColor(red: red, green: green, blue: blue) ? .black : .white
}
View IN_PROGRESS.md

Projects in progress

Projects that entertain me in my spare time.

  • i18n-editor
  • superconvert
    • Page: Decode base64.
    • Page: Encode base64.
    • Page: Generate random number (allow max/min values).
    • Page: Generate random UUID.
View counterdown.ts
import { Observable, timer } from "rxjs";
import { map, takeWhile, take } from "rxjs/operators";
export function countdown(minutes: number, delay: number = 0) {
return new Observable<{ display: string; minutes: number; seconds: number, finished: boolean }>(
subscriber => {
timer(delay, 1000)
.pipe(take(minutes * 60))
.pipe(map(v => minutes * 60 - 1 - v))
.pipe(takeWhile(x => x >= 0 && !subscriber.closed))
@tukkajukka
tukkajukka / 20190417131115_test-setup.ts
Last active Dec 2, 2021
How to use Knex.js in a TypeScript project
View 20190417131115_test-setup.ts
import { Knex } from 'knex'
export async function up(knex: Knex): Promise<any> {
await knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => {
table.integer('foobar');
});
}
export async function down(knex: Knex): Promise<any> {
await knex.schema.dropTable('test_setup');
@juliandavidmr
juliandavidmr / pasos_para_entender_lib.md
Last active Dec 27, 2018
Pasos para entender un proyecto/librería de npm, github, gitlab, etc.
View pasos_para_entender_lib.md

Pasos para entender una librería

  • Leer la documentación general (Normalmente se encuentra en un archivo README.md o Wiki).
  • Determinar herramienta de empaquetación: Rollup, Webpack…
  • Determinar estándar usado: ES6, ES5, TypeScript…
  • Determinar archivo(s) de arranque (Normalmente se visualiza desde un principio en el package.json con la clave main).
  • Obtener listado de dependencias (package.json > dependencies) y observar su comportamiento/funcionamiento (puede observarse rapidamente en la documentación oficial de cada librería desde npm o git(hub|lab)).
  • Abrir archivo de arranque encontrado anteriormente:
    • Buscar función inicializadora, probablemente esté declarado con alguno de los siguientes nombres: boostrap, main, lib. En ES6, ES7 o Typescript se puede encontrar con la exportacion de una funcion anonima o una clase: export default function ...
    • La función inicializadora (parametros de constructuctor cuando se trata de class) puede
@overclock11
overclock11 / drag-drop.component.ts
Created Jul 26, 2018
Simple drag and drop Angular
View drag-drop.component.ts
import {Component, ElementRef, OnInit, Renderer2, ViewChild} from '@angular/core';
@Component({
selector: 'app-transaction-condition',
styleUrls: ['./transaction-condition.component.css']
template: `
<div class="list" id="list" #list>
<div id="0"
class="item drop-zone"
draggable="true"
@lokeshjain2008
lokeshjain2008 / fcm_config_files_proces.js
Created Apr 15, 2018
Ionic cordova-plugin-fcm error fix
View fcm_config_files_proces.js
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var path = require('path');
fs.ensureDirSync = function (dir) {
if (!fs.existsSync(dir)) {
dir.split(path.sep).reduce(function (currentPath, folder) {
currentPath += folder + path.sep;
@edrpls
edrpls / init.vim
Last active May 13, 2021
My neovim config on WSL/Ubuntu
View init.vim
set shell=/bin/sh
set termguicolors
set number
set ruler
set relativenumber
set cursorline
"set synmaxcol=1000
set clipboard=unnamed
"set list listchars=tab:\ ,eol:¬,trail:
@juliandavidmr
juliandavidmr / grammar.jison
Created Dec 27, 2017
grammar pseudo language
View grammar.jison
/* description: Parses end executes mathematical expressions. */
/* lexical grammar */
%lex
%%
\s+ /* skip whitespace */
[0-9]+("."[0-9]+)?\b return 'NUMBER'
"true" return 'TRUE'
"false" return 'FALSE'