Skip to content

Instantly share code, notes, and snippets.

@Evanion
Evanion / datepicker.html
Created October 29, 2014 14:30
uk-datepicker in angular
<div class="uk-form-icon">
<i class="uk-icon-calendar"></i>
<input type="text" class="uk-width-1-1" ng-model="item.classified.meta.applyBy" data-uk-datepicker="{format:'DD.MM.YYYY'}" placeholder="{{ 'CLASSIFIED_CREATE_JOB_META_APPLYBY_DATE' | translate }}" />
</div>
@Evanion
Evanion / AuthService.js
Created November 6, 2014 08:45
Integrate Facebook in Iionic
(function() {
'use strict';
var module = angular.module('api.auth', [
'angular-data.DS',
'ngCordova'
]);
module.constant('AUTH_EVENTS', {
loginSuccess: 'auth-login-success',
@Evanion
Evanion / .bowerrc
Last active April 18, 2017 16:14
Revised Ionic build environment
{
"directory": "vendor"
}
@Evanion
Evanion / Intent.ts
Created August 19, 2019 12:50
StringEnum for Typescript
import StringEnum from './StringEnum';
export const Intent = StringEnum(['success', 'warning', 'error', 'info']);
export type Intent = keyof typeof Intent;
/**
* This allows you to declare an enum that can be used a both a type and value, while still allowing the user to use plain strings.
* The option to use plain strings is good when you are developing a library that might be used in a none TS project.
* example
````
const Message = (intent:Intent) => (message: string) => {
@Evanion
Evanion / README.md
Last active September 10, 2019 06:47
React-native form hook
@Evanion
Evanion / example.ts
Created August 30, 2021 11:07
Luhn mod N algorithm
const rawToken = "v83dtres";
const checksum = Luhn.generate(rawToken);
const testToken = `${rawToken}${checksum}`;
const isValid = Luhn.validate(testToken);
@Evanion
Evanion / grid-push-pull.less
Last active October 26, 2021 08:57
Responsive push/pull for uikit
/* Small */
@media (max-width: @breakpoint-small-max) {
[class*='uk-push-small-'],
[class*='uk-pull-small-'] { position: relative; }
/*
* Push
*/
@Evanion
Evanion / feature.context.ts
Created May 31, 2022 22:01
WIP: A React feature toggle system.
import { createContext } from 'react';
import { ActionProps, FeatureConfig, FeatureState } from './feature.types';
const dispatch = <Feature extends string | number>(
value: ActionProps<Feature>
) => {};
export const createFeatureContext = <Feature extends string | number>(
features: FeatureState<Feature>,
config: FeatureConfig
@Evanion
Evanion / build_number.js
Last active September 12, 2022 19:20
Build number hook
#!/usr/bin/env node
// Based on the 'replace text' hook found here: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/
// This hook should be placed in the 'after_prepare' hook folder.
// The hook relies on a JSON file located at '<project_root>/resources/.build.json' to track the build number.
// build.json content:
// {"build: 1}
// Add 'BUILDNR' to the version number in the '<project_root>/config.xml' file.
@Evanion
Evanion / fetch.hook.ts
Created November 7, 2022 12:23
useFetch hook for react.
import { DependencyList, useEffect, useReducer, useState } from "react";
interface State<T> {
data: T | null;
error: unknown | null;
loading: boolean;
loaded: boolean;
}
type Action<T> =