Skip to content

Instantly share code, notes, and snippets.

View RedGhoul's full-sized avatar
🌴
On vacation

RedGhoul

🌴
On vacation
View GitHub Profile
from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include
from first_app import views
urlpatterns = [
url(r'^$',views.index,name='index'),
url(r'^admin/', admin.site.urls),
url(r'^first_app/',include('first_app.urls')),
]
from django.conf.urls import url
from first_app import views
# is key word needs to be right
urlpatterns = [
url(r'^$',views.index, name='index'),
]
// here we have the type we are trying to extend the double
// notice how we can extend anything, even a built in type like Double
extension Double {
var km: Double { return self * 1_000.0 }
var m: Double { return self }
var cm: Double { return self / 100.0 }
var mm: Double { return self / 1_000.0 }
var ft: Double { return self / 3.28084 }
}
@RedGhoul
RedGhoul / MapsInJS.js
Last active March 11, 2019 18:20
MapsInJS
// Array you wanna do the operation on
const peopleArray = [ {Name: "Tim", BankBalance: 10},
{Name: "Leo", BankBalance: 20},
{Name: "Sam", BankBalance: 30} ];
// calling the Map function and having it return its value into
// reformattedArray. Where "obj" represents each object in the
// peopleArray
let reformattedArray = peopleArray.map((obj) =>{
@RedGhoul
RedGhoul / ReduceInJS.js
Last active March 11, 2019 18:34
ReduceInJS
// Here we have a list of all the transactions made by Mike
const transActionsForMike = [ {Name: "Bike", Cost: 5000},
{Name: "Apple Music", Cost: 20},
{Name: "Cook Book", Cost: 30},
{Name: "Azure Hosting", Cost: 60},
{Name: "Phone Bill", Cost: 70}];
// And we try to figure out how much Mike Spent
// "reduce" takes in three main arguments, the Accumulator (acc), the
// currentValue (curr) in the form of an anonymous function. And a inital
@RedGhoul
RedGhoul / FilterInJS.js
Created March 11, 2019 18:56
FilterInJS
const transActionsForMike = [ {Name: "Bike", Cost: 5000},
{Name: "Apple Music", Cost: 20},
{Name: "Cook Book", Cost: 30},
{Name: "Azure Hosting", Cost: 60},
{Name: "Phone Bill", Cost: 70}];
// As seen in Reduce and Map, we can add more elements into the
// anonymous functions such as the index and the whole array
// filter gives us each element in the array. We then have to return
// Note this is without any optimizations
const bubblesort = (arr) => {
// We have a loop here to slowly shrink how much of the array we cover
// So that we don't constantly keep looping over the whole array
for(let i = arr.length; i > 0; i--){
// This loop, covers the length of the array given to us by the
// loop above.
for(let j = 0; j < i - 1; i ++){
// Here we do the comparison that asks the question
@RedGhoul
RedGhoul / Tables.html
Created June 25, 2019 01:34
YOLO_LYFE
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Table</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var data = {
ALL: [
'SUPER_R:EditPages',
public class LoanFormShould
{
[Fact]
public async Task RenderApplicationForm()
{
// Creating a web Host Builder to put in your test server
var builder = new WebHostBuilder()
.UseContentRoot(@"Enter your Path here to project")
.UseEnvironment("Development")
.UseStartup<loans.Startup>()
public void ConfigureServices(IServiceCollection services)
{
if (CurrentEnvironment.IsDevelopment()) // Here is where we check
{
services.AddDbContext<AppDbContext>(
options => options.UseInMemoryDatabase()); // And we ask it to use the InMemoryDatabase Option
}
else
{
services.AddDbContext<AppDbContext>(