Skip to content

Instantly share code, notes, and snippets.

@mikasjp
mikasjp / StringExtensions.cs
Created Apr 7, 2019
IsPalindrome C# String extension method example
View StringExtensions.cs
using System.Linq;
namespace Extensions
{
public static class StringExtensions
{
public static bool IsPalindrome(this string s)
{
var x = s.ToCharArray()
.AsEnumerable();
View spinlock.py
def Spinlock(jump, iterations):
buffer = [0]
position = 0
for i in range(iterations):
position = (position + jump) % buffer.__len__()
buffer.insert(position+1, i+1)
position += 1
return buffer
View Vector.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InertialNavigationSystem
{
public class Vector
{
View DataCollection-demo-data.txt
(Preferred) sampling frequency set to 120 Hz.
Your device may not support this sampling frequency, so always check your timestamps!
ATTITUDE 19.679428 29.673703 0.175603 -9.586614
ACCEL 19.679471 -0.046143 0.468903 0.756302
GYRO 19.679494 -0.381407 -0.411497 0.121990
MAGNETO 19.679516 114.264801 -1.040695 -513.457886
ATTITUDE 19.686156 29.557649 -0.011281 -9.501279
ACCEL 19.686205 -0.076935 0.510986 0.740234
GYRO 19.686226 -0.249177 -0.328551 0.109375
MAGNETO 19.686245 113.561630 -1.040695 -515.828735
View PasswordVerificator-salt.cs
using System;
using System.Security.Cryptography;
using System.Text;
public class PasswordVerificator
{
public static void Main()
{
string AuthenticationResult = AuthenticateUser("admin", "supersecretpassword","mysalt1f$gO3123qs")?"User authenticated!":"Access denied!";
Console.WriteLine(AuthenticationResult);
View users-hashed-salted-passwords.csv
USER PASSWORD SALT
admin 8d3df449c3ce323176ea8f786060da80b9d86c1f MnDXdJ1CNS
jankowalski 4cc55fc0736f4b5d73a8d9074350369230becd90 3nyJcEItdm
View users-hashed-passwords.csv
USER PASSWORD
admin 18960546905b75c869e7de63961dc185f9a0a7c9
View users-plaintext.csv
USER PASSWORD
admin supersecretpassword
View PasswordVerificator-good.cs
using System;
using System.Security.Cryptography;
using System.Text;
public class PasswordVerificator
{
public static void Main()
{
string AuthenticationResult = AuthenticateUser("admin", "supersecretpassword")?"User authenticated!":"Access denied!";
Console.WriteLine(AuthenticationResult);
View PasswordVerificator-bad.cs
using System;
public class PasswordVerificator
{
public static void Main()
{
string AuthenticationResult = AuthenticateUser("admin", "supersecretpassword")?"User authenticated!":"Access denied!";
Console.WriteLine(AuthenticationResult);
}