Skip to content

Instantly share code, notes, and snippets.

@DavidWells
DavidWells / javascript-proxy-as-rest-client.js
Last active October 6, 2023 18:39
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
@malja
malja / check_bank_account_number.php
Last active July 17, 2023 18:23
Validace čísla bankovního účtu pro Českou republiku v PHP.
<?php
/**
* Funkce pro kontrolu čísla bankovního účtu v ČR.
* @param $number string Řetězec obsahující číslo bankovního účtu ve formátu:
* [prefix]-základní část/kód bank.
* Prefix je volitelná část obsahující až šest čísel. Od
* základní části je oddělen pomlčnou.
* Základní část se skládá ze dvou až deseti čísel.
* Poslední částí je kód banky. Ten je složen ze čtyř čísel
@stalniy
stalniy / cordova-upload-transport.js
Created November 1, 2016 10:18
Ionic/Cordova file upload
import { Inject } from 'lib/angular2'
import { File, Transfer } from 'ionic-native'
import { Events } from 'events'
import { Config } from 'config/env'
@Inject(Events, Config)
export class CordovaUploadTransport {
get cacheDirectory() {
return cordova.file.tempDirectory || cordova.file.cacheDirectory
}
@btroncone
btroncone / ngrxintro.md
Last active February 9, 2024 15:37
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@djabif
djabif / dynamicAnchorFix.js
Last active March 18, 2017 09:27
Directive to open external links in Ionic App using inAppBrowser cordova plugin
//Use this directive to open external links using inAppBrowser cordova plugin
.directive('dynamicAnchorFix', function($ionicGesture, $timeout, $cordovaInAppBrowser) {
return {
scope: {},
link: function(scope, element, attrs) {
$timeout(function(){
var anchors = element.find('a');
if(anchors.length > 0)
{
angular.forEach(anchors, function(a) {
@katowulf
katowulf / filter_using_extend.js
Last active November 7, 2019 21:10
Filter records loaded into AngularFire based on some criteria.
// this will be much more efficient than $watch()
app.factory('FilteredArray', function($firebaseArray) {
function FilteredArray(ref, filterFn) {
this.filterFn = filterFn;
return $firebaseArray.call(this, ref);
}
FilteredArray.prototype.$$added = function(snap) {
var rec = $firebaseArray.prototype.$$added.call(this, snap);
if( !this.filterFn || this.filterFn(rec) ) {
return rec;
@kyleschmolze
kyleschmolze / back_button_manager.coffee
Created December 10, 2014 20:42
Easy back button service for Ionic on Android
# I wanted to be able to easily add back button callbacks to certain app states
# (using the word "state" here in the context of ui-router).
# For example, I always know that the back button on page X should quit the app, etc.
# So I wrote this nifty service.
angular.module("groupmuse").service "BackButtonManager", ($rootScope, $ionicPlatform) ->
managedStates = []
$rootScope.$on '$stateChangeSuccess', (event, next) ->
# Disable all listeners
@facultymatt
facultymatt / Procfile
Created April 12, 2013 16:23
Get Deployd running on Heroku!
web: node server
@iBobik
iBobik / family_names.txt
Last active June 4, 2019 21:59
Sample of most used Czech first and family names in the UTF-8 encoded TXT file, as form 1 name - 1 line, sorted from least used to most used. Useful for example for random data generators. Source: ČSÚ Vzorek nejpoužívanějších českých jmen a příjmení v TXT souboru kodovaném UTF-8 ve formě 1 jméno - 1 řádek, seřazených od nejméně používaných k nej…
ADAMÍROVÁ
ANTONYOVÁ
BABINSKÁ
BAKOŠOVÁ
BALÁNOVÁ
BARTEL
BEKROVÁ
BIEDERMANN
BLUDSKÝ
BRABLÍKOVÁ