Skip to content

Instantly share code, notes, and snippets.

View randerzander's full-sized avatar

Randy Gelhausen randerzander

View GitHub Profile
@randerzander
randerzander / football.css
Last active November 26, 2022 13:42
Terminal UI for displaying live college or nfl game status
Game {
height: 3;
width: 50%;
}
@randerzander
randerzander / things.py
Last active November 25, 2022 19:11
Basic dynamic textual app
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.reactive import reactive
from textual.widgets import Static
class Thing(Static):
def __init__( self, text ) -> None:
self._text = text
super().__init__()
@randerzander
randerzander / control.sh
Last active November 22, 2022 11:54
Ambari Service Start/Stop script
USER='admin'
PASS='admin'
CLUSTER='dev'
HOST=$(hostname -f):8080
function start(){
curl -u $USER:$PASS -i -H 'X-Requested-By: ambari' -X PUT -d \
'{"RequestInfo": {"context" :"Start '"$1"' via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' \
http://$HOST/api/v1/clusters/$CLUSTER/services/$1
}
@randerzander
randerzander / front.html
Last active October 24, 2022 12:47
zeppelin angular-tricks
%angular
<input id="textbox" class="hide" ng-model="someAngularVar"></input>
<button id="btn" type="submit" onclick="update()">UpperCase It!</button>
<script type="text/javascript">
function update(){
var element = $('#textbox');
var currentVal = element.val();
//Update the value
element.val(currentVal.toUpperCase());
# determines whether a GPU is available in your instance and starts an appropriate Dask Cluster
from dask.distributed import Client, LocalCluster
from dask_cuda import LocalCUDACluster
from dask_sql import Context
from pyngrok import ngrok
import dask
import time
import warnings
from IPython.core.magic import needs_local_scope, register_cell_magic
@randerzander
randerzander / pyPhoenix
Created April 20, 2015 18:09
Apache Phoenix via Python
import jaydebeapi
conn = jaydebeapi.connect('org.apache.phoenix.jdbc.PhoenixDriver', \
['jdbc:phoenix:my_zk_server:2181:/hbase-unsecure', '', ''], \
'/usr/hdp/current/phoenix-client/phoenix-client.jar')
curs = conn.cursor()
curs.execute('select * from WEB_STAT limit 1')
curs.fetchall()
from IPython.core.magic import register_cell_magic, needs_local_scope
from sql_formatter.core import format_sql
import time, warnings
warnings.filterwarnings("ignore")
@register_cell_magic
@needs_local_scope
def sql(line, cell, local_ns):
sql_statement = cell.format(**local_ns)
df = spark.createDataFrame(
[
(1, 'foo'), # create your data here, be consistent in the types.
(2, 'bar'),
],
['id', 'txt'] # add your columns label here
)
df.write.csv('test')
spark.read.csv('test').collect()
@randerzander
randerzander / distget
Last active January 13, 2021 09:49
distget for hadoop
# Put a list of URLs in a file, inputs.txt
echo ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/by_year/2009.csv.gz > input.txt
echo ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/by_year/2010.csv.gz >> input.txt
# Trick to force MapReduce to treat each line in inputs.txt as a single map task
mkdir input
cd input
# I used 1 line per file - tweak for smaller downloads & fewer map tasks
split -l 1 ../input.txt
hadoop fs -put input .
@randerzander
randerzander / tickets.py
Last active August 18, 2020 16:48
SalesForce open cases list
# See https://pip.pypa.io/en/latest/installing.html for how to install pip, then:
# pip install simple-salesforce
from simple_salesforce import Salesforce
import string
# To get your SFDC token, see https://help.salesforce.com/apex/HTViewHelpDoc?id=user_security_token.htm
# salesforce_login.txt should contain the following, one per line:
# Your Name
# your_email@sfdc_account.com
# your_password