Skip to content

Instantly share code, notes, and snippets.

@dsjt
dsjt / life.c
Last active November 27, 2016 08:41
life game in c
/* life.c */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 30
#define ALIVE 1
#define DEATH -1
@dsjt
dsjt / life.py
Created November 27, 2016 05:28
life game in python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import sys
SIZE = int(sys.argv[1])
E = np.eye(SIZE, k=1) + np.eye(SIZE) + np.eye(SIZE, k=-1)
world = np.random.randint(2, size=(SIZE, SIZE))
(require 'recentf)
(require 'dired-open)
;;;###autoload
(defun my-add-recentf-in-dired ()
"Add a file to the recentf list when you try to open the file using dired-open.el."
(interactive)
(let ((file (dired-get-filename)))
(when file
(recentf-add-file file)))
nil)
@dsjt
dsjt / gist:4ec44797187dfa63f7ea
Last active August 29, 2015 14:13
cVim configuration
map <Space>d :duplicate<CR>
map U scrollPageUp
map D scrollPageDown
map <Space>h :help<CR>
map <Space>ss :settings<CR>
map G scroolToBottom
map <C-n> scroolPageDown
map <C-p> scroolPageUp
map <C-x>2 :duplicate<CR>
map <C-x>h :help<CR>
@dsjt
dsjt / gist:90bdb87e48516aaa9e4b
Last active August 29, 2015 14:13
cVim configuration
map g2 :duplicate<CR>
map U scrollPageUp
map D scrollPageDown
(defun open-explorer()
(interactive)
(start-process-shell-command "open-explorer" nil "start."))
(defun view-pdf()
(interactive)
(let ((pdf-file (concat (car (split-string (buffer-file-name) "\\.")) ".pdf"))
(viewer pdf-viewer))
(start-process "*view-pdf*" nil viewer pdf-file)))
@dsjt
dsjt / gist:73d5b8449916da18c709
Last active August 29, 2015 14:04
tweet-current-line
(defun tweet-current-line()
(interactive)
(let* ((clbeg (progn (forward-line 0) (point)))
(clend (progn (end-of-visible-line) (point)))
(tw-string (buffer-substring clbeg clend)))
(if (y-or-n-p (format "post \"%s\"?" tw-string))
(progn (twittering-update-status-from-pop-up-buffer tw-string)
(twittering-edit-post-status)))))
@echo off
set service_name=emacs
tasklist | find /i "%service_name%"
if %errorlevel%==0 (
echo 1
start emacsclientw something
) Else (
echo 2
start runemacs
)
Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c myemacs.bat", vbhide