Skip to content

Instantly share code, notes, and snippets.

@virolea
virolea / upload.js
Last active June 11, 2024 06:48
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@scarpent
scarpent / better-twitter
Last active September 13, 2021 14:49
Better Twitter: Greasemonkey/Tampermonkey script to hide stuff you don't want to see
// ==UserScript==
// @name Better Twitter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove unwanted stuff (promoted, other people's likes, ...)
// @author Scott Carpenter
// @match https://twitter.com/
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.githubusercontent.com/scarpent/ba8e369f1187fa990b98d1f58b2c013d/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @grant none
@nikhita
nikhita / update-golang.md
Last active June 17, 2024 16:29
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@tayiorbeii
tayiorbeii / vimeo_downloader.py
Created February 24, 2017 17:18
Usage: `python vimeo_downloader.py http://...master.json optional_name.mp4` modified from https://gist.github.com/alexeygrigorev/a1bc540925054b71e1a7268e50ad55cd
import requests
import base64
from tqdm import tqdm
import sys
master_json_url = sys.argv[1]
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
resp = requests.get(master_json_url)
content = resp.json()
@rgl
rgl / wait_for_http_200.sh
Last active March 7, 2024 17:08
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
@thenbrent
thenbrent / _subscriptions.md
Last active November 22, 2021 05:31 — forked from mattallan/_subscriptions.md
WooCommerce Subscriptions REST API Endpoint Documentation (fork of https://gist.github.com/mattallan/fd52629eae293540c6d8)

Subscriptions

This section lists all API that can be used to create, edit or otherwise manipulate subscriptions.

Subscription Properties

Attribute Type Description
id integer Subscription ID (post ID) read-only
order_number integer Order number read-only
@mrkpatchaa
mrkpatchaa / README.md
Last active June 6, 2024 21:03
Bulk delete github repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.

@erezsob
erezsob / tld-list.json
Last active July 10, 2017 13:04
All Top-Level-Domains as single level objects in one JSON file
{
".ac": "Ascension Island",
".ad": "Andorra",
".ae": "United Arab Emirates",
".af": "Afghanistan",
".ag": "Antigua and Barbuda",
".ai": "Anguilla",
".al": "Albania",
".am": "Armenia",
".an": "Netherlands Antilles",
@timothycrosley
timothycrosley / versioning.py
Created March 11, 2016 07:00
A simple example of a hug API call with versioning
"""A simple example of a hug API call with versioning"""
import hug
@hug.get('/echo', versions=1)
def echo(text):
return text