This file contains hidden or 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
| # ######################################################################### | |
| # This bash script adds tab-completion feature to django-admin.py and | |
| # manage.py. | |
| # | |
| # Testing it out without installing | |
| # ================================= | |
| # | |
| # To test out the completion without "installing" this, just run this file | |
| # directly, like so: | |
| # |
This file contains hidden or 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
| /** | |
| * <b>Fixed Point Combinator is:</b> | |
| * Y = λf.(λx.f (x x)) (λx.f (x x)) | |
| * | |
| * <b>Proof of correctness:</b> | |
| * Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y) | |
| * = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g) | |
| * = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable) | |
| * = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function) | |
| * = g (Y g) (by second equality) [1] |
This file contains hidden or 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
| val primes: Stream[Int] = 2 #:: Stream.from(3).filter { n => !primes.takeWhile(_ <= math.sqrt(n)).exists(n % _ == 0) } | |
| def isPrime(n: Int) = primes.dropWhile(_ < n).head == n |
This file contains hidden or 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
| gdb -batch -ex 'call close(3)' -p <PID> # closes file descriptor 3 for process with <PID> |
This file contains hidden or 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 | |
| # | |
| # Build shell command completions | |
| # | |
| function _build_completions { | |
| local current_word | |
| COMPREPLY=() | |
| current_word=${COMP_WORDS[COMP_CWORD]} |
This file contains hidden or 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 | |
| # Given a logfile with pairwise loglines when an event starts, and when it finishes, | |
| # this script plots the duration for the events. | |
| # Feed me a log file with rows like these: | |
| # 2014-07-21 07:50:03,440 INFO Begin job | |
| # 2014-07-21 07:52:50,530 INFO End job | |
| # 2014-07-21 08:00:03,044 INFO Begin job | |
| # 2014-07-21 08:02:02,548 INFO End job |
This file contains hidden or 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 | |
| rlwrap tr -d '\n\r' | tr -sc [:alnum:] '_' | tr [:upper:] [:lower:] |
This file contains hidden or 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 java.io.ByteArrayInputStream | |
| import java.io.ByteArrayOutputStream | |
| import scala.sys.process._ | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.Future | |
| import scala.concurrent.blocking | |
| import scala.concurrent.Await | |
| import scala.concurrent.duration._ |
This file contains hidden or 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 | |
| FILE="$1" | |
| PORT=${PORT:-9999} | |
| MIME_TYPE=$(mimetype "$FILE") | |
| SIZE_BYTES=$(du -b "$FILE" | cut -f1) | |
| FILE_NAME=$(basename "$FILE") | |
| HEADER="\ | |
| HTTP/1.1 200 OK |
This file contains hidden or 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 getUnsafeInstance: sun.misc.Unsafe = { | |
| val f = classOf[sun.misc.Unsafe].getDeclaredField("theUnsafe") | |
| f.setAccessible(true) | |
| val unsafe = f.get(null).asInstanceOf[sun.misc.Unsafe] | |
| unsafe | |
| } |