Skip to content

Instantly share code, notes, and snippets.

View lsloan's full-sized avatar

Mr. Lance E Sloan «UMich» lsloan

  • Teaching and Learning (@tl-its-umich-edu) at University of Michigan: Information and Technology Services
  • Ann Arbor, Michigan, USA
  • 00:29 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / submodulewiki.md
Created October 14, 2016 18:04 — forked from iracooke/submodulewiki.md
Wiki as a submodule

From within the parent repo do

        git submodule add [email protected]:iracooke/transcriptomes.git/wiki wiki
        git commit -m "Adding wiki as submodule"
        git push

Making changes to the wiki and to the parent require separate git commit commands.

@lsloan
lsloan / GitHub_repo_wiki_submodule.md
Created October 14, 2016 19:00
Adding GitHub repo's wiki as a submodule of the repo

Given a GitHub repo username/reponame with a wiki containing one or more pages:

  1. git clone https://github.com/username/reponame.git
  2. cd reponame
  3. git submodule add ../reponame.wiki.git wiki
@lsloan
lsloan / Markdown and reStructuredText: A Comparison
Last active December 13, 2016 22:26 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText
Gist title: "Markdown and reStructuredText: A Comparison"
Summary: A comparison of formatting features in Markdown and reStructuredText documents. See the " README.md" file for details.
@lsloan
lsloan / Minimal JSON-LD required for Graded vocab
Last active December 5, 2016 15:24 — forked from anonymous/README.md
JSON-LD Playground: Minimal JSON-LD required for Graded vocab
See README.md, https://gist.github.com/lsloan/2e43be50000bc13f178cad7fcfca71f0#file-readme-md
@lsloan
lsloan / kwargs.py
Last active February 4, 2017 11:46
Find which arguments of a method have defaults and add them to kwargs if they're not None.
from __future__ import print_function
import inspect
import pprint
class MyClass(object):
def myFunc(self, arg1, arg2=None, arg3=None, *args, **kwargs):
# Find which arguments of this method have defaults and add them to kwargs if they're not None
@lsloan
lsloan / fixJS_toSource_JSON.php
Last active February 4, 2017 12:17
Convert output from JavaScript's `toSource()` to valid JSON.
<?php
/**
* Convert output from JavaScript's `toSource()` to valid JSON.
*
* @param $toSourceOutput
* @return string
*/
function fixJS_toSource_JSON($toSourceOutput) {
$fixedJSON = substr($toSourceOutput, 1, strlen($toSourceOutput) - 2); // remove outer parentheses
return preg_replace('/([a-zA-Z0-9_]+?):/', '"$1":', $fixedJSON); // enclose variable names in quotes
@lsloan
lsloan / README.md
Created February 21, 2017 18:02 — forked from joyrexus/README.md
curl tutorial

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@lsloan
lsloan / list_vagrant_port_forwardings.rb
Last active March 22, 2017 21:16 — forked from andre1810/list_vagrant_port_forwardings.rb
List Port Forwardings of vagrant machines
vm_infos = `vboxmanage list vms`
puts 'Port Forwardings:'
puts '---------------------------------'
vm_infos.each_line do |vm_info|
vm_name = vm_info.scan(/\"(.*)\"/)
vm_id = vm_info.scan(/.*{(.*)}/).join('')
vm_detail_info = `vboxmanage showvminfo #{vm_id}`
@lsloan
lsloan / vagrant_host.md
Last active September 21, 2022 13:53
Vagrant: host IP address from guest perspective

Unless specified otherwise in Vagrantfile, the IP address of the host (the computer running Vagrant) from the perspective of the guest (the VM being run by Vagrant) is: 10.0.2.2

If that IP address doesn't work, then examination of Vagrantfile should reveal directives that changed it from its default value.

If an IP address can't be found in Vagrantfile, then the following command will probably reveal it:

route -A inet
@lsloan
lsloan / MongoDB index size.md
Last active June 19, 2017 19:44
JS: Display the number of bytes used by the indices of each collection in a MongoDB database.

From: https://stackoverflow.com/questions/7851563#37232484

A short JavaScript program (and a one-line version) to display the number of bytes used by the indices of each collection in a MongoDB database.

TODO: Use functions like each() to loop over the arrays, making it execute faster and the code shorter.