Skip to content

Instantly share code, notes, and snippets.

View sim642's full-sized avatar

Simmo Saan sim642

View GitHub Profile
@sim642
sim642 / lcminv.py
Created July 5, 2015 15:32
lcminv problem - find all numbers b such that lcm(a, b) == l
from fractions import gcd
def lcm(a, b):
"""Least common multiple"""
return a * b // gcd(a, b)
def factor(n):
"""Factor natural number into primes and their powers"""
factors = {}
@sim642
sim642 / cmd_pass2.trigger
Last active August 29, 2015 14:27
WeeChat password hiding triggers "fixed" for multiple args
/trigger addreplace cmd_pass2 modifier "6000|input_text_display;6000|history_add;6000|irc_command_auth" "" "/.*/${tg_string}/tg_modifier X^((/(msg|m|quote) +nickserv +(id|identify|register|ghost +[^ ]+|release +[^ ]+|regain +[^ ]+) +)|/oper +[^ ]+ +|/quote +pass +|/set +[^ ]*password[^ ]* +|/secure +(passphrase|decrypt|set +[^ ]+) +)(.*)|.*X${re:+}Xtg_modifier /[^\ ]/*/tg_modifier X^((/(msg|m|quote) +nickserv +(id|identify|register|ghost +[^ ]+|release +[^ ]+|regain +[^ ]+) +)|/oper +[^ ]+ +|/quote +pass +|/set +[^ ]*password[^ ]* +|/secure +(passphrase|decrypt|set +[^ ]+) +)(.*)X${re:1}${tg_modifier}X"
@sim642
sim642 / ssh.md
Created August 28, 2015 19:35
Huvitavaid ssh seadistusi
@sim642
sim642 / _tutorial.md
Last active September 3, 2015 09:31
Parandatud ID kaardi Linuxi paigaldusskript
  1. Lae alla parandatud skript altpoolt (või kopeeri faili install-esteid-ubuntu.sh)
  2. Ava terminal samas kaustas, kus skript paikeb (nt failihalduris paremkliki alt)
  3. Anna käivitusõigused: chmod +x install-esteid-ubuntu.sh
  4. Käivita: ./install-esteid-ubuntu.sh
  5. Jälgi skripti käske
@sim642
sim642 / boost-windows.md
Last active March 16, 2026 08:07
Installing boost libraries for GCC (MinGW) on Windows

Installing boost libraries for GCC (MinGW) on Windows

Folder setup

  1. Extract downloaded boost source, e.g. C:\Program Files\boost_1_59_0.
  2. Create a folder for Boost.Build installation, e.g. C:\Program Files\boost-build.
  3. Create a folder within for building, i.e. C:\Program Files\boost_1_59_0\build.
  4. Create a folder for installation, e.g. C:\Program Files\boost.

GCC setup

  1. Open Command Prompt.
@sim642
sim642 / simLCD.cpp
Created April 10, 2016 17:09
Arduino library for Nokia 5110 screen with complete buffer support
#include "simLCD.h"
simLCD::simLCD()
{
clear();
}
simLCD& simLCD::setSCLK(int pin)
{
pinSCLK = pin;
@sim642
sim642 / nio-refactor.diff
Last active May 9, 2016 11:43
diff of refactoring Java NIO into shy, produced by shy, after importing git repository to shy
--- /src/main/java/ee/shy/cli/command/AddCommand.java
+++ /src/main/java/ee/shy/cli/command/AddCommand.java
@@ -2,21 +2,21 @@
import ee.shy.cli.Command;
import ee.shy.cli.HelptextBuilder;
import ee.shy.core.Repository;
-import java.io.File;
import java.io.IOException;
@sim642
sim642 / ArrayUtils.java
Last active May 15, 2016 16:12
Lexicographical array comparison
public final class ArrayUtils {
private ArrayUtils() {
}
public static <T extends Comparable<T>> int compare(T[] arr1, T[] arr2) {
int length = Math.min(arr1.length, arr2.length);
for (int i = 0; i < length; i++) {
int compare = arr1[i].compareTo(arr2[i]);
if (compare != 0)
public class Ch5_q7 {
public static void main(String[] args) {
int[] mateArray = new int[21];
int counter = 1, starter = 1;
mateArray[0] = 0;
while (counter < 21) {
if (starter != dividerSum(starter) && starter == dividerSum(dividerSum(starter))) {
if (starter != mateArray[counter-1]) {
mateArray[counter] = starter;
mateArray[counter+1] = dividerSum(starter);
@sim642
sim642 / HTTPS_rant.md
Last active February 21, 2018 15:26
HTTPS is Dangerous vol 2, aka webdev view

HTTPS is Dangerous vol 2, aka webdev view

A less-sensational and less-conspiratory follow-up to [Bryan Lunduke's "HTTPS is Dangerous"][lunduke].

Introduction

While Lunduke focuses on numerous high-level and theoretical issues with HTTPS, which are very controversial, this writing rant looks at actual practical issues regarding HTTPS advocacy and adoption. It is mainly from the point of view of a web application developer, who make up a fraction of web users, but also gives insight into related average user experience. I am basing this off of my own (probably somewhat unique) experiences during a project regarding the topic as there isn't similar discussion elsewhere.

My webapp

I don't consider myself a web developer, let alone a professional one; in fact I despise webdev for many reasons, including the ones discussed below. Nevertheless, a side project of mine, for now ~8 months (on and off), has been a [small webdev project][einstein-js] (referred to as "my webapp" below). **It is a purely