Skip to content

Instantly share code, notes, and snippets.

View scarsman's full-sized avatar

Perpo Hipolito scarsman

View GitHub Profile
@scarsman
scarsman / test_bottle.py
Created July 22, 2020 07:21
run bottle api using gunicorn server
#run bottle api using gunicorn
from bottle import Bottle
app = Bottle()
@app.route("/")
def index():
return "test index"
@scarsman
scarsman / graphqlapp.py
Created February 25, 2020 02:19 — forked from sergiolucero/graphqlapp.py
basic flask-graphql app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from flask_graphql import GraphQLView
#################################
app = Flask(__name__)
app.debug = True
def extract_values(obj, key):
"""Recursively pull values of specified key from nested JSON."""
arr = []
def extract(obj, arr, key):
"""Return all matching values in an object."""
if isinstance(obj, dict):
for k, v in obj.items():
if isinstance(v, (dict, list)):
extract(v, arr, key)
#!/bin/bash
# This is for Ubuntu
apt-get install xinetd
(
cat << 'EOF'
# default: on
# description: mysqlchk
service mysqlchk
{
@scarsman
scarsman / git-merge-po.sh
Created July 17, 2018 06:20 — forked from mezis/git-merge-po.sh
Git merge driver for PO files
#!/bin/sh
#
# *******************************************
# WARNING: this does *not* handle 3-way merges properly.
# Anything modified on the local branch since the common base will get ignored.
#
# FOR ANYONE LANDING HERE:
# This script is now updated as part of the git-whistles gem.
# https://github.com/mezis/git-whistles
# *******************************************
@scarsman
scarsman / git-list-branches.sh
Created July 17, 2018 06:19 — forked from mezis/git-list-branches.sh
List all remote local or branches in your repo, along with colourful freshness information!
#!/bin/bash
#
# List branch status and age against an integration branch.
#
# Copyright (C) 2012 Julien Letessier
#
# 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
@scarsman
scarsman / git-chop.sh
Created July 17, 2018 06:19 — forked from mezis/git-chop.sh
Close a feature branch - removing it from local and remote
#!/bin/bash
#
# Close a feature branch - removing it from local and remote.
#
die() {
echo "$@" ; exit 1
}
head=$(git symbolic-ref HEAD 2> /dev/null || git log -1 --format=%h)
@scarsman
scarsman / query_finder.sql
Created July 17, 2018 06:17 — forked from mezis/query_finder.sql
Finding long-running queries in MySQL
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120)
FROM information_schema.processlist
WHERE command <> 'Sleep'
AND info NOT LIKE '%PROCESSLIST%'
ORDER BY time DESC LIMIT 50;
@scarsman
scarsman / proxy.py
Created December 12, 2017 05:10 — forked from tkhn/proxy.py
A very basic caching python HTTP proxy server.
# Originally from http://sharebear.co.uk/blog/2009/09/17/very-simple-python-caching-proxy/
#
# Usage:
# A call to http://localhost:80000/example.com/foo.html will cache the file
# at http://example.com/foo.html on disc and not redownload it again.
# To clear the cache simply do a `rm *.cached`. To stop the server simply
# send SIGINT (Ctrl-C). It does not handle any headers or post data.
import BaseHTTPServer
import hashlib
@scarsman
scarsman / node-and-npm-in-30-seconds.sh
Created November 3, 2017 02:02 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh