Skip to content

Instantly share code, notes, and snippets.

@dchrzanowski
dchrzanowski / index.html
Created July 21, 2017 13:59 — forked from rukeba/index.html
Very simple example chat on Node.js
<html>
<head>
<title>Node.js Zoo Chat</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('form#send').submit(onSend);
longPoll();
$('#nickname').focus();
});
(defun powerline-evil-center-color-theme ()
"Powerline's center-evil them with the evil state in color."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(mode-line (if active 'mode-line 'mode-line-inactive))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
;; -------------------------------------------------------------------------------------------------------------------------
;; Neo tree open xdg on point helpers
;; -------------------------------------------------------------------------------------------------------------------------
(defun neotree-open-xdg-on-point ()
"Open a file under point."
(interactive)
(call-process "xdg-open" nil 0 nil
(neo-buffer--get-filename-current-line)))
;; Add "o" as the key that will launch the function
(global-set-key [f5]
(lambda ()
(interactive)
(save-window-excursion
(async-shell-command (concat "urxvt -e run_any.py " default-directory " " (buffer-name))))))
#!/usr/bin/env python2
import doctest
def shift_zeros(line):
no_zeros = [each for each in line if each != 0] # make a list with no zeroes
return no_zeros + ([0] * (len(line) - len(no_zeros))) # return the list with the zeroes added at the end
def merge(line):
@dchrzanowski
dchrzanowski / sprite_sheet.py
Last active July 14, 2023 23:39
Sprite sheet cutter for the pygame library, python.
def sprite_sheet(size, file_name, pos=(0, 0)):
"""Loads a sprite sheet.
(tuple(num, num), string, tuple(num, num) -> list
This functions cuts the given image into pieces(sprites) and returns them as a list of images.
WARNING!!! It needs the pygame library to be imported and initialised to work.
Basically this piece of code is to be used preferably within an existing program.
size is the size in pixels of the sprite. eg. (64, 64) sprite size of 64 pixels, by 64 pixels.
file_name is the file name that contains the sprite sheet. preferable format is png.
pos is the starting point on the image. eg. (10, 10) think about it as an offset.