Skip to content

Instantly share code, notes, and snippets.

View kevinthecity's full-sized avatar

Kevin Grant kevinthecity

  • LatticeHR
  • New York City
View GitHub Profile
More docs - https://sonos.svrooij.io/services/rendering-control#setrelativevolume
Get IP Address from your Sonos App - Settings -> General Settings -> About you system
// Set Relative Volume
curl -X POST "http://192.168.XXX.XXX:1400/MediaRenderer/RenderingControl/Control" \
-H "SOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#SetRelativeVolume\"" \
-H "Content-Type: text/xml; charset=utf-8" \
--data '<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
from flask import Blueprint, redirect, request, session, render_template
from spotipy.oauth2 import SpotifyOAuth
import spotipy
import random
# Spotify credentials
SPOTIPY_CLIENT_ID = "your client id"
SPOTIPY_CLIENT_SECRET = "your secret"
SPOTIPY_REDIRECT_URI = "http://localhost:5000/spotify/callback"
@kevinthecity
kevinthecity / ag-replace.sh
Created May 26, 2023 20:15
Find / Replace in directory
# ag <https://github.com/ggreer/the_silver_searcher>
# requires ag -> brew install the_silver_searcher
# usage: ag-replace.sh [search] [replace]
# caveats: will choke if either arguments contain a forward slash
# notes: will back up changed files to *.bak files. Remove the second line if you'd like to keep them
ag -0 -l $1 | xargs -0 sed -ri.bak -e "s/$1/$2/g";
git clean -f '**/*.bak';
@kevinthecity
kevinthecity / find_unused_keys.sh
Created May 26, 2023 19:43
Script for finding keys in a folder directory
#!/bin/bash
# brew install the_silver_searcher https://github.com/ggreer/the_silver_searcher
# Add this script somewhere, and update permissions: chmod +x find_unused_keys.sh
# usage: ./find_unused_keys.sh keys.csv [optional: /path/to/search/]
# column 1 should be the key, column 2 should be the team name
CSV_FILE=$1
@kevinthecity
kevinthecity / .lua
Last active March 14, 2023 02:47
Simple repair mod for Project Zomboid.
-- Project forked from existing repair mod https://steamcommunity.com/sharedfiles/filedetails/?id=2852867235&searchtext=better+repair
-- Docs https://projectzomboid.com/modding/zombie/characters/package-summary.html
local ISFixAction_perform = ISFixAction.perform
-- Random chance to return true if the repair counter should be frozen (e.g. this item can no longer break)
local function shouldFreezeRepairCount()
local chance = SandboxVars.PRM.stopCounterChance
if chance == 0 then return false end
local a = ZombRand(0, 101)
local b = 100 - chance
/**
* Shake a view with a preset cycle interpolater
*
* @param view
* the view to shake
*/
public static void shakeIt(final View view) {
if (view != null) {
Animation shakeAnimation = new TranslateAnimation(0, 10, 0, 0);
shakeAnimation.setDuration(300);
https://drive.google.com/file/d/0B31CyA6eg0M6NU9sNWpxMkJham8/edit?usp=sharing
<!--
Copyright (C) 2014 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@kevinthecity
kevinthecity / gist:11192121
Last active August 29, 2015 14:00
Recursively remove children from ViewGroups
public static void removeAllViews(final ViewGroup viewGroup) {
while (viewGroup.getChildCount() != 0) {
boolean childrenHaveChildren = false;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
final View child = viewGroup.getChildAt(i);
if (child instanceof ViewGroup) {
/**
* Converts a DP value to a PX value.
*
* @param context
* the context to use.
* @param dp
* the DP value to convert.
* @return the converted PX value.
*/
public static int getPxFromDp(Context context, float dp) {