Skip to content

Instantly share code, notes, and snippets.

@xtream1101
xtream1101 / Backup&RestoreRepo.md
Created June 29, 2019 12:38
Backup and restore a git repo using git bundle

Backup/archive a repo

  1. Clone the repo
git clone --mirror https://github.com/vuejs/vue
  1. cd into the cloned repo
  2. Create a bundle file in the parent directory
git bundle create ../vuejs_vue.bundle --all
@xtream1101
xtream1101 / instacart_scraper.py
Last active January 31, 2022 03:21
Instacart scraper
import json
import time
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from webdriverdownloader import GeckoDriverDownloader
@xtream1101
xtream1101 / getty.py
Last active October 3, 2018 16:01
Quick example on how to download videos off getty images using only requests
import logging
import requests
import urllib
import urllib.parse
from parsel import Selector
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
"""Sort a list of dicts using multiple keys
Also be able to have the different keys sort in different orders
"""
from pprint import pprint
unsorted_data_a = [{'title': 'Foo Beta',
'date': '2018-06-03',
'value': 5},
@xtream1101
xtream1101 / sublime.sh
Created November 25, 2017 05:25
Auto create and open sublime projects
sublime_project_template='{
"folders":
[
{
"path": "."
}
],
"file_exclude_patterns":[
"*.sublime-*"
]
@xtream1101
xtream1101 / open_dirty_git_files.sh
Created November 2, 2017 17:26
Open all git files that have been modified or are untracked in sublime (or your editor of choice)
git status -s | cut -c4- | xargs -L1 sublime
@xtream1101
xtream1101 / Try #1.sql
Created April 21, 2017 14:31
Dynamic QA query
#1
DROP FUNCTION qa_fields(character varying,character varying);
CREATE OR REPLACE FUNCTION qa_fields(schema_name VARCHAR, tbl_name VARCHAR)
-- The table def needs to be known before the function runs, but the number of fields returned is dynamic :(
-- Also need to correct names for the fields, the types will alwyas be FLOAT
RETURNS TABLE(a FLOAT, b FLOAT, c FLOAT, d FLOAT, e FLOAT, f FLOAT, g FLOAT, h FLOAT, i FLOAT, j FLOAT, k FLOAT, l FLOAT, m FLOAT, n FLOAT, o FLOAT, p FLOAT, q FLOAT, r FLOAT, s FLOAT, t FLOAT, u FLOAT, v FLOAT, w FLOAT, x FLOAT, ts DATE) AS
$func$
DECLARE field_name VARCHAR;
@xtream1101
xtream1101 / python_venv_shortcuts.sh
Last active December 6, 2016 21:46
Easy python environments
# Put this code in your .bashrc or .bash_profile
# Get Virtual Env
Color_Off="\033[0m" # Text Reset
Purple="\033[0;35m" # Purple
virtualenv_prompt() {
if [[ $VIRTUAL_ENV != "" ]]; then
venv=${VIRTUAL_ENV##*/}
# Strip out the path and just leave the env name
@xtream1101
xtream1101 / X's Scrapers.md
Last active August 27, 2017 20:10
Current Scrapers
// ==UserScript==
// @name Periscope Auto refresh all
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Refresh all table on an interval
// @author xtream1101
// @match https://www.periscopedata.com/app/*
// @grant none
// @downloadURL https://gist.githubusercontent.com/xtream1101/211332c4cb2062a77010f623796a6431/raw/periscope_auto_refresh.js
// @updateURL https://gist.githubusercontent.com/xtream1101/211332c4cb2062a77010f623796a6431/raw/periscope_auto_refresh.js