Skip to content

Instantly share code, notes, and snippets.

View GlenDC's full-sized avatar
🚀

Glen De Cauwsemaecker GlenDC

🚀
View GitHub Profile
@GlenDC
GlenDC / exploor-resizer.sh
Last active August 23, 2016 21:45
a shell script to resize activity images for exploor
#!/bin/bash
if [ "$#" -lt 1 ]; then
TARGET_DIR="."
else
TARGET_DIR="$1"
fi
if [ "$#" -lt 2 ]; then
ROOT_DIR="$HOME/exploor/images"
curl -o quine.f90 https://gist.githubusercontent.com/GlenDC/11dadd47137b2c1a5587/raw/ && \
alias _fortran='(gfortran -o quine quine.f90 && ./quine)' && \
alias _fotopy='(_fortran > quine.py && rm -f quine)' && \
alias _pytofo='(python quine.py > quine.f90)' && \
_fotopy && _pytofo && _fotopy && _pytofo && _fortran
curl -o quine.py 'https://gist.githubusercontent.com/GlenDC/5ec5528c7fcac5468715/raw/' \
&& python quine.py | python | python
@GlenDC
GlenDC / quine.f90
Created December 6, 2015 17:10
A quine that switches between languages
PROGRAM QUINE
IMPLICIT NONE
WRITE(*, '(A)') '#!/usr/bin/python'
WRITE(*, '(A)') ''
WRITE(*, '(A)') 'sq = chr(39) ; dq = chr(34)'
WRITE(*, '(A)') 'ind = lambda str: '' '' + str'
WRITE(*, '(A)') 'sqe = lambda str: sq + str + sq'
WRITE(*, '(A)') 'dqe = lambda str: dq + str + dq'
WRITE(*, '(A)') ''
@GlenDC
GlenDC / quine.f90
Last active December 6, 2015 06:13
My second attempt for the Quine Challenge.
PROGRAM QUINE
CHARACTER(LEN=*), PARAMETER :: Quote = Char(39)
CHARACTER(LEN=86), DIMENSION(11) :: Source
INTEGER :: i ; CHARACTER(LEN=2) :: Line
Source( 1) = 'PROGRAM QUINE'
Source( 2) = ' CHARACTER(LEN=*), PARAMETER :: Quote = Char(39)'
Source( 3) = ' CHARACTER(LEN=86), DIMENSION(11) :: Source'
Source( 4) = ' INTEGER :: i ; CHARACTER(LEN=2) :: Line'
Source( 5) = ' DO i=1, 4 ; WRITE(*,*) TRIM(Source(i)) ; END DO'
Source( 6) = ' DO i=1, 11'
@GlenDC
GlenDC / quine.py
Created December 6, 2015 04:46
My python version for the Quine Challenge
#!/usr/bin/python
quote = chr(34)
source = [
"#!/usr/bin/python",
"",
"quote = chr(34)",
"source = [",
" ]",
"",
@GlenDC
GlenDC / quine.f90
Last active December 6, 2015 04:43
My first attempt for the Quine Challenge
PROGRAM QUINE
IMPLICIT NONE
INTEGER :: i
CHARACTER(LEN=80), DIMENSION(10) :: Source
Source(1) = "PROGRAM QUINE"
Source(2) = " IMPLICIT NONE"
Source(3) = " INTEGER :: i"
Source(4) = " DO i=1, 3"
Source(5) = " DO i=1, 5"
Source(6) = " END DO"
@GlenDC
GlenDC / lazyIf-virtualdom.diff
Last active September 29, 2015 21:44
Proposal for lazyif functionallity in elm-virtualdom
diff --git a/src/Native/VirtualDom.js b/src/Native/VirtualDom.js
index efb9ce7..45ec52e 100644
--- a/src/Native/VirtualDom.js
+++ b/src/Native/VirtualDom.js
@@ -1407,13 +1407,18 @@ Elm.Native.VirtualDom.make = function(elm)
return newNode;
}
+ function predicate(a, b)
+ {
@GlenDC
GlenDC / grid.elm
Last active August 29, 2015 14:22
Draw Grid
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Window
main : Signal Element
main =
Signal.map render Window.dimensions
renderGridLine : Int -> Int -> Int -> Int -> Form
@GlenDC
GlenDC / combinations.go
Last active August 29, 2015 14:01
Combinations of an array in Go
func AllUniqueCombinations_Recursive(combination, array []int, result [][]int) [][]int {
if len(array) > 0 {
for i := range array {
c := make([]int, 0, len(combination))
c = append(c, combination...)
c = append(c, array[i])
a := make([]int, 0, len(array)-1)
a = append(a, array[0:i]...)
a = append(a, array[i+1:]...)
result = AllUniqueCombinations_Recursive(c, a, result)