Skip to content

Instantly share code, notes, and snippets.

View lmumar's full-sized avatar

Lord Norlan Mumar lmumar

View GitHub Profile
@lmumar
lmumar / btree1.swift
Last active August 20, 2019 04:22
Construct binary tree from inorder and level order sequence
import Foundation
indirect enum Tree {
case empty
case node(data: Int, left: Tree, right: Tree)
}
extension Tree: CustomStringConvertible {
var description: String {
switch self {
@lmumar
lmumar / AnyComparable.swift
Created August 16, 2019 08:38
AnyComparable sample implementation
import Foundation
internal protocol _AnyComparableBox {
var _canonicalBox: _AnyComparableBox { get }
func _isEqual(to box: _AnyComparableBox) -> Bool
func _precede(to box: _AnyComparableBox) -> Bool
func _unbox<T: Comparable>() -> T?
}
extension _AnyComparableBox {
@lmumar
lmumar / react-es6-flow-emacs-configuration.md
Created July 17, 2019 03:16 — forked from CodyReichert/react-es6-flow-emacs-configuration.md
Configuring Emacs for react, es6, and flow

Configuring Emacs for react, es6, and flow

For a while, JSX and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.

This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.

Set up web-mode

web-mode provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.

@lmumar
lmumar / pythia
Last active May 3, 2022 23:39
Informal design document for pythia programming language
type Point = struct {
x, y: float
}
type PointPtr = ^Point
p : PointPtr
p = new Point
p.x = 100
p.y = 200
@lmumar
lmumar / rails_webpacker_bootstrap_expose_jquery.md
Created September 18, 2018 05:35 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collect all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new  --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@lmumar
lmumar / README.md
Created May 13, 2018 08:21 — forked from tuxmartin/README.md
Minimal Poco websocket C++ client

Stazeni a kompilace POCO

wget http://pocoproject.org/releases/poco-1.7.3/poco-1.7.3.tar.gz
tar xzf poco-1.7.3.tar.gz
cd poco-1.7.3
./configure --minimal --static --no-samples --no-tests
time make -j4 -s
cd lib/Linux/x86_64/
for f in *.a; do "strip $f"; done

Core Coding Standard

Coding practices are a source of a lot of arguments among programmers. Coding standards, to some degree, help us to put certain questions to bed and resolve stylistic debates. No coding standard makes everyone happy. (And even their existence is sure to make some unhappy.) What follows are the standards we put together on the Core team, which have become the general coding standard for all programming teams on new code development. We’ve tried to balance the need for creating a common, recognizable and readable code base with not unduly burdening the programmer with minor code formatting concerns.

Table Of Contents

@lmumar
lmumar / firewall-ufw
Created February 2, 2018 22:04 — forked from yourdesigncoza/firewall-ufw
UFW - Uncomplicated Firewall
# The Uncomplicated Firewall (ufw) is a frontend for iptables and is particularly well-suited for host-based firewalls. ufw provides a framework for managing netfilter, as well as a command-line interface for manipulating the firewall.
# resources
# https://wiki.ubuntu.com/UncomplicatedFirewall
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Enable and configure Firewall - ufw
# ufw firewall is installed by default on Ubuntu 12.04. gufw is a handy GUI frontends for ufw to manage the firewall.
@lmumar
lmumar / domain.md
Created January 24, 2018 00:24 — forked from vsavkin/domain.md
Building Rich Domain Models in Rails

Building Rich Domain Models in Rails

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about here.

@lmumar
lmumar / http_server.rs
Created January 14, 2018 14:03 — forked from mjohnsullivan/http_server.rs
Simple HTTP server example for Rust
// Updated example from http://rosettacode.org/wiki/Hello_world/Web_server#Rust
// to work with Rust 1.0 beta
use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
fn handle_read(mut stream: &TcpStream) {
let mut buf = [0u8 ;4096];