Skip to content

Instantly share code, notes, and snippets.

(defun proper-bracket (bracket)
(cond
((string= "(" bracket)
(insert "\\left(\\right)")
(backward-char 8)
)
((string= "{" bracket)
(insert "\\left\\{\\right\\}")
(backward-char 9)
)
@Bolt64
Bolt64 / code.ipynb
Created July 20, 2018 16:28
Code for the model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# .latexmkrc starts
$pdf_mode = 1;
$pdflatex .= ' && (cp "%D" "%R.pdf"; echo Output file copied from "%D" to "%R.pdf" in current directory)';
$out_dir = 'build';
# .latexmkrc ends
#!/bin/bash
array=("a" "b" "c" "d" "e")
length=${#array[@]}
for i in $(seq 0 $(($length - 2)));
do
for j in $(seq $(($i + 1)) $(($length - 1)));
do
echo ${array[i]} ${array[j]}
#!/usr/bin/env python3
def sanitize(dens, amount):
return tuple(filter(lambda x: x<=amount, dens))
def memoize(func):
cache = {}
def inner(dens, amount):
dens = sanitize(dens, amount)
if not (dens, amount) in cache:
import scala.util.Random
object HashCollide {
def gen_random_lists(size: Int, upper: Int) = {
val s = Random.nextInt(size)
(1 to s).toList map (_ => Random.nextInt(upper))
}
def gen_list_of_list(size1: Int, size2: Int = 10, upper: Int = 20) = {
((1 to size1).toList map (_ => gen_random_lists(size2, upper))).distinct
@Bolt64
Bolt64 / algorithmic_complexity.c
Created July 6, 2015 19:04
A problem set for algorithmic complexity
#include <stdio.h>
#include <stdlib.h>
// All important code here
// Following the code, there are questions related to the code
// which you need to solve.
float power(float x, int n) { // Calculates the float x raised to n
if(n>=0) {
float result = 1;
@Bolt64
Bolt64 / show.scala
Created June 25, 2015 10:46
Showing that type erasure happens at compile time
object Temp {
def a(r: List[Int]): List[Int] = {
r map ((x: Int) => x*2)
}
def a(r: List[String]): List[String] = {
r map ((x: String) => x*2)
}
}
def check_bit4(inp):
if inp & 16 > 0: # 16 is just 0b1000
return "on"
else:
return "off"
#!/bin/bash
# Install the application imagemagick before using this script
TARGET_DIR=$1 # Unzip the file and the folder is the first argument
mkdir target # A temporary directory to hold the images
find "$TARGET_DIR" -name "*.jpg" -print0 | xargs -0 cp -t ./target
convert ./target/*.jpg output.pdf # output.pdf is the name of the output file
rm -r target