Skip to content

Instantly share code, notes, and snippets.

@nrosner
nrosner / jarstats.py
Created March 4, 2017 02:25
A Python script to count the number of classes and methods in a .jar file using javap.
#!/usr/bin/env python
import sys, os, re, zipfile, subprocess
# Rudimentary parsing of javap output
regex_type = r'[a-zA-Z0-9.<>, ?$[\]]+'
regex_class = r'(?:(public|private|protected) )?((?:(?:static|abstract|final) ?)*)(class|interface) (' + regex_type + ') (?:extends ((?:' + regex_type +'),?)+ )?(?:implements ((?:[a-zA-Z0-9\\.<>\\?\\$])+,?)+ )?{([^}]+)}'
regex_method = r'(?:(public|private|protected) )?((?:static|abstract|final) ?)*(?:(' + regex_type + ') )?([a-zA-Z]+)\\(([^\\)]*)\\)'
regex_field = r'(?:(public|private|protected) )?((?:(?:static|abstract|final) ?)*)(' + regex_type + ') ([a-zA-Z0-9]+)'
RE_TYPE = re.compile(regex_type)
@alexellis
alexellis / timelapse.md
Created March 9, 2017 08:48 — forked from porjo/timelapse.md
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

  • -r 24 - output frame rate
  • -pattern_type glob -i '*.JPG' - all JPG files in the current directory
  • -i DSC_%04d.JPG - e.g. DSC_0397.JPG
  • -s hd1080 - 1920x1080 resolution

Slower, better quality

public void onAttach(View view) {
// Remember to clean the subscription!
repository.getDataEventStream().subscribe({ event ->
if (event.isLoading) {
view.showLoading(true)
} else if (event.hasError()) {
view.showError(event.getError())
} else {
view.showData(event.getData())
}
final PublishRelay<String> refreshRelay = PublishRelay.create()
void refreshData() {
refreshRelay.call("refresh event")
}
Observable<Lce<Data>> getDataEventStream() {
return refreshRelay
.startWith("initial")
.switchMap { event ->
#!/usr/bin/swift
// Run: $ swift noCrashplan.swift
// Background: https://github.com/KrauseFx/overkill/issues/3#issuecomment-270505227
import Foundation
import Cocoa
import ServiceManagement
let badApps = [ "Code42 CrashPlan", "CrashPlanService", "CrashPlanLauncher", "CrashPlanWeb" ]
@BrantApps
BrantApps / oceanlife-activity-fragment.graphml
Last active February 27, 2018 18:08
Degraph configuration file used within BrantApps/OceanLife to isolate and visualise package tangle. See http://blog.schauderhaft.de/degraph/ & https://github.com/schauder/degraph
output = oceanlife-activity-fragment.graphml
classpath = ../../../OceanLife/app/build/intermediates/classes/withAmazon/debug/com/brantapps/oceanlife/
# Don’t model dependencies
exclude = java*.**
exclude = android*.**
exclude = dagger*.**
exclude = rx*.**
exclude = okhttp*.**
exclude = org*.**
@lyshie
lyshie / BackupAndroid.md
Last active November 16, 2021 20:32
Backup Android device via SSHelper and rsync
  • Install SSHelper or 08.30.2018 Version 11.9
  • mount Android device via sshfs
    $ printf "admin\n" | sshfs [email protected]:/ ~/mnt -o port=2222,password_stdin
    
  • use rsync to backup all files
    $ rsync -avH --progress ~/mnt/storage/extSdCard/DCIM .
    
  • passwordless login
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@brianegan
brianegan / spinnies2.dart
Created January 21, 2019 17:43
Shows how to create some funky spinners
import 'dart:math' show pi;
import 'package:flutter/material.dart';
/// A Widget that can be configured to show funky spinning rectangles!
///
/// ### Usage
///
/// ```
/// Spinnies(
@alexjlockwood
alexjlockwood / CircleSquareView.kt
Created April 8, 2019 05:59
Inspired by @beesandbombs (twitter.com/beesandbombs)
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt