Skip to content

Instantly share code, notes, and snippets.

@beall49
beall49 / MockTest.java
Created January 10, 2018 19:44
How to mock Static Class
@RunWith(PowerMockRunner.class) @PowerMockIgnore("javax.net.ssl.*") @PrepareForTest(WeatherUtil.class)
public class WeatherTest {
@Test public void testGoodPayload() {
PowerMockito.mockStatic(WeatherUtil.class);
weatherObject = jsonToObject(stringToJson(goodPayload));
when(WeatherUtil.getWeatherBody(LLNL_WEATHER)).thenReturn(weatherObject);
when(WeatherUtil.getWeather(LLNL)).thenCallRealMethod();
when(WeatherUtil.getSiteId(Mockito.anyObject())).thenCallRealMethod();
Weather testWeather = WeatherUtil.getWeather(LLNL);
assertNotNull(testWeather);
@beall49
beall49 / mp3_length.py
Created January 3, 2018 05:49
sum mp3 lengths in a directory
from mutagen.mp3 import MP3
import glob
seconds = 0.0
for f in glob.glob("*.mp3"):
audio = MP3(f)
seconds = seconds + audio.info.length
print (seconds//3600)
#%RAML 1.0
title: Skeleton API
version: v1
baseUri: https://api.example.com/
traits:
standard-error-responses:
responses:
@beall49
beall49 / mp3_split.py
Last active September 23, 2017 03:46
split mp3 in 20 min intervals using mp3splt
"""
install mp3splt http://mp3splt.sourceforge.net/mp3splt_page/home.php
add to environment variable PATH=>C:\Program Files (x86)\mp3splt or
save and run this file from that location
"""
import os
import glob
from subprocess import call
MAVEN_HOME="/usr/local/Cellar/maven/3.5.0/libexec"
export MAVEN_HOME
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
export JAVA_HOME
PYTHONPATH="/usr/bin/python2.7"
export PYTHONPATH
@beall49
beall49 / clone_all_branches.sh
Created April 25, 2017 05:02
clone all branches
#clone
$ git clone https://git.some.repo/
$ cd myproject
#list all branches
$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/orders
// Place your settings in this file to overwrite the default settings
{
"eslint.enable": false,
"telemetry.enableTelemetry": true,
"window.openFilesInNewWindow": "off",
"window.zoomLevel": 0,
"files.associations": {"*.dwl":"yaml","*.xml":"xml"},
"python.linting.pylintEnabled": false,
"python.linting.enabled": false,
"http.proxyStrictSSL": false,
@beall49
beall49 / overwrite_master_branch.sh
Last active April 9, 2023 11:51
Overwrite master with another branch
git checkout BRANCH_THAT_YOU_WANT_TO_BE_MASTER
git merge -s ours master
git checkout master
git merge BRANCH_THAT_YOU_WANT_TO_BE_MASTER
https://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch
package mypackage;
import com.auth0.jwt.*;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.DecodedJWT;
import java.util.HashMap;
public class JWTBuilder {
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Reactive.Linq;
using System.Threading.Tasks;