Skip to content

Instantly share code, notes, and snippets.

@geetduggal
geetduggal / gist:4335080
Created December 19, 2012 07:36
Basic latex template
\documentclass{article}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{cancel}
\usepackage{wrapfig}`
\title{Title\\\small{Author}}
\begin{document}
\maketitle
\setlength{\parindent}{0cm}
# Here is a fun language thing I made for parallel for loops. The syntax is:
# parallelFor(sequence, i, numProcs):
# do something with sequence[i]
# Which gets translated by this code:
template parallelFor*[T](data:openarray[T], i:expr, numProcs:int, body : stmt) : stmt {.immediate.} =
let numOpsPerThread = (data.len/numProcs).toInt
@geetduggal
geetduggal / shell.nim
Created March 3, 2014 04:28
Basic shell scripting in Nimrod
import os
proc shell*(cmd: string) =
if os.execShellCmd(cmd) != 0:
raise newException(EOS, cmd & " returned error code 1")
proc fexists*(fname: string) : bool =
try: discard Open(fname)
except EIO: return false
return true
" vim +BundleInstall! +BundleClean +qall
" ,,w smart jumping!
set nofoldenable
Bundle 'zah/nimrod.vim'
colorscheme peaksea
UnBundle 'AutoClose'
UnBundle 'spf13/vim-autoclose'
"set mouse=c " Disable cursor positioning by mouse
execute "set colorcolumn=" . join(range(81,335), ',')
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
import memfiles, strutils
proc firstChar*(s: pointer; c,n: int) : pointer {.importc: "memchr",
header: "<string.h>"}
type TEntry* = tuple[start: TAddress, numChars: int]
proc skipToChar*(e:TEntry, c: int): TEntry =
let caddr = cast[TAddress](firstChar(cast[pointer](e.start), c, e.numChars))
if caddr > 0:
@geetduggal
geetduggal / wrap-lines.coffee
Last active August 29, 2015 14:01
Experiment with a line wrapping script for Atom
module.exports =
activate: ->
atom.workspaceView.command "wrap-lines:wrap", => @wrap()
atom.workspaceView.command "wrap-lines:unwrap", => @unwrap()
wrap: ->
editor = atom.workspace.activePaneItem
selection = editor.getSelection()
stext = selection.getText()
killall -9 sshfs
umount mydir
sshfs user@host:path -oauto_cache,reconnect,volname=mydir
# Your keymap
#
# Atom keymaps work similarly to stylesheets. Just as stylesheets use selectors
# to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
# Here's an example taken from Atom's built-in keymap:
import fastentries
iterator fastaEntries*(fname: string) : tuple[name,s:string] =
for entryInfo in entriesMapped(fname, sep=int('>')):
let seqInfo = entryInfo.skipToChar(10)
let s = seqInfo.toGCString(skipNewline=true, upper=true)
var nameInfo : TEntry = (entryInfo.start, seqInfo.start - entryInfo.start)
let name = nameInfo.toGCString
yield (name, s)