Skip to content

Instantly share code, notes, and snippets.

View TheMatt2's full-sized avatar

Matthew Schweiss TheMatt2

View GitHub Profile
@jtriley
jtriley / terminalsize.py
Created July 26, 2011 21:58
Get current terminal size on Linux, Mac, and Windows
#!/usr/bin/env python
import os
import shlex
import struct
import platform
import subprocess
def get_terminal_size():
""" getTerminalSize()
@glennblock
glennblock / fork forced sync
Created March 4, 2012 19:27
Force your forked repo to be the same as upstream.
git fetch upstream
git reset --hard upstream/master
@josephbisch
josephbisch / OPR_Calculator.py
Created March 21, 2012 14:46
Calculates OPR from a single event's data that is input as csv files
# Calculates OPR
# For implementation details, see
# http://www.chiefdelphi.com/forums/showpost.php?p=1129108&postcount=55
# M is 2m x n where m is # of matches and n is # of teams
# s is 2m x 1 where m is # of matches
# solve [M][x]=[s] for [x] by turning it into [A][x]=[b]
# A should end up being n x n an b should end up being n x 1
# x is OPR and should be n x 1
@abevoelker
abevoelker / pipelines.py
Last active March 17, 2024 05:59
scrapy RabbitMQ pipeline
# project_name/pipelines.py
from scrapy import signals
from scrapy.utils.serialize import ScrapyJSONEncoder
from scrapy.xlib.pydispatch import dispatcher
from carrot.connection import BrokerConnection
from carrot.messaging import Publisher
from twisted.internet.threads import deferToThread
@jobsamuel
jobsamuel / readme.md
Last active January 19, 2024 18:26
Run NodeJS as a Service on Ubuntu 14.04 LTS

Run NodeJS as a Service on Ubuntu 14.04 LTS

With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?

  • Go to /etc/init/
  • $ sudo vim yourapp.conf
  • Paste script.conf
  • $ sudo start yourapp
  • And when you wanna kill the process $ sudo stop yourapp
@zed
zed / url2filename.py
Last active September 3, 2022 04:42
Extract filename from an url
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import posixpath
try:
from urlparse import urlsplit
from urllib import unquote
except ImportError: # Python 3
from urllib.parse import urlsplit, unquote
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 28, 2024 03:34
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@Daenyth
Daenyth / debug_requests.py
Created August 27, 2015 14:35
Enable debug logging for python requests
import requests
import logging
import httplib
# Debug logging
httplib.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
req_log = logging.getLogger('requests.packages.urllib3')
req_log.setLevel(logging.DEBUG)
@jomo
jomo / Minecraft Accounts.md
Last active July 25, 2024 18:25
Tracking down Minecraft account creation

Tracks down when a Minecraft account was created.

How it works

Mojang has an API endpoint for usernames:

https://api.mojang.com/users/profiles/minecraft/<name>?at=<timestamp>

It can be used to find the UUID of an account, by username it used at the given time.
It returns either 200 OK or 204 No Content – indicating that the username was not in use at the time.

@santisbon
santisbon / Update-branch.md
Last active March 21, 2024 15:50
Deploying from #Git branches adds flexibility. Bring your feature branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.

Updating a feature branch

First we'll update your local master branch. Go to your local project and check out the branch you want to merge into (your local master branch)

$ git checkout master

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to master will be stored in a local branch, remotes/origin/master.