Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Avaneesa RedGhoul

🌴
On vacation
View GitHub Profile
View deletedupes.sql
DELETE dupes
FROM jobtransparncyprod.JobPostings dupes, jobtransparncyprod.JobPostings fullTable
WHERE dupes.url = fullTable.url
AND dupes.title = fullTable.title
AND dupes.id > fullTable.id
@RedGhoul
RedGhoul / dupes.sql
Created Feb 25, 2020
How do I know if you have dupes
View dupes.sql
SELECT
title, url, count(*)
FROM
jobtransparncyprod.JobPostings
GROUP BY
title, url
Having
count(title) > 1
View InMemoryDBTesting.cs
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>(
View RenderTestingGETCall.cs
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>()
View Tables.html
<!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',
View BubbleSort.js
// 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
View FilterInJS.js
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
View ReduceInJS.js
// 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
View MapsInJS.js
// 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) =>{
View extensionsInSwift.swift
// 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 }
}