This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (kill-new "KILLED") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (kill-new "KILLED") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| A_CONSTANT = :outside | |
| class AClass | |
| A_CONSTANT = :inside | |
| end | |
| p A_CONSTANT # => :outside | |
| p AClass::A_CONSTANT # => :inside |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Paste me! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Paste me! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This should be a public Gist. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- mode: snippet -*- | |
| # name: header | |
| # key: ;;; | |
| # -- | |
| ${1:$(let ((starter (or comment-start "#"))) (concat starter (make-string (length "abc") (string-to-char (substring starter -1)))))} | |
| ${1:Header}$0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun jeg2s-regex-escape (str) | |
| "Escape all special regular expression characters in the passed string." | |
| (if (stringp str) | |
| (jeg2s-regex-escape (cons "" (split-string str "" t))) | |
| (if (>= (safe-length str) 2) | |
| (if (and (not (string= "\\" (car str))) (cadr (string-match "[.*+?^$\\\\[]" str))) | |
| (concat (car str) "\\" (cadr str) (jeg2s-regex-escape (cddr str))) | |
| (concat (car str) (jeg2s-regex-escape (cdr str))) | |
| (mapconcat 'identity str ""))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun jeg2s-regex-replace (str regex replacement &optional fixedcase literal) | |
| "Replace a regular expression in the passed string, if it occurs." | |
| (or (when (string-match regex str) | |
| (replace-match replacement fixedcase literal str)) | |
| str)) | |
| (defun jeg2s-regex-replace-all (str regex replacement &optional fixedcase literal) | |
| "Replace a regular expression everywhere it occurs in the passed string." | |
| (if (string-match regex str) | |
| (jeg2s-regex-replace-all (replace-match replacement fixedcase literal str) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| s = "james" | |
| substrings = [ ] | |
| s.size.times do |length| | |
| s.split("").permutation(length + 1) do |perm| | |
| if s.include? perm.join | |
| substrings << perm | |
| end | |
| end | |
| end |