Skip to content

Instantly share code, notes, and snippets.

View juliandavidmr's full-sized avatar
:octocat:
Working from home

Julian David juliandavidmr

:octocat:
Working from home
View GitHub Profile
@thonkinator
thonkinator / miniflare-in-sveltekit.md
Last active November 15, 2024 23:11
Miniflare in Sveltekit

Miniflare in SvelteKit!

This requires the package miniflare (NOT any of the @miniflare/-scoped packages), as well as @cloudflare/workers-types if you're using TypeScript. For setting up @sveltejs/adapter-cloudflare, see https://kit.svelte.dev/docs/adapter-cloudflare

// src/hooks.server.ts
import { dev } from "$app/environment";
import type { Miniflare } from "miniflare";
@yannxou
yannxou / ForegroundTextColor.swift
Created December 23, 2020 09:55
Foreground text color based on background color #SwiftUI
// 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
}

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.
@juliandavidmr
juliandavidmr / counterdown.ts
Created December 20, 2019 19:17
Counterdown + RxJS
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))
@jukkatupamaki
jukkatupamaki / 20190417131115_test-setup.ts
Last active November 9, 2024 17:31
How to use Knex.js in a TypeScript project
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 December 27, 2018 20:37
Pasos para entender un proyecto/librería de npm, github, gitlab, etc.

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 July 26, 2018 12:59
Simple drag and drop Angular
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 April 15, 2018 09:37
Ionic cordova-plugin-fcm error fix
#!/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 January 4, 2023 03:00
My neovim config on WSL/Ubuntu
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: