Skip to content

Instantly share code, notes, and snippets.

View sim642's full-sized avatar

Simmo Saan sim642

View GitHub Profile
@sim642
sim642 / golomb.hs
Created June 3, 2021 15:57
Haskell Golomb sequence
golomb@(_:_:g) = 1 : 2 : 2 : concatMap (uncurry replicate) (zip g [3..])
-- golomb = 1 : 2 : g
-- where g = 2 : concatMap (uncurry replicate) (zip g [3..])
@sim642
sim642 / newline.patch
Last active July 18, 2020 07:31
WeeChat WIP patch for rendering \n in messages
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 7fb229e88..c65db3302 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -1244,8 +1244,10 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
int read_marker_x, read_marker_y;
int word_start_offset, word_end_offset;
int word_length_with_spaces, word_length;
+ int num_split_lines, i;
char *message_with_tags, *message_with_search;
module SICPInfSeries where
-- SICP, exercise 3.59
integrateSeries :: Fractional a => [a] -> [a]
-- integrateSeries s = helper s 1
-- where helper (a:as) n = a / n : helper as (n + 1)
integrateSeries s = zipWith (/) s nats
where nats = 1 : map (+1) nats
expSeries :: Fractional a => [a]
@sim642
sim642 / aoc2018-day20-tree.txt
Created December 20, 2018 14:35
Advent of Code 2018 day 20 regex AST tree
.SWWNNWNNESENNWWNWSSWSWWWSEEEE
.|N
.|.SSWWSSESSSEENNESSEEEENENEEENWNWSWWWS
.|.|.WW
.|.|.|SEEWWN
.|.|.|
.|.|.NEN
.|.|.|.WWW
.|.|.|.|NN
.|.|.|.|.W
@sim642
sim642 / reddit-sendbird.ts
Last active March 11, 2023 21:36
Reddit Chat (via SendBird) reverse engineering
import * as request from "request";
import * as SendBird from "sendbird";
const sendbirdServiceUrl = "https://sendbird.reddit.com";
const sendbirdAppId = "2515BDA8-9D3A-47CF-9325-330BC37ADA13";
const userId = "t2_mv8j9bt"; // chatrev1
const accessToken = "49777998329-oof4CSA1jedsnu6pXgJj_SFIk7o";
// accessToken (bearer):
// full (personalized) oauth2 access token (from web/installed reddit app): user id base 10 - oauth2 access token
@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

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 / 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)