Skip to content

Instantly share code, notes, and snippets.

@burhanloey
burhanloey / VLSM.java
Last active January 14, 2024 18:29
Example of VLSM Subnet Calculation
/*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
@burhanloey
burhanloey / wrap-self-link.clj
Last active December 12, 2015 07:15
Middleware for Compojure+Ring to add self link in REST API response
@burhanloey
burhanloey / soundcloud-api-then-method.cljs
Created March 31, 2016 05:09
Example for using .then() method in SoundCloud API in ClojureScript
;; (.then (.then (.connect js/SC)
;; (fn [] (.get js/SC "/me")))
;; (fn [me] (js/alert (str "Hello, " (.-username me)))))
(.. (.connect js/SC)
(then #(.get js/SC "/me"))
(then #(js/alert (str "Hello, " (.-username %)))))
@burhanloey
burhanloey / build.gradle
Created May 26, 2017 18:57
Gradle config to run servlet-web-applications from kotlin-examples using Embedded Tomcat
// Usage:
//
// Run './gradlew tomcatRunWar'
// Visit http://localhost:8080/servlet-web-applications/hello
buildscript {
ext.kotlin_version = '1.1.2'
repositories {
jcenter()
}
@burhanloey
burhanloey / translate_forfun.lisp
Last active May 27, 2017 19:53
Playing around with Lisp macro to translate Common Lisp core functions to Malay language
;; MIT License
;; Copyright (c) 2017 Burhanuddin Baharuddin
;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
@burhanloey
burhanloey / euler-23.lisp
Last active July 16, 2017 15:57
Problem 23: Brute force method (took around 80 seconds, < 40 seconds if limit set to 20161)
(ql:quickload :cl-arrows)
(ql:quickload :lparallel)
(defpackage :euler-playground
(:use :cl :lparallel :cl-arrows))
(in-package :euler-playground)
(defconstant +limit+ 28123)
(defvar *abundant-numbers* '())
@burhanloey
burhanloey / KotlinPlayground.kt
Last active August 5, 2017 02:22
Constructing DSL to make readable Malay language sentence using Kotlin's extension functions
package kotlinplayground
fun List<Int>.kemudian() = apply { }
fun List<Int>.dan() = apply { }
fun Int.sehingga(x: Int): IntRange = rangeTo(x)
fun diberiSenarai(x : IntRange): List<Int> = x.toList()
@burhanloey
burhanloey / emacs-in-terminal.txt
Last active August 7, 2017 12:06
Instructions to open Emacs in terminal using the same colors as Emacs GUI
This is for xfce4-terminal.
Shortcuts:
Ctrl+Alt+t - Open terminal
Ctrl+Shift+t - Open new tab
Ctrl+PgUp/PgDown - Switch tab
Ctrl+Shift+w - Close tab
To make terminal uses 256-color mode, type:
export TERM=xterm-256color
@burhanloey
burhanloey / hello-ccl.lisp
Created August 8, 2017 13:29
Creating executables from different Common Lisp implementation
(defun main ()
(format t "Hello World!~%"))
(save-application "hello-ccl" :toplevel-function #'main :prepend-kernel t)
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi