Remove snippets

This is not the way I want to present them
This commit is contained in:
Tom Willemsen 2013-01-19 03:01:33 +01:00
parent 4a390ffcfd
commit 5695637fc1
5 changed files with 0 additions and 359 deletions

View file

@ -38,10 +38,3 @@
[[file:projects/mode-icons.org][mode-icons]] [[file:projects/mode-icons.org][mode-icons]]
[[file:projects/ogi.org][ogi]] [[file:projects/ogi.org][ogi]]
[[file:projects/yoshi-theme.org][yoshi-theme]] [[file:projects/yoshi-theme.org][yoshi-theme]]
* Snippets
[[file:snippets/check-php-syntax.org][check-php-syntax]]
[[file:snippets/etcgit.org][etcgit]]
[[file:snippets/euler-problem-1.org][euler-problem-1]]
[[file:snippets/org-export.org][org-export]]

View file

@ -1,32 +0,0 @@
#+TITLE: check-php-syntax
#+OPTIONS: toc:nil
* check-php-syntax
A ~pre-commit~ script for git that checks if all php source files
have proper syntax. This catches far from all mistakes (as most are
not syntax related, of course), but it helps sometimes.
#+BEGIN_SRC sh :tangle yes
#!/bin/zsh
result=0
cd $PWD/src
for php in **/*.php
do
message=$(php -l $php)
if [ $? -ne 0 ]
then
echo "$message"
result=1
fi
done
if [ $result -eq 0 ]
then
echo "All checked out"
fi
exit $result
#+END_SRC

View file

@ -1,12 +0,0 @@
#+TITLE: etcgit
#+OPTIONS: toc:nil
* etcgit
A tiny wrapper around git to help it make managing my ~/etc/~
directory a little easier
#+BEGIN_SRC sh :tangle etcgit
#!/usr/bin/env rc
git --git-dir /home/slash/projects/etcfiles --work-tree /etc/ $*
#+END_SRC

View file

@ -1,286 +0,0 @@
#+TITLE: euler-problem-1
* euler-problem-1
Here is my solution to the Project Euler problem #1 in as many
languages as I could write it.
Each section will first show the commands to run the program and
then the source for it.
I should still add:
- C# (Mono)
Maybe, someday soon I'll also add:
- Ruby
- Io
- Prolog
- Scala
- Erlang
- Haskell
** Bash
#+BEGIN_EXAMPLE
./euler-problem-1.sh
#+END_EXAMPLE
#+BEGIN_SRC shell-script :tangle yes
#!/bin/sh
TOTAL=0
I=0
while [ $I -lt 1000 ]; do
if [ $[ $I % 3 ] -eq 0 -o $[ $I % 5 ] -eq 0 ]; then
let TOTAL=TOTAL+I
fi
let I=I+1
done
echo $TOTAL
#+END_SRC
** C
#+BEGIN_EXAMPLE
gcc euler-problem-1.c && ./a.out
#+END_EXAMPLE
#+BEGIN_SRC c :tangle yes
#include <stdio.h>
int main(int argc, char *argv[])
{
int i, total = 0;
for (i = 0; i < 1000; i++)
if (i % 3 == 0 || i % 5 == 0)
total += i;
printf("%d\n", total);
return 0;
}
#+END_SRC
** Clojure
#+BEGIN_EXAMPLE
clj euler-problem-1.clj
#+END_EXAMPLE
#+BEGIN_SRC clojure :tangle yes
(def total 0)
(dotimes [i 1000]
(when (or (zero? (mod i 3)) (zero? (mod i 5)))
(def total (+ total i))))
(println total)
#+END_SRC
** Emacs lisp
#+BEGIN_EXAMPLE
emacs -script euler-problem-1.el
#+END_EXAMPLE
#+BEGIN_SRC emacs-lisp :tangle yes
(let ((i 0)
(total 0))
(while (< i 1000)
(when (or (zerop (mod i 3)) (zerop (mod i 5)))
(setq total (+ total i)))
(setq i (1+ i)))
(message "%d" total))
#+END_SRC
** Go
#+BEGIN_EXAMPLE
go run euler-problem-1.go
#+END_EXAMPLE
#+BEGIN_SRC go :tangle yes
package main
import (
"fmt"
)
func main() {
total := 0
for i := 0; i < 1000; i++ {
if i % 3 == 0 || i % 5 == 0 {
total += i
}
}
fmt.Printf("%d\n", total)
}
#+END_SRC
** Java
#+BEGIN_EXAMPLE
javac euler-problem-1.java && java Problem
#+END_EXAMPLE
#+BEGIN_SRC java :tangle yes
class Problem
{
public static void main(String args[])
{
int total = 0;
int i;
for (i = 0; i < 1000; i++)
if (i % 3 == 0 || i % 5 == 0)
total += i;
System.out.println(total);
}
}
#+END_SRC
** JavaScript
#+BEGIN_EXAMPLE
js euler-problem-1.js
#+END_EXAMPLE
#+BEGIN_SRC javascript :tangle yes
var total = 0;
for (i = 0; i < 1000; i++)
if (i % 3 == 0 || i % 5 == 0)
total += i;
print(total);
#+END_SRC
** Common Lisp
#+BEGIN_EXAMPLE
sbcl --script euler-problem-1.lisp
#+END_EXAMPLE
#+BEGIN_SRC lisp :tangle yes
(loop for i from 0 to 999
when (or (zerop (mod i 3)) (zerop (mod i 5))) sum i into total
finally (format t "~d~%" total))
#+END_SRC
** PHP
#+BEGIN_EXAMPLE
php euler-problem-1.php
#+END_EXAMPLE
#+BEGIN_SRC php :tangle yes
<?php
$total = 0;
for ($i = 0; $i < 1000; $i++)
if ($i % 3 == 0 || $i % 5 == 0)
$total += $i;
echo $total . "\n";
?>
#+END_SRC
** Python
#+BEGIN_EXAMPLE
python euler-problem-1.py
#+END_EXAMPLE
#+BEGIN_SRC python :tangle yes
TOTAL = 0
for i in range(1000):
if i % 3 == 0 or i % 5 == 0:
TOTAL += i
print(TOTAL)
#+END_SRC
** Rep
#+BEGIN_EXAMPLE
rep euler-problem-1.java
#+END_EXAMPLE
#+BEGIN_SRC sawfish :tangle yes
(do ((i 0 (1+ i))
(total 0))
((>= i 1000)
(format standard-output "%d\n" total))
(when (or (zerop (mod i 3)) (zerop (mod i 5)))
(setq total (+ total i))))
#+END_SRC
** Rust
#+BEGIN_EXAMPLE
rustc euler-problem-1.rs && ./euler-problem-1
#+END_EXAMPLE
#+BEGIN_SRC rust :tangle yes
fn main() {
let mut total = 0;
let mut i = 0;
while i < 1000 {
if i % 3 == 0 || i % 5 == 0 {
total += i;
}
i += 1;
}
io::print(fmt!("%d\n", total));
}
#+END_SRC
** Scheme
#+BEGIN_EXAMPLE
guile euler-problem-1.scm
#+END_EXAMPLE
#+BEGIN_SRC scheme :tangle yes
(use-modules ((rnrs base)))
(do ((i 0 (1+ i))
(total 0))
((>= i 1000)
(display total)
(newline))
(when (or (zero? (mod i 3)) (zero? (mod i 5)))
(set! total (+ total i))))
#+END_SRC
** Vala
#+BEGIN_EXAMPLE
valac euler-problem-1.vala && ./euler-problem-1
#+END_EXAMPLE
#+BEGIN_SRC vala :tangle yes
class Euler.Problem1 : GLib.Object {
public static int main(string[] args) {
int total = 0;
for (int i = 0; i < 1000; i++)
if (i % 3 == 0 || i % 5 == 0)
total += i;
stdout.printf("%d\n", total);
return 0;
}
}
#+END_SRC

View file

@ -1,22 +0,0 @@
#+TITLE: org-export
#+OPTIONS: toc:nil
* org-export
An ~about-filter~ for cgit using Emacs org-mode
#+BEGIN_SRC sh :tangle yes
#!/bin/sh
oname="`mktemp --suffix=.org`"
hname="${oname%.*}.html"
cat > "$oname"
emacs -Q -visit "$oname" -batch \
-l /usr/local/share/emacs/site-lisp/htmlize-1.39.el \
-eval "(let ((org-export-htmlize-output-type 'css))
(org-export-as-html 3 nil nil nil t))" \
2> /dev/null
cat "$hname"
rm "$hname" "$oname"
#+END_SRC