Skip to content

Instantly share code, notes, and snippets.

@QiangF
QiangF / gist:4c59aab59375495c7e34
Last active August 27, 2015 14:30 — forked from jgarvin/gist:ce37d08654978fd7e4c9
Implementation of minibuffer 'belts'
(require 'cl) ;; defstruct
;; TODO: overwrite existing characters, don't erase the
;; whole buffer everytime. And only update things that
;; are actually different.
(defvar md-belt-item-max 8)
(defvar md-current-message nil)
(defvar md-message-counter 0)
(defvar md-num-belts 3)
@QiangF
QiangF / fileinsert.py
Last active August 29, 2015 14:14 — forked from Cilyan/fileinsert.py
#
# Copyright 2013 Cilyan Olowen <gaknar@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
;; Simplified variant. Add only current perspective group.
(with-eval-after-load "ibuffer"
(require 'ibuf-ext)
(define-ibuffer-filter persp
"Toggle current view to buffers of current perspective."
(:description "persp-mode"
:reader (persp-prompt (safe-persp-name (get-frame-persp)) t))
@QiangF
QiangF / dired-ediff
Last active August 29, 2015 14:21 — forked from rmcm/dired-ediff
; ----------------------------------------
;; dired ediff
; ----------------------------------------
(defun my-dired-ediff-marked-files ()
"Run ediff on 2 or 3 marked dired files."
(interactive)
(let ((marked-files (dired-get-marked-files)))
(if (= (safe-length marked-files) 2)
(ediff-files (nth 0 marked-files) (nth 1 marked-files))
(if (= (safe-length marked-files) 3)
(defun cofi/helm-flyspell-correct ()
"Use helm for flyspell correction.
Adapted from `flyspell-correct-word-before-point'."
(interactive)
;; use the correct dictionary
(flyspell-accept-buffer-local-defs)
(let ((cursor-location (point))
(word (flyspell-get-word))
(opoint (point)))
;; hack that enable major mode for newly created buffer according to `auto-mode-alist'
(defadvice set-buffer-major-mode (after new-buffer-auto-mode activate compile)
"Select major mode for newly created buffer.
Compare the `buffer-name' the entries in `auto-mode-alist'."
(with-current-buffer (ad-get-arg 0)
(if (and (buffer-name) (not buffer-file-name))
(let ((name (buffer-name)))
;; Remove backup-suffixes from file name.
(setq name (file-name-sans-versions name))
@QiangF
QiangF / gist:5c7d1ec61b4d1cc52754
Last active August 29, 2015 14:27 — forked from hyone/gist:1323137
evil-text-object-defun
(require 'evil)
(setq evil-move-defun-alist
'((ruby-mode . (ruby-beginning-of-defun . ruby-end-of-defun))
(c-mode . (c-beginning-of-defun . c-end-of-defun))
(js2-mode . (js2-beginning-of-defun . js2-end-of-defun))))
(defun evil-move-defun (count &optional begin-defun end-defun)
"Move by defun"
(let ((count (or count 1))
#
#
# Python Assistant Window
# v 0.1 initial release
#
#
#***********************************************************************************
#
# provide a text editing window with functions to aid in coding Python within FreeCAD
#
@QiangF
QiangF / MaxResult.py
Created June 15, 2016 13:13 — forked from crmccreary/MaxResult.py
Extracts the maximum result from an Abaqus odb
import sys
import os
import odbAccess
import numpy as NP
import math
def open_odb(odbPath):
base, ext = os.path.splitext(odbPath)
odbPath = base + '.odb'
new_odbPath = None
@QiangF
QiangF / process_abaqus_rpt.py
Created June 15, 2016 13:15 — forked from crmccreary/process_abaqus_rpt.py
This python function attempts to convert the XYData report generated by Abaqus into something useful
def process_rpt(fname):
with open(fname, 'rb') as f:
lines = f.readlines()
lines_cleaned = []
for line in lines:
# Strip leading and trailing whitespace
line_cleaned = line.lstrip().rstrip()
# Ignore blank lines
if len(line_cleaned):
# Check if first element is a float