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
  • 04:41 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
# -*- coding: utf-8 -*-
# test_docstrings.py
import pytest
def test_lambdas():
# Create a lambda and test it
doubler = lambda x: " ".join([x, x])
assert doubler("fun") == "fun fun"
# Add a docstring to the lambda
@Naatan
Naatan / executeAsPHP.js
Last active November 21, 2017 08:07
Komodo Macro - Execute file/selection as PHP
new function()
{
/**
* Execute Macro
*
* @returns {void}
*/
this.exec = function()
{
@joyrexus
joyrexus / README.md
Last active December 13, 2024 00:46
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@chauncey-garrett
chauncey-garrett / test_if_interactive_shell.sh
Created October 25, 2013 20:52
Test for an interactive shell in Bash
if [[ -z $PS1 ]] # no prompt?
### if [ -v PS1 ] # On Bash 4.2+ ...
then # non-interactive
...
else # interactive
...
fi
@omz
omz / SlimIt-Installer.py
Created October 21, 2013 17:11
SlimIt-Installer
ply_url = 'https://pypi.python.org/packages/source/p/ply/ply-3.4.tar.gz'
slimit_url = 'https://pypi.python.org/packages/source/s/slimit/slimit-0.8.1.zip'
print 'Downloading SlimIt...'
from urllib import urlretrieve
import tarfile
import zipfile
import shutil
import os
try:
@larchanka
larchanka / uniqid.js
Last active October 27, 2019 08:51
JavaScript function that copies functionality of PHP's 'uniqid'.
(function () {
this.uniqid = function (pr, en) {
var pr = pr || '', en = en || false, result;
this.seed = function (s, w) {
s = parseInt(s, 10).toString(16);
return w < s.length ? s.slice(s.length - w) : (w > s.length) ? new Array(1 + (w - s.length)).join('0') + s : s;
};
result = pr + this.seed(parseInt(new Date().getTime() / 1000, 10), 8) + this.seed(Math.floor(Math.random() * 0x75bcd15) + 1, 5);
@cclauss
cclauss / sounder.py
Last active December 26, 2021 18:33
Play each .caf sound inside of Pythonista.app
# sounder.py
# play each of the .caf sounds inside the Pythonista.app
import os, os.path, scene, sound
framesPerSound = 60
pythonistaDir = os.path.expanduser('~/Pythonista.app')
#print(os.listdir(pythonistaDir))
soundFileExtention = '.caf'
wallpaperAppIcon = ('/AppIcon76x76@2x~ipad.png', '/[email protected]')
@cclauss
cclauss / noDoze.py
Last active January 20, 2023 07:08
Update: This looks like a far better solution... `console.set_idle_timer_disabled(flag)` Disable or enable the idle timer (which puts the device to sleep after a certain period of inactivity). -- Keep relaunching yourself to prevent your iOS device from falling asleep. Run, sleep 30 seconds, store state in argv (or a file), reboot self -- Repeat…
# Update: This looks like a far better solution...
# `console.set_idle_timer_disabled(flag)`
# Disable or enable the idle timer (which puts the device to sleep after a certain period of inactivity).
# noDoze.py -- keep relaunching yourself to prevent
# your iOS device from falling asleep.
import notification, time, urllib
def argsString(argv):
@thom-nic
thom-nic / cx_oracle_instructions.md
Created July 16, 2013 19:14
Installing CX Oracle for Python & Mac OS X. Instructions exist around the web, but they seem to be piecemeal and incomplete.
@BashedCrab
BashedCrab / Hydrogen.py
Last active March 19, 2023 04:14
Hydrogen - A lightweight GUI framework for Pythonista
#
# Hydrogen is a lightweight GUI framework for Pythonista
#
# Hydrogen - https://gist.github.com/BashedCrab/5924965
#
# HydrogenLayouts - https://gist.github.com/BashedCrab/6103019
#
# HydrogenDemo - https://gist.github.com/BashedCrab/5953776
#