Skip to content

Instantly share code, notes, and snippets.

@AndrewLane
AndrewLane / index.py
Last active August 3, 2022 23:59
"Interview question of the week" from Cassidy Williams 31-Jul-2022
# algorithm idea
# The number of times 1 is in the 1s place is the total number of 10s in the number, plus a potential bonus 1
# The number of times 1 is in the 10s place is ten times the total number of 100s in the number, plus a potential bonus 10
# ...
# The number of times 1 is in the (10**x)s place is 10**x times the total number of 10**(x+1) in the number, plus a potential bonus 10**x
def process_more_efficiently(num):
if num <= 0:
return 0
string_rep_of_num = str(num)
@AndrewLane
AndrewLane / index.py
Created June 21, 2022 18:42
"Interview question of the week" from Cassidy Williams 20-Jun-2022
def prev_fibonacci_number(fibo):
'''Given a number that could be part of the fibonacci sequence, find its predecessor in the fibonacci
sequence or return -1 if it's not part of the sequence
We really only need to keep track of the most recent two numbers we've seen in the sequence, just in case
this needs to be used on super large numbers'''
if fibo <= 0:
return -1
@AndrewLane
AndrewLane / cloudSettings
Created February 13, 2020 18:15
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-13T18:15:40.256Z","extensionVersion":"v3.4.3"}
@AndrewLane
AndrewLane / keybase.md
Created November 12, 2018 02:29
keybase.md

Keybase proof

I hereby claim:

  • I am andrewlane on github.
  • I am andrewwlane (https://keybase.io/andrewwlane) on keybase.
  • I have a public key ASAJjermM_jtC5CQAyxcYOE5_Lw3Eiczf77wbBFLvcMs_go

To claim this, I am signing this object:

using System;
using System.Threading.Tasks;
using Amazon;
using Ninject;
using Rebus.Config;
using Rebus.Log4net;
using Rebus.Ninject;
using Rebus.Routing.TypeBased;
using Shared.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using RestSharp.Authenticators;
namespace LocalyticsPushPlayground
{
@AndrewLane
AndrewLane / SortDiagnostic.cs
Created January 13, 2015 17:49
NLS_SORT and Oracle 11g vs 12c
using System;
using System.Configuration;
using System.Text.RegularExpressions;
using Oracle.ManagedDataAccess.Client;
namespace SortDiagnostic
{
class Program
{
const string queryToRun = @"SELECT data FROM (SELECT ROW_NUMBER() OVER (order by data ASC)
@AndrewLane
AndrewLane / 11g database result (qa3iad)
Created January 13, 2015 17:17
Oracle 11g vs Oracle 12c NLS_SORT issue
Data before 'alter session'...
----------
BulkEdit_Completed
BulkEdit_Delete Recurring Daily Queued
BulkEdit_Delete Recurring Daily Queued - Daily
BulkEdit_Delete Recurring Daily Queued - Daily
Job 1
Job 2
Job 3
Nov._4th_2014
@AndrewLane
AndrewLane / Program.cs
Created March 20, 2013 16:03
Showing flushing a couchbase bucket via API doesn't seem to work
using System;
using Couchbase;
using Enyim.Caching.Memcached;
namespace TryToFlushCouchbaseBucket
{
class Program
{
private static void Main(string[] args)
{
@AndrewLane
AndrewLane / bcrypt.php
Created January 7, 2013 21:25
BCrypt unit tests in PHP
<?php
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
die("At least PHP 5.3.7 is required");
}
function bcryptHash($plainTextPassword, $cost = 10)
{
if ($cost < 4 || $cost > 31) {
die("Invalid cost: " . $cost);