Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
happy to be alive!

Ron Klein kleinron

👋
happy to be alive!
View GitHub Profile
@kleinron
kleinron / lzma_sample.cpp
Created Jun 25, 2020 — forked from Treeki/lzma_sample.cpp
simple LZMA SDK compression/decompression example
View lzma_sample.cpp
// note: -D_7ZIP_ST is required when compiling on non-Windows platforms
// g++ -o lzma_sample -std=c++14 -D_7ZIP_ST lzma_sample.cpp LzmaDec.c LzmaEnc.c LzFind.c
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <memory>
#include "LzmaEnc.h"
#include "LzmaDec.h"
View ansi.py
import sys
from itertools import zip_longest
from traceback import print_exc
def grouper(iterable, n, fillvalue=None):
"""Collect data into fixed-length chunks or blocks"""
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)
@kleinron
kleinron / express_item.js
Created Feb 18, 2020
demonstrate code improvements
View express_item.js
import * as request from "superagent";
export class TokenExtractMiddleware {
constructor() {
}
extract = (req, res, next) => {
const url = `${process.env.AUTH_SERVICE}/auth/authenticate`;
View has_next.py
class hn_wrapper(object):
def __init__(self, it):
self.it = iter(it)
self._hasnext = None
def __iter__(self): return self
def next(self):
if self._hasnext:
result = self._thenext
else:
result = next(self.it)
View rsa-example.txt
https://8gwifi.org/RSAFunctionality?keysize=512
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKanYhwoySc0JjNjqT21f+4hXP+e1g1h
dz9wNj0XHii1luZtn8ydFRpzMF5CgECYO4jHMbuB2ZnPXU6Ar7t57HMCAwEAAQ==
-----END PUBLIC KEY-----
-----BEGIN RSA PRIVATE KEY-----
MIIBOQIBAAJBAKanYhwoySc0JjNjqT21f+4hXP+e1g1hdz9wNj0XHii1luZtn8yd
FRpzMF5CgECYO4jHMbuB2ZnPXU6Ar7t57HMCAwEAAQJACcZfls89nTMN2o3J63it
View tic-tac-toe-input-01.txt
OOXXO X O
XOOXXOOXO
XX XXOOOO
XO O OXX
XXXOO O
OXXXOXOOX
XXOOXOXOX
O O XOXXO
OO XXX
X OXO XXO
@kleinron
kleinron / MovieRecommender.java
Created Jan 21, 2018
MovieRecommender.java - interface
View MovieRecommender.java
package org.aftermath;
import java.util.List;
public interface MovieRecommender {
List<String> recommend();
}
View HelloWeb.java
package com.leadspace.tools;
import spark.Request;
import spark.Response;
import spark.Route;
import spark.Spark;
import java.util.Arrays;
public class HelloWeb {
View SomewhereInCode.java
// given that we already have an instance of shakersProvider
String color = getColor();
// no if-else, and no switch-case-default, the provider should do the work (aka service locator)
IShaker shaker = shakersProvider.getByColor(color);
shaker.shake();
// or with reusable constants
View MyColors.java
public enum MyColors {
White,
Green,
Blue,
Brown
}