Skip to content

Instantly share code, notes, and snippets.

@candh
candh / quicksort.el
Created January 5, 2019 18:33
elisp quicksort
;; https://harryrschwartz.com/2014/04/08/an-introduction-to-emacs-lisp.html
;; this is amazing
(require 'cl-remove-if-not)
(defun quicksort (items)
(if (null items)
nil
(let* ((pivot (car items))
(rest (cdr items))
(lesser (cl-remove-if-not (lambda (x) (<= x pivot)) rest))
@candh
candh / elisp.el
Created January 26, 2019 23:59
Elisp cheatsheet.
;; from https://harryrschwartz.com/2014/04/08/an-introduction-to-emacs-lisp.html
43
3.0
"foo!"
;; FUNCTIONS
(+ 1 2 3 4 5)
@candh
candh / makefile
Last active February 27, 2019 16:04
makefile for OpenGL projects in C for both Mac and Linux (Works with gcc versions >= 5.5 on linux. Tested on Ubuntu)
# candh
# set compiler
CC = gcc
MACFLAGS = -framework OpenGL -framework GLUT
LINFLAGS = -lGL -lGLU -lglut
TARGET = main
mac:
@candh
candh / CMakeLists.txt
Created February 9, 2019 22:11
CMakeList for OpenGL. Tested on macOS only. Seems Finicky
cmake_minimum_required(VERSION 3.6)
project(Testing C)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
if (OPENGL_FOUND)
message("opengl found")
message("include dir: ${OPENGL_INCLUDE_DIR}")
message("link libraries: ${OPENGL_gl_LIBRARY}")
@candh
candh / opengl.c
Last active February 18, 2019 14:16
opengl.c template for mac, linux and windows.
#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION
#include <GLUT/glut.h>
#else
#ifdef _WIN32
#include <window.h>
#endif
// linux and win
#include <GL/glut.h>
#endif
@candh
candh / data.sql
Created April 28, 2019 12:22
w3resources is dumb
INSERT INTO reviewer (rev_id, rev_name) VALUES(9001, 'Righty Sock')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9002, 'Jack Malvern')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9003, 'Flagrant Baronessa')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9004, 'Alec Shaw')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9005, '')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9006, 'Victor Woeltjen')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9007, 'Simon Wright')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9008, 'Neal Wruck')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9009, 'Paul Monks')
INSERT INTO reviewer (rev_id, rev_name) VALUES(9010, 'Mike Salvati')
@candh
candh / node-creation.tcl
Created November 23, 2019 17:59
[DCCN] 1st lab NS2
#Create a simulator object
set ns [new Simulator]
#Open the NAM trace file
set nf [open out.nam w]
$ns namtrace-all $nf
# Define finish procedure
proc finish {} {
global ns nf
@candh
candh / ass4.asm
Created December 1, 2019 14:08
find largest number in assembly
.stack 100h
.model small
.data
arr dw 12, 25, 7, 44
N dw 4
MAXN dw 0
msg1 db "Max = $"
.code
main proc
mov ax, @data
# create a new simulator object
set ns [new Simulator]
# define different colors for data flows
# as defined by fid_
$ns color 1 Blue
$ns color 2 Red
$ns color 3 Green
$ns color 4 Black

Keybase proof

I hereby claim:

  • I am candh on github.
  • I am candh (https://keybase.io/candh) on keybase.
  • I have a public key ASD_UGMX3e3adX1iK3WZVGDW3onwh_tdj2kZBryJK6u8Swo

To claim this, I am signing this object: