Skip to content

Instantly share code, notes, and snippets.

@sanscore
sanscore / conftest.py
Last active December 31, 2019 11:51
print(...) tracing for pytest.
import inspect
import pytest
def pytest_addhooks(pluginmanager):
print(inspect.currentframe().f_code.co_name)
def pytest_namespace():
@acoyfellow
acoyfellow / Mass LinkedIn Connect (with limit)
Created May 5, 2017 11:42
Mass LinkedIn Connect (with limit)
var maximumTries= 200, runCount=0;
var timer= setInterval(e=>{
if(maximumTries==maximumTries){
clearInterval(timer)
}else{
runCount++
};
document.querySelectorAll('.search-result__actions--primary.button-secondary-medium.m5').forEach(btn=> {
if(btn.innerHTML.indexOf('Connect')==-1){
@jaketame
jaketame / logging_subprocess.py
Created April 28, 2017 13:05
Python subprocess logging to logger from stdout/stderr
#!/usr/local/bin/python3
import logging, select, subprocess
LOG_FILE = "test.log"
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO,filename=LOG_FILE,format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
def logging_call(popenargs, **kwargs):
process = subprocess.Popen(popenargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 20, 2024 01:36
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Grab the main page with all the links:
curl https://slackmojis.com/ > emoji

Open file in vim and run the following commands:

v/src=/d
%s/^.*https:/https:/g"
%s/?.*$//g
@deanhume
deanhume / web-share.js
Created February 22, 2017 21:34
Web Share API example
var shareButton = document.getElementById('shareThis');
var supported = document.getElementById('support');
// Listen for any clicks
shareButton.addEventListener('click', function (ev) {
// Check if the current browser supports the Web Share API
if (navigator.share !== undefined) {
// Get the canonical URL from the link tag
var shareUrl = document.querySelector('link[rel=canonical]') ? document.querySelector('link[rel=canonical]').href : window.location.href;
@rgolangh
rgolangh / large-setup.yml
Last active August 16, 2017 06:41
Build an ovirt lab using ansible
---
- hosts: localhost
connection: local
vars:
#engine_prefix: /
engine_url: "http://example.com:8080/ovirt-engine/api"
engine_user: admin@internal
engine_password: PASSWORD
engine_insecure: true
#engine_cafile: /etc/pki/ovirt-engine/ca.pem

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

# Send POST request with data to github api to create a gist
curl --user "<username>" --request POST --data '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# or in short
curl -u "<username>" -X POST -d '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# or more short, if supplied -d (data) POST method can ommited as below
curl -u "<username>" -d '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# Send POST request with multiple data
curl --data "login=<username>" --data "token=<token_string>" https://github.com/api/v2/json/user/show/<username>
# or combine into single --data
@adejones
adejones / filerotator.py
Last active October 21, 2022 17:00 — forked from RWJMurphy/filerotator.py
Python class and utility for file rotation. Configurable daily, weekly and monthly retention; can use hard links to save space; supports `argparse` config files.
#!/usr/bin/env python3
# vim: ft=python ts=4 sw=4 expandtab
#
# Copyright (c) 2013 Reed Kraft-Murphy <reed@reedmurphy.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is