Skip to content

Instantly share code, notes, and snippets.

@Foovanadil
Foovanadil / clientsideFileDownload.js
Last active August 12, 2024 21:57
JS Clientside download file from blob
const clientsideDownloadFile = (blob,fileName) => {
// Test download attribute first
if ('download' in HTMLAnchorElement.prototype) {
// Create an object URL for the blob object
const url = URL.createObjectURL(blob);
// Create a new anchor element
const a = document.createElement('a');
a.href = url;
a.download = fileName;
import { Injectable } from '@angular/core';
import { AbstractControl } from '@angular/forms';
@Injectable()
export class CustomValidators {
min(control: AbstractControl, value: number): { [key: string]: boolean } {
return control.value >= value ? null : { 'min': true };
}
@Foovanadil
Foovanadil / minMaxValidator.ts
Last active February 27, 2017 22:12
Min Max validator directives for Angular 2 (since they don't exist currently in angular 2)
import { Directive, forwardRef, Attribute, Injectable, ElementRef, Input } from '@angular/core';
import { NG_VALIDATORS, Validator, AbstractControl, FormControl } from '@angular/forms';
import { CustomValidators } from './customValidators';
@Directive({
selector: '[min][formControlName],[min][formControl],[min][ngModel]',
providers: [{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => MinValidator),
multi: true
@Foovanadil
Foovanadil / TimeProvider.vb
Last active March 11, 2016 17:46
VB version of the Time Provider... Like anyone would ever need this...
Public MustInherit Class TimeProvider
Private Shared _current As TimeProvider = DefaultTimeProvider.Instance
Public Shared Property Current As TimeProvider
Get
Return _current
End Get
Set
If Value Is Nothing Then
@Foovanadil
Foovanadil / 1.py
Created July 2, 2015 04:48
String makeTrans example
import string
sourceText = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
input = "abcdefghijklmnopqrstuvwxyz"
map = "cdefghijklmnopqrstuvwxyzab"
trans = string.maketrans(input,map);
@Foovanadil
Foovanadil / 0.py
Created June 25, 2015 05:22
Python Challenge exercise 1
import webbrowser
url = "http://www.pythonchallenge.com/pc/def/{0}.html"
newUrl = url.format(2**38)
print newUrl
webbrowser.open(newUrl)
@Foovanadil
Foovanadil / ngFilters.html
Created March 26, 2015 03:29
HTML for Search Filter
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>ngFilters</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.1/css/foundation.css">
</head>
<body>
<!--ng-app value matches Angular module string name in js file-->
@Foovanadil
Foovanadil / ngFilters.js
Created March 26, 2015 03:29
Search Highlight
var myApp = angular.module('myApp', []);
myApp.factory('Avengers', function () {
var Avengers = {};
Avengers.cast = [{
name: "Robert Downey Jr.",
character: "Tony Stark / Iron Man"
},
{
name: "Chris Evans",
@Foovanadil
Foovanadil / MainActivity.cs
Last active August 29, 2015 14:07
Xamarin Android Main Activity example for starting an IntentService.
using System.IO;
using Android.App;
using Android.Content;
using Android.Widget;
using Android.OS;
using TIG.Todo.Common;
using Android.Content.PM;
using TIG.Todo.Common.SQLite;
namespace TIG.Todo.AndroidApp
@Foovanadil
Foovanadil / GeofenceIntentService.cs
Last active August 29, 2015 14:07
Xamarin Android IntentService Example
using Android.App;
using Android.Content;
using Android.Support.V4.App;
using Android.Gms.Location;
using Android.Locations;
namespace TIG.Todo.AndroidApp
{
[Service]