Skip to content

Instantly share code, notes, and snippets.

View Narshe1412's full-sized avatar
📚
On my way to something great!

Manuel Narshe1412

📚
On my way to something great!
View GitHub Profile
@Narshe1412
Narshe1412 / RoundOrDefault.ts
Created February 17, 2020 12:51
TypeScript round function with a default return value if the object provided is not defined or not a number
/**
* Given an object with a property, it tests if the property is a number and returns the round of that
* Otherwise returns the value provided by defaultValue, or null
* @param obj The object that contains the property to test
* @param prop The property that will be tested
* @param decimalsToRound The number of decimals to round to
* @param defaultValue The default value provided if it cannot complete the transaction
*/
export const roundOrDefault = (obj: any, prop: string, decimalsToRound: number, defaultValue = null) => {
if (!obj) {
@Narshe1412
Narshe1412 / url_reset.py
Created September 5, 2019 08:17
Urls for django password reset
from django.conf.urls import url
from django.core.urlresolvers import reverse_lazy
from django.contrib.auth.views import password_reset, password_reset_done, password_reset_confirm, password_reset_complete
urlpatterns = [
url(r'^$', password_reset, {'post_reset_redirect' : reverse_lazy('password_reset_done')}, name="password_reset"),
url(r'^done/$', password_reset_done, name="password_reset_done"),
url(r'^(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', password_reset_confirm, {'post_reset_confirm': reverse_lazy('password_reset_complete')}, name="password_reset_confirm"),
url(r'^complete$', password_reset_complete, name="password_reset_complete"),
]
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using StackExchange.Redis;
using WebApp;
namespace ClassLib.CacheExtension
@felixfbecker
felixfbecker / tasks.json
Last active March 9, 2021 01:28
VS Code Javac & JUnit tasks.json
/*
Example for quick Java compilation and unit tests in VS Code.
Works well with simple BlueJ projects.
Hit Ctrl+Shift+B to compile currently open file with javac.
Hit Ctrl+Shift+T to test currently open test class.
See red wiggles for compilation errors / failed assertions or click exclamation mark in the status bar.
Uses a few workarounds for individual commands per task and filename without extension.
This is written for Windows but it should be easy to adopt for Linux and Mac.
*/
{