Skip to content

Instantly share code, notes, and snippets.

@mortymacs
mortymacs / cs.py
Last active June 7, 2017 04:47
Convert Size to Human Readable String
#!/usr/bin/env python
import sys
types = ["KB","MB","GB","TB","PB","EB","ZB","YB"]
def convert(s):
div = 1024
i = 0
while i < len(types):
s /= div
@mortymacs
mortymacs / get_textview_value.py
Created June 9, 2017 11:42
Get GTK TextView Value (Content) by Python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
input = Gtk.TextView()
value = item.get_buffer().get_text(
item.get_buffer().get_start_iter(),
item.get_buffer().get_end_iter(),
True
@mortymacs
mortymacs / unset_focus_state.py
Created June 9, 2017 12:05
Unset Focus State on Entry in PyGTK
widget = Gtk.Entry()
widget.unset_state_flags(Gtk.StateFlags.FOCUSED)
@mortymacs
mortymacs / pass_func.c
Created June 13, 2017 14:26
Passing Function as an Argument in C
#include <stdio.h>
void pass_it(void (*f)(char), char c, int t) {
for(int i = 0; i<t; i++)
(*f)(c);
}
void echo(char c) {
printf("%c", c);
}
@mortymacs
mortymacs / A.markdown
Last active September 14, 2017 02:59 — forked from umpirsky/A.markdown
Sublime Text Monokai Sidebar Theme.
@mortymacs
mortymacs / .emacs
Last active November 13, 2017 06:16
My emacs config
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(package-initialize)
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
(require 'fill-column-indicator)
(add-hook 'after-change-major-mode-hook 'fci-mode)
@mortymacs
mortymacs / set_dark_theme.py
Last active July 9, 2017 19:06 — forked from sergejx/gist:2358089
Set dark theme for GTK+ application
from gi.repository import Gtk
settings = Gtk.Settings.get_default()
settings.set_property("gtk-application-prefer-dark-theme", True)
@mortymacs
mortymacs / get_cdrom_image.sh
Created July 4, 2017 14:21
Get CD/DVD Image in Linux
dd if=/dev/cdrom of=cd2.iso
@mortymacs
mortymacs / tmux-notify.pl
Created July 16, 2017 06:42 — forked from basilfx/tmux-notify.pl
Irssi and tmux-notify
use strict;
use warnings;
use vars qw($VERSION %IRSSI);
use Irssi;
# Script info
$VERSION = '0.1';
%IRSSI = (
authors => 'Bas Stottelaar',
@mortymacs
mortymacs / tmux.conf
Last active July 17, 2017 04:28
My Tmux Config
bind -n S-Right next-window
bind -n S-Left previous-window
#bind -n C-Up select-pane -U
#bind -n C-Down select-pane -D
#bind -n C-Left select-pane -L
#bind -n C-Right select-pane -R
# Config plugins
set -g status-right '#(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD) %m-%d %H:%M'
#set -g status off