Skip to content

Instantly share code, notes, and snippets.

View Cauen's full-sized avatar
🎯
Focusing

Cauê Nolasco Cauen

🎯
Focusing
View GitHub Profile
@webstrand
webstrand / 000~nonempty-validator.ts
Last active June 20, 2023 16:37
Examples of the <T>(foo: Validator<T>) pattern in typescript
/******************************************************************************
* Implementation of `Nonempty` validator which checks that the provided type
* has at least one defined property, excluding `{}`.
******************************************************************************/
type Nonempty<T extends { [key: string]: any }> = { [P in keyof T]: T }[keyof T];
declare function wantsNonempty<T extends { [key: string]: any }>(x: Nonempty<T>): true;
wantsNonempty({ x: 1 });
wantsNonempty({}); // error expected
@VeraZab
VeraZab / LocalNotifications.js
Last active February 26, 2023 23:26
Simple local notification with Expo
import React, {Component} from 'react';
import {TextInput, View, Keyboard} from 'react-native';
import {Constants, Notifications, Permissions} from 'expo';
export default class Timer extends Component {
onSubmit(e) {
Keyboard.dismiss();
const localNotification = {
title: 'done',
@knxroot
knxroot / laravelUseless.flt
Created October 23, 2014 13:51
A WinMerge filter for compare 2 Laravel proyects
## This is a directory/file filter for WinMerge
## This filter is a helper for compare 2 laravel proyects in Windows
name: Exclude Laravel useless
desc: Exclude additional data from Laravel Proyects
## This is an inclusive (loose) filter
## (it lets through everything not specified)
def: include
## Filters for filenames begin with f:
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}