Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile
javascript: function runDownloadThing(howManyToDownload) {
if (!howManyToDownload) {
howManyToDownload = 3;
}
if (window['downloadSome']) {
window.downloadSome();
return;
}
var iter = $('div.download a.a:not([download])').toArray();
iter = iter.concat($('div.row a[download]').toArray());
@dschep
dschep / py
Last active September 13, 2022 18:55
Shortcut for commandline python use
#!/usr/bin/env python3
"""
More convinient than `python -c`.
Automatically imports python modules and prints the repr of the last statement.
for example:
`py 'json.load(sys.stdin)'`
instead of
`python -c 'import json,stdin;print(repr(json.load(sys.stdin)))`
'use strict';
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
}),
};
@dschep
dschep / py-comp-to-js.md
Last active June 2, 2023 15:57
Python Comprehensions to JS

Python list & dict comprehensions translated to JavasScript

Comprehensions are a really useful feature of Python that aren't available in JavaScript (or many languages). These concepts of course can be tranlsated into using map instead. But especially the dictionaries are a bit trickier.

Lists / Arrays

>>> foobar = range(5)
>>> [x + 1 for x in foobar]
[1, 2, 3, 4, 5]
@dschep
dschep / post-merge
Last active July 8, 2020 14:00 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `yarn` if yarn.lock changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
import json
import requests
def hello(event, context):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
@dschep
dschep / ntfy.yml
Created March 24, 2017 12:26
Multiple ntfy pushover backends
backends:
- desktop
- cellphone
pushover: &pushover
backend: pushover
user_key: uiRM6s9BEXY5BPE78J3CBK3mb6rMe1
api_token: aUnsraBiEZVsmrG89AZp47K3S2dX2a
desktop:
<<: *pushover
device: desktop
@dschep
dschep / raspbian-python3.6.rst
Last active October 24, 2023 14:57 — forked from BMeu/raspbian-python3.5.rst
Installing Python 3.6 on Raspbian

Installing Python 3.6 on Raspbian

As of January 2018, Raspbian does not yet include the latest Python release, Python 3.6. This means we will have to build it ourselves, and here is how to do it. There is also an ansible role attached that automates it all for you.

  1. Install the required build-tools (some might already be installed on your system).

Keybase proof

I hereby claim:

  • I am dschep on github.
  • I am dschep (https://keybase.io/dschep) on keybase.
  • I have a public key ASAOASCVweS-lajGgb690KEptFPhZSdZuPmTrBs5BkcTQgo

To claim this, I am signing this object:

@dschep
dschep / swc
Created March 24, 2016 01:29
Streaming version of wc -l
#!/bin/bash
exec awk '{printf "\r%lu", NR}'