Skip to content

Instantly share code, notes, and snippets.

How to fix missing Safari Extensions

  • Quit Safari
  • Open a Terminal and execute this command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
  • Open Safari
@beached
beached / iterator_templates.md
Last active August 15, 2024 23:02
Templates for Iterators

Input Iterator

struct input_iterator {  
  using value_type = T;
  using reference = T const &;
  using pointer = T const *;
  using difference_type = std::ptrdiff_t;
  using iterator_category = std::input_iterator_tag;

  pointer ptr;
@beached
beached / C++ normal operators.md
Last active July 21, 2024 23:09
A list of the normal signatures of C++ operators that allow overloading

C++ Operator Signatures

This is a list of C++ operators that can be overloaded and their normal signatures(a.k.a what an int would do). The order is the preffered order to use them(The first one listed is often preffered)

Arithmetic

operator+ addition

  • free function -> T operator+( T const & lhs, T const & rhs )
  • member function -> T operator+( T const & rhs ) const

operator+ unary plus

  • member function -> T operator+( ) const
using System;
using System.IO;
namespace CSVExport {
public class CSVExport {
private static string CsvEscape( object value ) {
if(value is null) {
return string.Empty;
}
string str = value.ToString( );
return @"""" + str.Replace( @"""", @"""""" ) + @"""";
// The MIT License (MIT)
//
// Copyright (c) 2018 Darrell Wright
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files( the "Software" ), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
char[] message = "Secret message!".toCharArray();
char[] userPassword = input("Enter your password: ");
//16 bytes twice PBKDF2 minimum salt recommendation
byte[] salt = SecureRandom.getBytes(16);
//Why did I use SHA512? see note at the bottom
//produce 64 bytes of secretmaterial from user password
byte[] secretMaterial = PBKDF2(userPassword, salt, 5000, "SHA512", 64);
@beached
beached / punycode.js
Created August 14, 2016 04:41 — forked from bnoordhuis/punycode.js
javascript punycode encoder and decoder
/**
* Copyright (C) 2011 by Ben Noordhuis <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
#1 GND -> 10 #2 TVS -> 3.3
#3 DBGCLK -> 18 #4 DBGDAT -> 17
#5 CSn -> 09 #6 SCLK -> 08
#7 RESETn -> 05 #8 MOSI -> 07
#9 3.3v -> 01 #10 MISO -> 06
# number is the cc debugger pin number
the -> number is the XRF pin number
Hole on odd side
@beached
beached / mixed_traits.cpp
Last active August 29, 2015 14:13
Succinct way of mixing several type traits to create new one
#include <type_traits>
template<typename T>
using is_numeric = std::integral_contstant<bool, std::is_integral<T>::value || std::is_floating_point<T>::value>;
template<typename T> using is_numeric_t = typename is_numeric<T>::type;
@beached
beached / rounding_fun.cpp
Last active August 29, 2015 14:12
Some useful little functions to round, ceil, and floor to the nearest N. A little rough, but they work
template<class T, class U>
T round_by( T const & value, U const & rnd_by ) {
static_assert(std::is_arithmetic<T>::value, "First template parameter must be an arithmetic type");
static_assert(std::is_floating_point<U>::value, "Second template parameter must be a floating point type");
const auto rnd = round( static_cast<U>(value) / rnd_by );
const auto ret = rnd*rnd_by;
return static_cast<T>(ret);
}
template<class T, class U>