This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun proper-bracket (bracket) | |
(cond | |
((string= "(" bracket) | |
(insert "\\left(\\right)") | |
(backward-char 8) | |
) | |
((string= "{" bracket) | |
(insert "\\left\\{\\right\\}") | |
(backward-char 9) | |
) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_bit4(inp): | |
if inp & 16 > 0: # 16 is just 0b1000 | |
return "on" | |
else: | |
return "off" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
NewerOlder