Skip to content

Instantly share code, notes, and snippets.

View Danielkaas94's full-sized avatar
💜
Unconditional love to everyone

Daniel Kaas Bundgaard Jørgensen Danielkaas94

💜
Unconditional love to everyone
View GitHub Profile
@Danielkaas94
Danielkaas94 / GetIntegersFromList.cs
Created January 29, 2018 18:20
GetIntegersFromList & GetIntegersFromList2
public static IEnumerable<int> GetIntegersFromList(List<object> listOfItems)
{
// Believe 👍
List<int> integerList = new List<int>();
int content;
foreach (var item in listOfItems)
{
if (item is int)
{
int.TryParse(item.ToString(), out content);
@Danielkaas94
Danielkaas94 / VowelIndices in C#.cs
Last active January 29, 2018 18:22
VowelIndices in my way and as lambda/RegularExpression
private static int[] VowelIndices(string word)
{
List<int> myVowelList = new List<int>();
for (int i = 0; i < word.Length; i++)
{
switch (word.ToLower()[i])
{
case 'a':
myVowelList.Add(i + 1);
@Danielkaas94
Danielkaas94 / CountSmileys.cs
Last active January 29, 2018 18:23
CountSmileys in my way and as RegularExpression
private static int CountSmiley(string[] smileys)
{
// :) :D ;-D :~) - Valid.
// ;( :> :} :] - Invalid.
int counter = 0;
foreach (string item in smileys)
{
switch (item)
{
@Danielkaas94
Danielkaas94 / ArrayPlusArray.cs
Last active January 29, 2018 18:24
ArrayPlusArray in my way and as lambda expression
private static int ArrayPlusArray(int[] arr1, int[] arr2)
{
int preSum1 = 0;
int preSum2 = 0;
for (int i = 0; i < arr1.Length; i++)
{
if (arr1[i] > 0)
{
preSum1 += arr1[i];
@Danielkaas94
Danielkaas94 / AlphabetPosition.cs
Created February 1, 2018 14:49
AlphabetPosition "The sunset sets at twelve o' clock." => "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11" as a string
/// <summary>
/// Replace every letter with its position in the alphabet.
/// If anything in the text isn't a letter, ignore it and don't return it.
/// A being 1, B being 2, etc.
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static string AlphabetPosition(string text)
{
int index;
/// <summary>
/// Check to see if a string has the same amount of 'x's and 'o's.
/// The method must return a boolean and be case insensitive.
/// </summary>
/// <param name="input">The string can contain any char.</param>
/// <returns></returns>
public static bool XO(string input)
{
int xCounter = 0;
int oCounter = 0;
@Danielkaas94
Danielkaas94 / ToCamelCase.cs
Created February 8, 2018 18:02
ToCamelCase & ToCamelCase2
/// <summary>
/// Converts dash/underscore delimited words into camel casing.
/// The first word within the output should be capitalized only if the original word was capitalized.
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string ToCamelCase(string str)
{
StringBuilder sb = new StringBuilder();
string tempStr = str;
@Danielkaas94
Danielkaas94 / FindingSpoofedWebsites.js
Created April 17, 2018 18:22
Finding Spoofed Websites
javascript:alert("The actual URL is:\t\t" + location.protocol + "//" + location.hostname + "/" + "\nThe address URL is:\t\t" + location.href + "\n" + "\nIf the server names do not match, this may be a spoof.");
@Danielkaas94
Danielkaas94 / Edit.js
Created April 17, 2018 18:24
Edit Website
javascript:document.body.contentEditable='true'; document.designMode='on'; void 0
@Danielkaas94
Danielkaas94 / Astroid.js
Created April 17, 2018 18:17
Astroid shooting on WebSite
javascript:var s = document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='http://erkie.github.com/asteroids.min.js';void(0);