Skip to content

Instantly share code, notes, and snippets.

View danlamanna's full-sized avatar
🏠
Working from home

Dan LaManna danlamanna

🏠
Working from home
View GitHub Profile
(setq
ido-save-directory-list-file (format "%s/ido.last" emacs-tmp-dir)
ido-ignore-buffers '(".*Completion"
"\\*"
"^irc\.")
ido-work-directory-list '("~/" "~/projects")
ido-enable-flex-matching t
ido-case-fold t
ido-enable-last-directory-history t
ido-max-work-directory-list 10
(defun fix-double-capital()
"Go back to last occurence of a 'double capital' at start of word and correct."
(interactive)
(if (re-search-backward "\\b\\([A-Z]\\{2\\}\\)" nil t)
(replace-match (concat (substring (match-string 0) 0 1) ;concat first char
(downcase (substring (match-string 0) 1 2))) t) ; with downcased second char
(message "No double capital found!")))
interactive("assembla-spot-check-space-urls", "Loads n URLs with random space IDs.",
function assembla_spot_check(I) {
var url_format = yield I.minibuffer.read($prompt = "Assembla URL (with %s where space-id should belong): ");
var num_spaces = yield I.minibuffer.read($prompt = "Number of spot checks: ");
if (num_spaces > assembla_space_ids.length) {
I.window.minibuffer.message("Number of spot checks exceeds number of space IDs known, performing " + assembla_space_ids.length + " instead.");
num_spaces = assembla_space_ids.length;
}
(defun html-source-of(url)
(let ((response-buffer (url-retrieve-synchronously url)))
(with-current-buffer response-buffer
(buffer-substring-no-properties url-http-end-of-headers (point-max)))))
;; set to conkeror if it exists, otherwise try chromium
(if (file-exists-p "/usr/bin/conkeror")
(setq browse-url-browser-function 'browse-url-generic browse-url-generic-program "/usr/bin/conkeror")
(if (fboundp 'browse-url-chromium)
(custom-set-variables
'(browse-url-browser-function 'browse-url-chromium))))
(defun recursive-find-dirs(dir-name dir &optional working-dirs)
"find all directories with the name DIR-NAME within DIR, recursively."
(print working-dirs)
(setq working-dirs (or working-dirs '()))
(let ((dirs (directory-files-and-attributes dir t directory-files-no-dot-files-regexp)))
(when dirs
(dolist (current-dir dirs)
(when (file-directory-p (car current-dir))
(if (string-equal (car (last (split-string (car current-dir) "/"))) dir-name)
(push (car current-dir) working-dirs))
(defcustom magit-svn-externals-dir ".git_externals"
"Directory from repository root that stores cloned SVN externals."
:group 'magit
:type 'string)
(defun magit-svn-fetch-externals()
"Loops through all external repos found by `magit-svn-external-directories'
and runs git svn fetch, and git svn rebase on each of them."
(interactive)
(let ((externals (magit-svn-external-directories)))
(add-hook 'magit-mode-hook (lambda()
(require 'magit-svn)
(if (magit-svn-get-ref-info)
(magit-svn-mode))))
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
{
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
/**/
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["subscr_id"])), $url)))
if (($url = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["txn_id"])), $url)))
if (($url = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_u
@danlamanna
danlamanna / gist:5207472
Last active December 15, 2015 05:18
Add build user to all spaces

get all space ids existent using python script
get all space-ids build-user is in via api call
so a set-difference like so:
(set-difference all-spaces build-user-spaces :test 'string-equal)
set json for user_roles api call: (setq user-role-json "{\"user_role\":\"user_id\":\"BUILD_USER_ID_HERE\",\"role\":\"member\"}}") on the resulting list, do a mapc like so:
(mapc (lambda(space-id) (asl/post-or-put (format "spaces/%s/user_roles" space-id) "json" build-user-json "POST" 'print)) missing-spaces)